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

Side by Side Diff: components/web_view/frame_devtools_agent.cc

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "components/web_view/frame_devtools_agent.h" 5 #include "components/web_view/frame_devtools_agent.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/guid.h" 12 #include "base/guid.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "components/web_view/frame_devtools_agent_delegate.h" 17 #include "components/web_view/frame_devtools_agent_delegate.h"
18 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" 18 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
19 #include "mojo/shell/public/cpp/application_impl.h" 19 #include "mojo/shell/public/cpp/shell.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 namespace web_view { 22 namespace web_view {
23 23
24 using devtools_service::DevToolsAgentClientPtr; 24 using devtools_service::DevToolsAgentClientPtr;
25 using devtools_service::DevToolsAgentPtr; 25 using devtools_service::DevToolsAgentPtr;
26 using devtools_service::DevToolsRegistryPtr; 26 using devtools_service::DevToolsRegistryPtr;
27 27
28 using mojo::String; 28 using mojo::String;
29 29
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 FrameDevToolsAgent* const owner_; 79 FrameDevToolsAgent* const owner_;
80 mojo::Binding<DevToolsAgentClient> binding_; 80 mojo::Binding<DevToolsAgentClient> binding_;
81 // The DevToolsAgentClient interface provided by the DevTools service. This 81 // The DevToolsAgentClient interface provided by the DevTools service. This
82 // class will forward DevToolsAgentClient method calls it receives to 82 // class will forward DevToolsAgentClient method calls it receives to
83 // |forward_client_|. 83 // |forward_client_|.
84 DevToolsAgentClientPtr forward_client_; 84 DevToolsAgentClientPtr forward_client_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(FrameDevToolsAgentClient); 86 DISALLOW_COPY_AND_ASSIGN(FrameDevToolsAgentClient);
87 }; 87 };
88 88
89 FrameDevToolsAgent::FrameDevToolsAgent(mojo::ApplicationImpl* app, 89 FrameDevToolsAgent::FrameDevToolsAgent(mojo::Shell* shell,
90 FrameDevToolsAgentDelegate* delegate) 90 FrameDevToolsAgentDelegate* delegate)
91 : app_(app), 91 : shell_(shell),
92 delegate_(delegate), 92 delegate_(delegate),
93 id_(base::GenerateGUID()), 93 id_(base::GenerateGUID()),
94 binding_(this) { 94 binding_(this) {
95 DCHECK(app_); 95 DCHECK(shell_);
96 DCHECK(delegate_); 96 DCHECK(delegate_);
97 } 97 }
98 98
99 FrameDevToolsAgent::~FrameDevToolsAgent() {} 99 FrameDevToolsAgent::~FrameDevToolsAgent() {}
100 100
101 void FrameDevToolsAgent::AttachFrame( 101 void FrameDevToolsAgent::AttachFrame(
102 DevToolsAgentPtr forward_agent, 102 DevToolsAgentPtr forward_agent,
103 Frame::ClientPropertyMap* devtools_properties) { 103 Frame::ClientPropertyMap* devtools_properties) {
104 RegisterAgentIfNecessary(); 104 RegisterAgentIfNecessary();
105 forward_agent_ = std::move(forward_agent); 105 forward_agent_ = std::move(forward_agent);
106 106
107 StringToVector(id_, &(*devtools_properties)["devtools-id"]); 107 StringToVector(id_, &(*devtools_properties)["devtools-id"]);
108 if (client_impl_) { 108 if (client_impl_) {
109 StringToVector(state_, &(*devtools_properties)["devtools-state"]); 109 StringToVector(state_, &(*devtools_properties)["devtools-state"]);
110 client_impl_->OnAttachedFrame(); 110 client_impl_->OnAttachedFrame();
111 } 111 }
112 112
113 // This follows Chrome's logic and relies on the fact that call IDs increase 113 // This follows Chrome's logic and relies on the fact that call IDs increase
114 // monotonously so iterating over |pending_messages_| preserves the order in 114 // monotonously so iterating over |pending_messages_| preserves the order in
115 // which they were received. 115 // which they were received.
116 for (const auto& item : pending_messages_) 116 for (const auto& item : pending_messages_)
117 forward_agent_->DispatchProtocolMessage(item.second); 117 forward_agent_->DispatchProtocolMessage(item.second);
118 } 118 }
119 119
120 void FrameDevToolsAgent::RegisterAgentIfNecessary() { 120 void FrameDevToolsAgent::RegisterAgentIfNecessary() {
121 if (binding_.is_bound()) 121 if (binding_.is_bound())
122 return; 122 return;
123 123
124 DevToolsRegistryPtr devtools_registry; 124 DevToolsRegistryPtr devtools_registry;
125 app_->ConnectToService("mojo:devtools_service", &devtools_registry); 125 shell_->ConnectToService("mojo:devtools_service", &devtools_registry);
126 126
127 devtools_registry->RegisterAgent(id_, binding_.CreateInterfacePtrAndBind()); 127 devtools_registry->RegisterAgent(id_, binding_.CreateInterfacePtrAndBind());
128 } 128 }
129 129
130 void FrameDevToolsAgent::HandlePageNavigateRequest( 130 void FrameDevToolsAgent::HandlePageNavigateRequest(
131 const base::DictionaryValue* request) { 131 const base::DictionaryValue* request) {
132 std::string method; 132 std::string method;
133 if (!request->GetString("method", &method) || method != "Page.navigate") 133 if (!request->GetString("method", &method) || method != "Page.navigate")
134 return; 134 return;
135 135
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 pending_messages_.erase(call_id); 187 pending_messages_.erase(call_id);
188 } 188 }
189 189
190 void FrameDevToolsAgent::OnForwardClientClosed() { 190 void FrameDevToolsAgent::OnForwardClientClosed() {
191 client_impl_.reset(); 191 client_impl_.reset();
192 state_.clear(); 192 state_.clear();
193 pending_messages_.clear(); 193 pending_messages_.clear();
194 } 194 }
195 195
196 } // namespace web_view 196 } // namespace web_view
OLDNEW
« no previous file with comments | « components/web_view/frame_devtools_agent.h ('k') | components/web_view/pending_web_view_load.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698