OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_ | 5 #ifndef CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_ |
6 #define CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_ | 6 #define CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
12 #include "content/public/browser/devtools_agent_host.h" | 13 #include "content/public/browser/devtools_agent_host.h" |
13 #include "content/public/browser/devtools_frontend_host.h" | 14 #include "content/public/browser/devtools_frontend_host.h" |
14 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
15 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
16 | 17 |
| 18 namespace base { |
| 19 class Value; |
| 20 } |
| 21 |
17 namespace content { | 22 namespace content { |
18 | 23 |
19 class RenderViewHost; | 24 class RenderViewHost; |
20 class Shell; | 25 class Shell; |
21 class WebContents; | 26 class WebContents; |
22 | 27 |
23 class ShellDevToolsFrontend : public WebContentsObserver, | 28 class ShellDevToolsFrontend : public WebContentsObserver, |
24 public DevToolsFrontendHost::Delegate, | 29 public DevToolsFrontendHost::Delegate, |
25 public DevToolsAgentHostClient, | 30 public DevToolsAgentHostClient, |
26 public net::URLFetcherDelegate { | 31 public net::URLFetcherDelegate { |
27 public: | 32 public: |
28 static ShellDevToolsFrontend* Show(WebContents* inspected_contents); | 33 static ShellDevToolsFrontend* Show(WebContents* inspected_contents); |
29 | 34 |
30 void Activate(); | 35 void Activate(); |
31 void Focus(); | 36 void Focus(); |
32 void InspectElementAt(int x, int y); | 37 void InspectElementAt(int x, int y); |
33 void Close(); | 38 void Close(); |
34 | 39 |
35 void DisconnectFromTarget(); | 40 void DisconnectFromTarget(); |
36 | 41 |
37 Shell* frontend_shell() const { return frontend_shell_; } | 42 Shell* frontend_shell() const { return frontend_shell_; } |
38 | 43 |
| 44 void CallClientFunction(const std::string& function_name, |
| 45 const base::Value* arg1, |
| 46 const base::Value* arg2, |
| 47 const base::Value* arg3); |
| 48 |
39 protected: | 49 protected: |
40 ShellDevToolsFrontend(Shell* frontend_shell, DevToolsAgentHost* agent_host); | 50 ShellDevToolsFrontend(Shell* frontend_shell, DevToolsAgentHost* agent_host); |
41 ~ShellDevToolsFrontend() override; | 51 ~ShellDevToolsFrontend() override; |
42 | 52 |
43 // content::DevToolsAgentHostClient implementation. | 53 // content::DevToolsAgentHostClient implementation. |
44 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override; | 54 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override; |
45 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, | 55 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
46 const std::string& message) override; | 56 const std::string& message) override; |
47 void AttachTo(WebContents* inspected_contents); | 57 void AttachTo(WebContents* inspected_contents); |
48 | 58 |
49 private: | 59 private: |
50 // WebContentsObserver overrides | 60 // WebContentsObserver overrides |
51 void RenderViewCreated(RenderViewHost* render_view_host) override; | 61 void RenderViewCreated(RenderViewHost* render_view_host) override; |
52 void DidNavigateMainFrame( | 62 void DidNavigateMainFrame( |
53 const LoadCommittedDetails& details, | 63 const LoadCommittedDetails& details, |
54 const FrameNavigateParams& params) override; | 64 const FrameNavigateParams& params) override; |
55 void WebContentsDestroyed() override; | 65 void WebContentsDestroyed() override; |
56 | 66 |
57 // content::DevToolsFrontendHost::Delegate implementation. | 67 // content::DevToolsFrontendHost::Delegate implementation. |
58 void HandleMessageFromDevToolsFrontend(const std::string& message) override; | 68 void HandleMessageFromDevToolsFrontend(const std::string& message) override; |
59 void HandleMessageFromDevToolsFrontendToBackend( | 69 void HandleMessageFromDevToolsFrontendToBackend( |
60 const std::string& message) override; | 70 const std::string& message) override; |
61 | 71 |
62 // net::URLFetcherDelegate overrides. | 72 // net::URLFetcherDelegate overrides. |
63 void OnURLFetchComplete(const net::URLFetcher* source) override; | 73 void OnURLFetchComplete(const net::URLFetcher* source) override; |
64 | 74 |
| 75 void SendMessageAck(int request_id, |
| 76 const base::Value* arg1); |
| 77 |
65 Shell* frontend_shell_; | 78 Shell* frontend_shell_; |
66 scoped_refptr<DevToolsAgentHost> agent_host_; | 79 scoped_refptr<DevToolsAgentHost> agent_host_; |
67 scoped_ptr<DevToolsFrontendHost> frontend_host_; | 80 scoped_ptr<DevToolsFrontendHost> frontend_host_; |
68 using PendingRequestsMap = std::map<const net::URLFetcher*, int>; | 81 using PendingRequestsMap = std::map<const net::URLFetcher*, int>; |
69 PendingRequestsMap pending_requests_; | 82 PendingRequestsMap pending_requests_; |
| 83 base::WeakPtrFactory<ShellDevToolsFrontend> weak_factory_; |
70 | 84 |
71 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsFrontend); | 85 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsFrontend); |
72 }; | 86 }; |
73 | 87 |
74 } // namespace content | 88 } // namespace content |
75 | 89 |
76 #endif // CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_ | 90 #endif // CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_ |
OLD | NEW |