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

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

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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/web_view_impl.h" 5 #include "components/web_view/web_view_impl.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "components/devtools_service/public/cpp/switches.h" 12 #include "components/devtools_service/public/cpp/switches.h"
12 #include "components/mus/public/cpp/scoped_window_ptr.h" 13 #include "components/mus/public/cpp/scoped_window_ptr.h"
13 #include "components/mus/public/cpp/window.h" 14 #include "components/mus/public/cpp/window.h"
14 #include "components/mus/public/cpp/window_tree_connection.h" 15 #include "components/mus/public/cpp/window_tree_connection.h"
15 #include "components/web_view/client_initiated_frame_connection.h" 16 #include "components/web_view/client_initiated_frame_connection.h"
16 #include "components/web_view/frame.h" 17 #include "components/web_view/frame.h"
17 #include "components/web_view/frame_connection.h" 18 #include "components/web_view/frame_connection.h"
(...skipping 18 matching lines...) Expand all
36 37
37 using web_view::mojom::ButtonState; 38 using web_view::mojom::ButtonState;
38 39
39 //////////////////////////////////////////////////////////////////////////////// 40 ////////////////////////////////////////////////////////////////////////////////
40 // WebViewImpl, public: 41 // WebViewImpl, public:
41 42
42 WebViewImpl::WebViewImpl(mojo::ApplicationImpl* app, 43 WebViewImpl::WebViewImpl(mojo::ApplicationImpl* app,
43 mojom::WebViewClientPtr client, 44 mojom::WebViewClientPtr client,
44 mojo::InterfaceRequest<mojom::WebView> request) 45 mojo::InterfaceRequest<mojom::WebView> request)
45 : app_(app), 46 : app_(app),
46 client_(client.Pass()), 47 client_(std::move(client)),
47 binding_(this, request.Pass()), 48 binding_(this, std::move(request)),
48 root_(nullptr), 49 root_(nullptr),
49 content_(nullptr), 50 content_(nullptr),
50 find_controller_(this), 51 find_controller_(this),
51 navigation_controller_(this) { 52 navigation_controller_(this) {
52 if (EnableRemoteDebugging()) 53 if (EnableRemoteDebugging())
53 devtools_agent_.reset(new FrameDevToolsAgent(app_, this)); 54 devtools_agent_.reset(new FrameDevToolsAgent(app_, this));
54 OnDidNavigate(); 55 OnDidNavigate();
55 } 56 }
56 57
57 WebViewImpl::~WebViewImpl() { 58 WebViewImpl::~WebViewImpl() {
(...skipping 15 matching lines...) Expand all
73 } 74 }
74 75
75 client_->TopLevelNavigationStarted(pending_url.spec()); 76 client_->TopLevelNavigationStarted(pending_url.spec());
76 77
77 content_ = root_->connection()->NewWindow(); 78 content_ = root_->connection()->NewWindow();
78 content_->SetBounds(gfx::Rect(root_->bounds().size())); 79 content_->SetBounds(gfx::Rect(root_->bounds().size()));
79 root_->AddChild(content_); 80 root_->AddChild(content_);
80 content_->SetVisible(true); 81 content_->SetVisible(true);
81 content_->AddObserver(this); 82 content_->AddObserver(this);
82 83
83 scoped_ptr<PendingWebViewLoad> pending_load(pending_load_.Pass()); 84 scoped_ptr<PendingWebViewLoad> pending_load(std::move(pending_load_));
84 scoped_ptr<FrameConnection> frame_connection( 85 scoped_ptr<FrameConnection> frame_connection(
85 pending_load->frame_connection()); 86 pending_load->frame_connection());
86 mus::mojom::WindowTreeClientPtr window_tree_client = 87 mus::mojom::WindowTreeClientPtr window_tree_client =
87 frame_connection->GetWindowTreeClient(); 88 frame_connection->GetWindowTreeClient();
88 89
89 Frame::ClientPropertyMap client_properties; 90 Frame::ClientPropertyMap client_properties;
90 if (devtools_agent_) { 91 if (devtools_agent_) {
91 devtools_service::DevToolsAgentPtr forward_agent; 92 devtools_service::DevToolsAgentPtr forward_agent;
92 frame_connection->application_connection()->ConnectToService( 93 frame_connection->application_connection()->ConnectToService(
93 &forward_agent); 94 &forward_agent);
94 devtools_agent_->AttachFrame(forward_agent.Pass(), &client_properties); 95 devtools_agent_->AttachFrame(std::move(forward_agent), &client_properties);
95 } 96 }
96 97
97 mojom::FrameClient* frame_client = frame_connection->frame_client(); 98 mojom::FrameClient* frame_client = frame_connection->frame_client();
98 const uint32_t content_handler_id = frame_connection->GetContentHandlerID(); 99 const uint32_t content_handler_id = frame_connection->GetContentHandlerID();
99 frame_tree_.reset(new FrameTree(content_handler_id, content_, 100 frame_tree_.reset(
100 window_tree_client.Pass(), this, frame_client, 101 new FrameTree(content_handler_id, content_, std::move(window_tree_client),
101 frame_connection.Pass(), client_properties, 102 this, frame_client, std::move(frame_connection),
102 pending_load->navigation_start_time())); 103 client_properties, pending_load->navigation_start_time()));
103 } 104 }
104 105
105 void WebViewImpl::PreOrderDepthFirstTraverseTree(Frame* node, 106 void WebViewImpl::PreOrderDepthFirstTraverseTree(Frame* node,
106 std::vector<Frame*>* output) { 107 std::vector<Frame*>* output) {
107 output->push_back(node); 108 output->push_back(node);
108 for (Frame* child : node->children()) 109 for (Frame* child : node->children())
109 PreOrderDepthFirstTraverseTree(child, output); 110 PreOrderDepthFirstTraverseTree(child, output);
110 } 111 }
111 112
112 //////////////////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////////////////
113 // WebViewImpl, WebView implementation: 114 // WebViewImpl, WebView implementation:
114 115
115 void WebViewImpl::LoadRequest(mojo::URLRequestPtr request) { 116 void WebViewImpl::LoadRequest(mojo::URLRequestPtr request) {
116 navigation_controller_.LoadURL(request.Pass()); 117 navigation_controller_.LoadURL(std::move(request));
117 } 118 }
118 119
119 void WebViewImpl::GetWindowTreeClient( 120 void WebViewImpl::GetWindowTreeClient(
120 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> window_tree_client) { 121 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> window_tree_client) {
121 mus::WindowTreeConnection::Create( 122 mus::WindowTreeConnection::Create(
122 this, window_tree_client.Pass(), 123 this, std::move(window_tree_client),
123 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); 124 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
124 } 125 }
125 126
126 void WebViewImpl::Find(const mojo::String& search_text, 127 void WebViewImpl::Find(const mojo::String& search_text,
127 bool forward_direction) { 128 bool forward_direction) {
128 find_controller_.Find(search_text.To<std::string>(), forward_direction); 129 find_controller_.Find(search_text.To<std::string>(), forward_direction);
129 } 130 }
130 131
131 void WebViewImpl::StopFinding() { 132 void WebViewImpl::StopFinding() {
132 find_controller_.StopFinding(); 133 find_controller_.StopFinding();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 content_ = nullptr; 180 content_ = nullptr;
180 } 181 }
181 } 182 }
182 183
183 //////////////////////////////////////////////////////////////////////////////// 184 ////////////////////////////////////////////////////////////////////////////////
184 // WebViewImpl, FrameTreeDelegate implementation: 185 // WebViewImpl, FrameTreeDelegate implementation:
185 186
186 scoped_ptr<FrameUserData> WebViewImpl::CreateUserDataForNewFrame( 187 scoped_ptr<FrameUserData> WebViewImpl::CreateUserDataForNewFrame(
187 mojom::FrameClientPtr frame_client) { 188 mojom::FrameClientPtr frame_client) {
188 return make_scoped_ptr( 189 return make_scoped_ptr(
189 new ClientInitiatedFrameConnection(frame_client.Pass())); 190 new ClientInitiatedFrameConnection(std::move(frame_client)));
190 } 191 }
191 192
192 bool WebViewImpl::CanPostMessageEventToFrame(const Frame* source, 193 bool WebViewImpl::CanPostMessageEventToFrame(const Frame* source,
193 const Frame* target, 194 const Frame* target,
194 mojom::HTMLMessageEvent* event) { 195 mojom::HTMLMessageEvent* event) {
195 return true; 196 return true;
196 } 197 }
197 198
198 void WebViewImpl::LoadingStateChanged(bool loading, double progress) { 199 void WebViewImpl::LoadingStateChanged(bool loading, double progress) {
199 client_->LoadingStateChanged(loading, progress); 200 client_->LoadingStateChanged(loading, progress);
200 } 201 }
201 202
202 void WebViewImpl::TitleChanged(const mojo::String& title) { 203 void WebViewImpl::TitleChanged(const mojo::String& title) {
203 client_->TitleChanged(title); 204 client_->TitleChanged(title);
204 } 205 }
205 206
206 void WebViewImpl::NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) { 207 void WebViewImpl::NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) {
207 client_->TopLevelNavigateRequest(request.Pass()); 208 client_->TopLevelNavigateRequest(std::move(request));
208 } 209 }
209 210
210 void WebViewImpl::CanNavigateFrame(Frame* target, 211 void WebViewImpl::CanNavigateFrame(Frame* target,
211 mojo::URLRequestPtr request, 212 mojo::URLRequestPtr request,
212 const CanNavigateFrameCallback& callback) { 213 const CanNavigateFrameCallback& callback) {
213 FrameConnection::CreateConnectionForCanNavigateFrame( 214 FrameConnection::CreateConnectionForCanNavigateFrame(
214 app_, target, request.Pass(), callback); 215 app_, target, std::move(request), callback);
215 } 216 }
216 217
217 void WebViewImpl::DidStartNavigation(Frame* frame) {} 218 void WebViewImpl::DidStartNavigation(Frame* frame) {}
218 219
219 void WebViewImpl::DidCommitProvisionalLoad(Frame* frame) { 220 void WebViewImpl::DidCommitProvisionalLoad(Frame* frame) {
220 navigation_controller_.FrameDidCommitProvisionalLoad(frame); 221 navigation_controller_.FrameDidCommitProvisionalLoad(frame);
221 } 222 }
222 223
223 void WebViewImpl::DidNavigateLocally(Frame* source, 224 void WebViewImpl::DidNavigateLocally(Frame* source,
224 const GURL& url) { 225 const GURL& url) {
(...skipping 20 matching lines...) Expand all
245 find_controller_.OnFindInPageSelectionUpdated(request_id, frame, 246 find_controller_.OnFindInPageSelectionUpdated(request_id, frame,
246 active_match_ordinal); 247 active_match_ordinal);
247 } 248 }
248 249
249 //////////////////////////////////////////////////////////////////////////////// 250 ////////////////////////////////////////////////////////////////////////////////
250 // WebViewImpl, FrameDevToolsAgentDelegate implementation: 251 // WebViewImpl, FrameDevToolsAgentDelegate implementation:
251 252
252 void WebViewImpl::HandlePageNavigateRequest(const GURL& url) { 253 void WebViewImpl::HandlePageNavigateRequest(const GURL& url) {
253 mojo::URLRequestPtr request(mojo::URLRequest::New()); 254 mojo::URLRequestPtr request(mojo::URLRequest::New());
254 request->url = url.spec(); 255 request->url = url.spec();
255 client_->TopLevelNavigateRequest(request.Pass()); 256 client_->TopLevelNavigateRequest(std::move(request));
256 } 257 }
257 258
258 //////////////////////////////////////////////////////////////////////////////// 259 ////////////////////////////////////////////////////////////////////////////////
259 // WebViewImpl, NavigationControllerDelegate implementation: 260 // WebViewImpl, NavigationControllerDelegate implementation:
260 261
261 void WebViewImpl::OnNavigate(mojo::URLRequestPtr request) { 262 void WebViewImpl::OnNavigate(mojo::URLRequestPtr request) {
262 pending_load_.reset(new PendingWebViewLoad(this)); 263 pending_load_.reset(new PendingWebViewLoad(this));
263 pending_load_->Init(request.Pass()); 264 pending_load_->Init(std::move(request));
264 } 265 }
265 266
266 void WebViewImpl::OnDidNavigate() { 267 void WebViewImpl::OnDidNavigate() {
267 client_->BackForwardChanged(navigation_controller_.CanGoBack() 268 client_->BackForwardChanged(navigation_controller_.CanGoBack()
268 ? ButtonState::BUTTON_STATE_ENABLED 269 ? ButtonState::BUTTON_STATE_ENABLED
269 : ButtonState::BUTTON_STATE_DISABLED, 270 : ButtonState::BUTTON_STATE_DISABLED,
270 navigation_controller_.CanGoForward() 271 navigation_controller_.CanGoForward()
271 ? ButtonState::BUTTON_STATE_ENABLED 272 ? ButtonState::BUTTON_STATE_ENABLED
272 : ButtonState::BUTTON_STATE_DISABLED); 273 : ButtonState::BUTTON_STATE_DISABLED);
273 } 274 }
274 275
275 //////////////////////////////////////////////////////////////////////////////// 276 ////////////////////////////////////////////////////////////////////////////////
276 // WebViewImpl, FindControllerDelegate implementation: 277 // WebViewImpl, FindControllerDelegate implementation:
277 278
278 std::vector<Frame*> WebViewImpl::GetAllFrames() { 279 std::vector<Frame*> WebViewImpl::GetAllFrames() {
279 std::vector<Frame*> all_frames; 280 std::vector<Frame*> all_frames;
280 PreOrderDepthFirstTraverseTree(frame_tree_->root(), &all_frames); 281 PreOrderDepthFirstTraverseTree(frame_tree_->root(), &all_frames);
281 return all_frames; 282 return all_frames;
282 } 283 }
283 284
284 mojom::WebViewClient* WebViewImpl::GetWebViewClient() { 285 mojom::WebViewClient* WebViewImpl::GetWebViewClient() {
285 return client_.get(); 286 return client_.get();
286 } 287 }
287 288
288 } // namespace web_view 289 } // namespace web_view
OLDNEW
« no previous file with comments | « components/web_view/web_view_apptest.cc ('k') | components/webcrypto/algorithms/asymmetric_key_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698