Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_BINDINGS_H_ |
| 6 #define CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_ | 6 #define CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_BINDINGS_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "content/public/browser/devtools_agent_host.h" | 15 #include "content/public/browser/devtools_agent_host.h" |
| 16 #include "content/public/browser/devtools_frontend_host.h" | 16 #include "content/public/browser/devtools_frontend_host.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "net/url_request/url_fetcher_delegate.h" | 18 #include "net/url_request/url_fetcher_delegate.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class Value; | 21 class Value; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 class ShellDevToolsDelegate { | |
| 27 public: | |
| 28 virtual void Close() = 0; | |
|
dgozman
2017/03/17 22:44:14
You also need empty virtual destructor.
chenwilliam
2017/03/20 21:32:20
:o - thanks!
| |
| 29 }; | |
| 30 | |
| 26 class RenderViewHost; | 31 class RenderViewHost; |
| 27 class Shell; | |
| 28 class WebContents; | 32 class WebContents; |
| 29 | 33 |
| 30 class ShellDevToolsFrontend : public WebContentsObserver, | 34 class ShellDevToolsBindings : public WebContentsObserver, |
| 31 public DevToolsAgentHostClient, | 35 public DevToolsAgentHostClient, |
| 32 public net::URLFetcherDelegate { | 36 public net::URLFetcherDelegate { |
| 33 public: | 37 public: |
| 34 static ShellDevToolsFrontend* Show(WebContents* inspected_contents); | 38 ShellDevToolsBindings(WebContents* devtools_contents, |
| 39 WebContents* inspected_contents, | |
| 40 ShellDevToolsDelegate* delegate); | |
| 35 | 41 |
| 36 void Activate(); | |
| 37 void Focus(); | |
| 38 void InspectElementAt(int x, int y); | 42 void InspectElementAt(int x, int y); |
| 39 void Close(); | |
| 40 | 43 |
| 41 void DisconnectFromTarget(); | 44 void DisconnectFromTarget(); |
| 42 | 45 |
| 43 Shell* frontend_shell() const { return frontend_shell_; } | 46 WebContents* devtools_contents() const { return devtools_contents_; } |
| 47 WebContents* inspected_contents() const { return inspected_contents_; } | |
| 44 | 48 |
| 45 void CallClientFunction(const std::string& function_name, | 49 void CallClientFunction(const std::string& function_name, |
| 46 const base::Value* arg1, | 50 const base::Value* arg1, |
| 47 const base::Value* arg2, | 51 const base::Value* arg2, |
| 48 const base::Value* arg3); | 52 const base::Value* arg3); |
| 53 void SetPreferences(const std::string& json); | |
|
dgozman
2017/03/17 22:44:14
This should be protected.
chenwilliam
2017/03/20 21:32:20
Done.
| |
| 54 void CreateFrontendHost(); | |
| 55 ~ShellDevToolsBindings() override; | |
| 49 | 56 |
| 50 protected: | 57 protected: |
| 51 ShellDevToolsFrontend(Shell* frontend_shell, WebContents* inspected_contents); | |
| 52 ~ShellDevToolsFrontend() override; | |
| 53 | |
| 54 // content::DevToolsAgentHostClient implementation. | 58 // content::DevToolsAgentHostClient implementation. |
| 55 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override; | 59 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override; |
| 56 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, | 60 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
| 57 const std::string& message) override; | 61 const std::string& message) override; |
| 58 void SetPreferences(const std::string& json); | 62 |
| 59 virtual void HandleMessageFromDevToolsFrontend(const std::string& message); | 63 virtual void HandleMessageFromDevToolsFrontend(const std::string& message); |
| 60 | 64 |
| 61 private: | 65 private: |
| 62 // WebContentsObserver overrides | 66 // WebContentsObserver overrides |
| 63 void RenderViewCreated(RenderViewHost* render_view_host) override; | 67 void RenderViewCreated(RenderViewHost* render_view_host) override; |
| 64 void DocumentAvailableInMainFrame() override; | 68 void DocumentAvailableInMainFrame() override; |
| 65 void WebContentsDestroyed() override; | 69 void WebContentsDestroyed() override; |
| 66 | 70 |
| 67 // net::URLFetcherDelegate overrides. | 71 // net::URLFetcherDelegate overrides. |
| 68 void OnURLFetchComplete(const net::URLFetcher* source) override; | 72 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 69 | 73 |
| 70 void SendMessageAck(int request_id, | 74 void SendMessageAck(int request_id, const base::Value* arg1); |
| 71 const base::Value* arg1); | |
| 72 | 75 |
| 73 Shell* frontend_shell_; | 76 WebContents* devtools_contents_; |
| 74 WebContents* inspected_contents_; | 77 WebContents* inspected_contents_; |
| 78 ShellDevToolsDelegate* delegate_; | |
| 75 scoped_refptr<DevToolsAgentHost> agent_host_; | 79 scoped_refptr<DevToolsAgentHost> agent_host_; |
| 76 int inspect_element_at_x_; | 80 int inspect_element_at_x_; |
| 77 int inspect_element_at_y_; | 81 int inspect_element_at_y_; |
| 78 std::unique_ptr<DevToolsFrontendHost> frontend_host_; | 82 std::unique_ptr<DevToolsFrontendHost> frontend_host_; |
| 79 using PendingRequestsMap = std::map<const net::URLFetcher*, int>; | 83 using PendingRequestsMap = std::map<const net::URLFetcher*, int>; |
| 80 PendingRequestsMap pending_requests_; | 84 PendingRequestsMap pending_requests_; |
| 81 base::DictionaryValue preferences_; | 85 base::DictionaryValue preferences_; |
| 82 base::WeakPtrFactory<ShellDevToolsFrontend> weak_factory_; | 86 base::WeakPtrFactory<ShellDevToolsBindings> weak_factory_; |
| 83 | 87 |
| 84 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsFrontend); | 88 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsBindings); |
| 85 }; | 89 }; |
| 86 | 90 |
| 87 } // namespace content | 91 } // namespace content |
| 88 | 92 |
| 89 #endif // CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_ | 93 #endif // CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_BINDINGS_H_ |
| OLD | NEW |