OLD | NEW |
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 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "components/mus/public/cpp/scoped_window_ptr.h" | 12 #include "components/mus/public/cpp/scoped_window_ptr.h" |
13 #include "components/mus/public/cpp/window.h" | 13 #include "components/mus/public/cpp/window.h" |
14 #include "components/mus/public/cpp/window_tree_connection.h" | 14 #include "components/mus/public/cpp/window_tree_connection.h" |
15 #include "components/web_view/client_initiated_frame_connection.h" | 15 #include "components/web_view/client_initiated_frame_connection.h" |
16 #include "components/web_view/frame.h" | 16 #include "components/web_view/frame.h" |
17 #include "components/web_view/frame_connection.h" | 17 #include "components/web_view/frame_connection.h" |
18 #include "components/web_view/frame_devtools_agent.h" | 18 #include "components/web_view/frame_devtools_agent.h" |
19 #include "components/web_view/frame_tree.h" | 19 #include "components/web_view/frame_tree.h" |
20 #include "components/web_view/navigation_entry.h" | 20 #include "components/web_view/navigation_entry.h" |
21 #include "components/web_view/pending_web_view_load.h" | 21 #include "components/web_view/pending_web_view_load.h" |
22 #include "components/web_view/url_request_cloneable.h" | 22 #include "components/web_view/url_request_cloneable.h" |
23 #include "mojo/converters/geometry/geometry_type_converters.h" | 23 #include "mojo/converters/geometry/geometry_type_converters.h" |
24 #include "mojo/shell/public/cpp/application_impl.h" | 24 #include "mojo/shell/public/cpp/shell.h" |
25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
26 | 26 |
27 namespace web_view { | 27 namespace web_view { |
28 | 28 |
29 using web_view::mojom::ButtonState; | 29 using web_view::mojom::ButtonState; |
30 | 30 |
31 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
32 // WebViewImpl, public: | 32 // WebViewImpl, public: |
33 | 33 |
34 WebViewImpl::WebViewImpl(mojo::ApplicationImpl* app, | 34 WebViewImpl::WebViewImpl(mojo::Shell* shell, |
35 mojom::WebViewClientPtr client, | 35 mojom::WebViewClientPtr client, |
36 mojo::InterfaceRequest<mojom::WebView> request) | 36 mojo::InterfaceRequest<mojom::WebView> request) |
37 : app_(app), | 37 : shell_(shell), |
38 client_(std::move(client)), | 38 client_(std::move(client)), |
39 binding_(this, std::move(request)), | 39 binding_(this, std::move(request)), |
40 root_(nullptr), | 40 root_(nullptr), |
41 content_(nullptr), | 41 content_(nullptr), |
42 find_controller_(this), | 42 find_controller_(this), |
43 navigation_controller_(this) { | 43 navigation_controller_(this) { |
44 devtools_agent_.reset(new FrameDevToolsAgent(app_, this)); | 44 devtools_agent_.reset(new FrameDevToolsAgent(shell_, this)); |
45 OnDidNavigate(); | 45 OnDidNavigate(); |
46 } | 46 } |
47 | 47 |
48 WebViewImpl::~WebViewImpl() { | 48 WebViewImpl::~WebViewImpl() { |
49 if (content_) | 49 if (content_) |
50 content_->RemoveObserver(this); | 50 content_->RemoveObserver(this); |
51 if (root_) { | 51 if (root_) { |
52 root_->RemoveObserver(this); | 52 root_->RemoveObserver(this); |
53 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); | 53 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); |
54 } | 54 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 195 } |
196 | 196 |
197 void WebViewImpl::NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) { | 197 void WebViewImpl::NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) { |
198 client_->TopLevelNavigateRequest(std::move(request)); | 198 client_->TopLevelNavigateRequest(std::move(request)); |
199 } | 199 } |
200 | 200 |
201 void WebViewImpl::CanNavigateFrame(Frame* target, | 201 void WebViewImpl::CanNavigateFrame(Frame* target, |
202 mojo::URLRequestPtr request, | 202 mojo::URLRequestPtr request, |
203 const CanNavigateFrameCallback& callback) { | 203 const CanNavigateFrameCallback& callback) { |
204 FrameConnection::CreateConnectionForCanNavigateFrame( | 204 FrameConnection::CreateConnectionForCanNavigateFrame( |
205 app_, target, std::move(request), callback); | 205 shell_, target, std::move(request), callback); |
206 } | 206 } |
207 | 207 |
208 void WebViewImpl::DidStartNavigation(Frame* frame) {} | 208 void WebViewImpl::DidStartNavigation(Frame* frame) {} |
209 | 209 |
210 void WebViewImpl::DidCommitProvisionalLoad(Frame* frame) { | 210 void WebViewImpl::DidCommitProvisionalLoad(Frame* frame) { |
211 navigation_controller_.FrameDidCommitProvisionalLoad(frame); | 211 navigation_controller_.FrameDidCommitProvisionalLoad(frame); |
212 } | 212 } |
213 | 213 |
214 void WebViewImpl::DidNavigateLocally(Frame* source, | 214 void WebViewImpl::DidNavigateLocally(Frame* source, |
215 const GURL& url) { | 215 const GURL& url) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 std::vector<Frame*> all_frames; | 269 std::vector<Frame*> all_frames; |
270 PreOrderDepthFirstTraverseTree(frame_tree_->root(), &all_frames); | 270 PreOrderDepthFirstTraverseTree(frame_tree_->root(), &all_frames); |
271 return all_frames; | 271 return all_frames; |
272 } | 272 } |
273 | 273 |
274 mojom::WebViewClient* WebViewImpl::GetWebViewClient() { | 274 mojom::WebViewClient* WebViewImpl::GetWebViewClient() { |
275 return client_.get(); | 275 return client_.get(); |
276 } | 276 } |
277 | 277 |
278 } // namespace web_view | 278 } // namespace web_view |
OLD | NEW |