| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "components/devtools_service/public/cpp/switches.h" | 8 #include "components/devtools_service/public/cpp/switches.h" |
| 9 #include "components/mus/public/cpp/scoped_view_ptr.h" | 9 #include "components/mus/public/cpp/scoped_view_ptr.h" |
| 10 #include "components/mus/public/cpp/view.h" | 10 #include "components/mus/public/cpp/view.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 WebViewImpl::~WebViewImpl() { | 53 WebViewImpl::~WebViewImpl() { |
| 54 if (content_) | 54 if (content_) |
| 55 content_->RemoveObserver(this); | 55 content_->RemoveObserver(this); |
| 56 if (root_) { | 56 if (root_) { |
| 57 root_->RemoveObserver(this); | 57 root_->RemoveObserver(this); |
| 58 mus::ScopedViewPtr::DeleteViewOrViewManager(root_); | 58 mus::ScopedViewPtr::DeleteViewOrViewManager(root_); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 void WebViewImpl::OnLoad() { | 62 void WebViewImpl::OnLoad(const std::string& pending_url) { |
| 63 client_->TopLevelNavigationStarted(pending_url); |
| 63 scoped_ptr<PendingWebViewLoad> pending_load(pending_load_.Pass()); | 64 scoped_ptr<PendingWebViewLoad> pending_load(pending_load_.Pass()); |
| 64 scoped_ptr<FrameConnection> frame_connection( | 65 scoped_ptr<FrameConnection> frame_connection( |
| 65 pending_load->frame_connection()); | 66 pending_load->frame_connection()); |
| 66 mojo::ViewTreeClientPtr view_tree_client = | 67 mojo::ViewTreeClientPtr view_tree_client = |
| 67 frame_connection->GetViewTreeClient(); | 68 frame_connection->GetViewTreeClient(); |
| 68 | 69 |
| 69 Frame::ClientPropertyMap client_properties; | 70 Frame::ClientPropertyMap client_properties; |
| 70 if (devtools_agent_) { | 71 if (devtools_agent_) { |
| 71 devtools_service::DevToolsAgentPtr forward_agent; | 72 devtools_service::DevToolsAgentPtr forward_agent; |
| 72 frame_connection->application_connection()->ConnectToService( | 73 frame_connection->application_connection()->ConnectToService( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 root->AddObserver(this); | 116 root->AddObserver(this); |
| 116 root_ = root; | 117 root_ = root; |
| 117 content_ = root->connection()->CreateView(); | 118 content_ = root->connection()->CreateView(); |
| 118 content_->SetBounds(*mojo::Rect::From(gfx::Rect(0, 0, root->bounds().width, | 119 content_->SetBounds(*mojo::Rect::From(gfx::Rect(0, 0, root->bounds().width, |
| 119 root->bounds().height))); | 120 root->bounds().height))); |
| 120 root->AddChild(content_); | 121 root->AddChild(content_); |
| 121 content_->SetVisible(true); | 122 content_->SetVisible(true); |
| 122 content_->AddObserver(this); | 123 content_->AddObserver(this); |
| 123 | 124 |
| 124 if (pending_load_ && pending_load_->is_content_handler_id_valid()) | 125 if (pending_load_ && pending_load_->is_content_handler_id_valid()) |
| 125 OnLoad(); | 126 OnLoad(pending_load_->pending_url()); |
| 126 } | 127 } |
| 127 | 128 |
| 128 void WebViewImpl::OnConnectionLost(mus::ViewTreeConnection* connection) { | 129 void WebViewImpl::OnConnectionLost(mus::ViewTreeConnection* connection) { |
| 129 root_ = nullptr; | 130 root_ = nullptr; |
| 130 } | 131 } |
| 131 | 132 |
| 132 //////////////////////////////////////////////////////////////////////////////// | 133 //////////////////////////////////////////////////////////////////////////////// |
| 133 // WebViewImpl, mus::ViewObserver implementation: | 134 // WebViewImpl, mus::ViewObserver implementation: |
| 134 | 135 |
| 135 void WebViewImpl::OnViewBoundsChanged(mus::View* view, | 136 void WebViewImpl::OnViewBoundsChanged(mus::View* view, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 169 |
| 169 void WebViewImpl::LoadingStateChanged(bool loading, double progress) { | 170 void WebViewImpl::LoadingStateChanged(bool loading, double progress) { |
| 170 client_->LoadingStateChanged(loading, progress); | 171 client_->LoadingStateChanged(loading, progress); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void WebViewImpl::TitleChanged(const mojo::String& title) { | 174 void WebViewImpl::TitleChanged(const mojo::String& title) { |
| 174 client_->TitleChanged(title); | 175 client_->TitleChanged(title); |
| 175 } | 176 } |
| 176 | 177 |
| 177 void WebViewImpl::NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) { | 178 void WebViewImpl::NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) { |
| 178 client_->TopLevelNavigate(request.Pass()); | 179 client_->TopLevelNavigateRequest(request.Pass()); |
| 179 } | 180 } |
| 180 | 181 |
| 181 void WebViewImpl::CanNavigateFrame(Frame* target, | 182 void WebViewImpl::CanNavigateFrame(Frame* target, |
| 182 mojo::URLRequestPtr request, | 183 mojo::URLRequestPtr request, |
| 183 const CanNavigateFrameCallback& callback) { | 184 const CanNavigateFrameCallback& callback) { |
| 184 FrameConnection::CreateConnectionForCanNavigateFrame( | 185 FrameConnection::CreateConnectionForCanNavigateFrame( |
| 185 app_, target, request.Pass(), callback); | 186 app_, target, request.Pass(), callback); |
| 186 } | 187 } |
| 187 | 188 |
| 188 void WebViewImpl::DidStartNavigation(Frame* frame) {} | 189 void WebViewImpl::DidStartNavigation(Frame* frame) {} |
| 189 | 190 |
| 190 void WebViewImpl::DidCommitProvisionalLoad(Frame* frame) { | 191 void WebViewImpl::DidCommitProvisionalLoad(Frame* frame) { |
| 191 navigation_controller_.FrameDidCommitProvisionalLoad(frame); | 192 navigation_controller_.FrameDidCommitProvisionalLoad(frame); |
| 192 } | 193 } |
| 193 | 194 |
| 194 //////////////////////////////////////////////////////////////////////////////// | 195 //////////////////////////////////////////////////////////////////////////////// |
| 195 // WebViewImpl, FrameDevToolsAgentDelegate implementation: | 196 // WebViewImpl, FrameDevToolsAgentDelegate implementation: |
| 196 | 197 |
| 197 void WebViewImpl::HandlePageNavigateRequest(const GURL& url) { | 198 void WebViewImpl::HandlePageNavigateRequest(const GURL& url) { |
| 198 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 199 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 199 request->url = url.spec(); | 200 request->url = url.spec(); |
| 200 client_->TopLevelNavigate(request.Pass()); | 201 client_->TopLevelNavigateRequest(request.Pass()); |
| 201 } | 202 } |
| 202 | 203 |
| 203 //////////////////////////////////////////////////////////////////////////////// | 204 //////////////////////////////////////////////////////////////////////////////// |
| 204 // WebViewImpl, NavigationControllerDelegate implementation: | 205 // WebViewImpl, NavigationControllerDelegate implementation: |
| 205 | 206 |
| 206 void WebViewImpl::OnNavigate(mojo::URLRequestPtr request) { | 207 void WebViewImpl::OnNavigate(mojo::URLRequestPtr request) { |
| 207 pending_load_.reset(new PendingWebViewLoad(this)); | 208 pending_load_.reset(new PendingWebViewLoad(this)); |
| 208 pending_load_->Init(request.Pass()); | 209 pending_load_->Init(request.Pass()); |
| 209 } | 210 } |
| 210 | 211 |
| 211 void WebViewImpl::OnDidNavigate() { | 212 void WebViewImpl::OnDidNavigate() { |
| 212 client_->BackForwardChanged(navigation_controller_.CanGoBack() | 213 client_->BackForwardChanged(navigation_controller_.CanGoBack() |
| 213 ? ButtonState::BUTTON_STATE_ENABLED | 214 ? ButtonState::BUTTON_STATE_ENABLED |
| 214 : ButtonState::BUTTON_STATE_DISABLED, | 215 : ButtonState::BUTTON_STATE_DISABLED, |
| 215 navigation_controller_.CanGoForward() | 216 navigation_controller_.CanGoForward() |
| 216 ? ButtonState::BUTTON_STATE_ENABLED | 217 ? ButtonState::BUTTON_STATE_ENABLED |
| 217 : ButtonState::BUTTON_STATE_DISABLED); | 218 : ButtonState::BUTTON_STATE_DISABLED); |
| 218 } | 219 } |
| 219 | 220 |
| 220 } // namespace web_view | 221 } // namespace web_view |
| OLD | NEW |