Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / content / shell / browser / shell_devtools_frontend.h
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_
6 #define CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/devtools_agent_host.h"
13 #include "content/public/browser/devtools_frontend_host.h"
14 #include "content/public/browser/web_contents_observer.h"
15
16 namespace content {
17
18 class RenderViewHost;
19 class Shell;
20 class WebContents;
21
22 class ShellDevToolsFrontend : public WebContentsObserver,
23                               public DevToolsFrontendHost::Delegate,
24                               public DevToolsAgentHostClient {
25  public:
26   static ShellDevToolsFrontend* Show(WebContents* inspected_contents);
27
28   void Activate();
29   void Focus();
30   void InspectElementAt(int x, int y);
31   void Close();
32
33   Shell* frontend_shell() const { return frontend_shell_; }
34
35  protected:
36   ShellDevToolsFrontend(Shell* frontend_shell, DevToolsAgentHost* agent_host);
37   ~ShellDevToolsFrontend() override;
38
39  private:
40   // WebContentsObserver overrides
41   void RenderViewCreated(RenderViewHost* render_view_host) override;
42   void DocumentOnLoadCompletedInMainFrame() override;
43   void WebContentsDestroyed() override;
44
45   // content::DevToolsFrontendHost::Delegate implementation.
46   void HandleMessageFromDevToolsFrontend(const std::string& message) override;
47   void HandleMessageFromDevToolsFrontendToBackend(
48       const std::string& message) override;
49
50   // content::DevToolsAgentHostClient implementation.
51   void DispatchProtocolMessage(DevToolsAgentHost* agent_host,
52                                const std::string& message) override;
53   void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override;
54
55   Shell* frontend_shell_;
56   scoped_refptr<DevToolsAgentHost> agent_host_;
57   scoped_ptr<DevToolsFrontendHost> frontend_host_;
58
59   DISALLOW_COPY_AND_ASSIGN(ShellDevToolsFrontend);
60 };
61
62 }  // namespace content
63
64 #endif  // CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_