Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: content/shell/browser/shell_devtools_bindings.h

Issue 2756623002: DevTools: extract bindings from ShellDevToolsFrontend (Closed)
Patch Set: fixup Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/shell/browser/shell.cc ('k') | content/shell/browser/shell_devtools_bindings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
17 #include "net/url_request/url_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
18 19
19 #if !defined(OS_ANDROID) 20 #if !defined(OS_ANDROID)
20 #include "content/public/browser/devtools_frontend_host.h" 21 #include "content/public/browser/devtools_frontend_host.h"
21 #endif 22 #endif
22 23
23 namespace base { 24 namespace base {
24 class Value; 25 class Value;
25 } 26 }
26 27
27 namespace content { 28 namespace content {
28 29
29 class RenderViewHost; 30 class ShellDevToolsDelegate {
30 class Shell; 31 public:
32 virtual void Close() = 0;
33 virtual ~ShellDevToolsDelegate(){};
34 };
35
31 class WebContents; 36 class WebContents;
32 37
33 class ShellDevToolsFrontend : public WebContentsObserver, 38 class ShellDevToolsBindings : public WebContentsObserver,
34 public DevToolsAgentHostClient, 39 public DevToolsAgentHostClient,
35 public net::URLFetcherDelegate { 40 public net::URLFetcherDelegate {
36 public: 41 public:
37 static ShellDevToolsFrontend* Show(WebContents* inspected_contents); 42 ShellDevToolsBindings(WebContents* devtools_contents,
43 WebContents* inspected_contents,
44 ShellDevToolsDelegate* delegate);
38 45
39 void Activate();
40 void Focus();
41 void InspectElementAt(int x, int y); 46 void InspectElementAt(int x, int y);
42 void Close();
43
44 void DisconnectFromTarget();
45
46 Shell* frontend_shell() const { return frontend_shell_; }
47 47
48 void CallClientFunction(const std::string& function_name, 48 void CallClientFunction(const std::string& function_name,
49 const base::Value* arg1, 49 const base::Value* arg1,
50 const base::Value* arg2, 50 const base::Value* arg2,
51 const base::Value* arg3); 51 const base::Value* arg3);
52 ~ShellDevToolsBindings() override;
52 53
53 protected: 54 protected:
54 ShellDevToolsFrontend(Shell* frontend_shell, WebContents* inspected_contents);
55 ~ShellDevToolsFrontend() override;
56
57 // content::DevToolsAgentHostClient implementation. 55 // content::DevToolsAgentHostClient implementation.
58 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override; 56 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override;
59 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, 57 void DispatchProtocolMessage(DevToolsAgentHost* agent_host,
60 const std::string& message) override; 58 const std::string& message) override;
59
61 void SetPreferences(const std::string& json); 60 void SetPreferences(const std::string& json);
62 virtual void HandleMessageFromDevToolsFrontend(const std::string& message); 61 virtual void HandleMessageFromDevToolsFrontend(const std::string& message);
62 void CreateFrontendHost();
63 63
64 private: 64 private:
65 // WebContentsObserver overrides 65 // WebContentsObserver overrides
66 void RenderViewCreated(RenderViewHost* render_view_host) override; 66 void RenderViewCreated(RenderViewHost* render_view_host) override;
67 void DocumentAvailableInMainFrame() override; 67 void DocumentAvailableInMainFrame() override;
68 void WebContentsDestroyed() override; 68 void WebContentsDestroyed() override;
69 69
70 // net::URLFetcherDelegate overrides. 70 // net::URLFetcherDelegate overrides.
71 void OnURLFetchComplete(const net::URLFetcher* source) override; 71 void OnURLFetchComplete(const net::URLFetcher* source) override;
72 72
73 void SendMessageAck(int request_id, 73 void SendMessageAck(int request_id, const base::Value* arg1);
74 const base::Value* arg1);
75 74
76 Shell* frontend_shell_;
77 WebContents* inspected_contents_; 75 WebContents* inspected_contents_;
76 ShellDevToolsDelegate* delegate_;
78 scoped_refptr<DevToolsAgentHost> agent_host_; 77 scoped_refptr<DevToolsAgentHost> agent_host_;
79 int inspect_element_at_x_; 78 int inspect_element_at_x_;
80 int inspect_element_at_y_; 79 int inspect_element_at_y_;
81 #if !defined(OS_ANDROID) 80 #if !defined(OS_ANDROID)
82 std::unique_ptr<DevToolsFrontendHost> frontend_host_; 81 std::unique_ptr<DevToolsFrontendHost> frontend_host_;
83 #endif 82 #endif
84 using PendingRequestsMap = std::map<const net::URLFetcher*, int>; 83 using PendingRequestsMap = std::map<const net::URLFetcher*, int>;
85 PendingRequestsMap pending_requests_; 84 PendingRequestsMap pending_requests_;
86 base::DictionaryValue preferences_; 85 base::DictionaryValue preferences_;
87 base::WeakPtrFactory<ShellDevToolsFrontend> weak_factory_; 86 base::WeakPtrFactory<ShellDevToolsBindings> weak_factory_;
88 87
89 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsFrontend); 88 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsBindings);
90 }; 89 };
91 90
92 } // namespace content 91 } // namespace content
93 92
94 #endif // CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_ 93 #endif // CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_BINDINGS_H_
OLDNEW
« no previous file with comments | « content/shell/browser/shell.cc ('k') | content/shell/browser/shell_devtools_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698