| 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 "mandoline/tab/web_view_impl.h" | 5 #include "mandoline/tab/web_view_impl.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "components/devtools_service/public/cpp/switches.h" | 9 #include "components/devtools_service/public/cpp/switches.h" |
| 10 #include "components/view_manager/public/cpp/view.h" | 10 #include "components/view_manager/public/cpp/view.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 //////////////////////////////////////////////////////////////////////////////// | 51 //////////////////////////////////////////////////////////////////////////////// |
| 52 // WebViewImpl, WebView implementation: | 52 // WebViewImpl, WebView implementation: |
| 53 | 53 |
| 54 void WebViewImpl::LoadRequest(mojo::URLRequestPtr request) { | 54 void WebViewImpl::LoadRequest(mojo::URLRequestPtr request) { |
| 55 if (!content_) { | 55 if (!content_) { |
| 56 // We haven't been embedded yet, store the request for when we are. | 56 // We haven't been embedded yet, store the request for when we are. |
| 57 pending_request_ = request.Pass(); | 57 pending_request_ = request.Pass(); |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); | 60 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); |
| 61 mojo::ViewManagerClientPtr view_manager_client; | 61 mojo::ViewTreeClientPtr view_tree_client; |
| 62 frame_connection->Init(app_, request.Pass(), &view_manager_client); | 62 frame_connection->Init(app_, request.Pass(), &view_tree_client); |
| 63 | 63 |
| 64 Frame::ClientPropertyMap client_properties; | 64 Frame::ClientPropertyMap client_properties; |
| 65 if (devtools_agent_) { | 65 if (devtools_agent_) { |
| 66 devtools_service::DevToolsAgentPtr forward_agent; | 66 devtools_service::DevToolsAgentPtr forward_agent; |
| 67 frame_connection->application_connection()->ConnectToService( | 67 frame_connection->application_connection()->ConnectToService( |
| 68 &forward_agent); | 68 &forward_agent); |
| 69 devtools_agent_->AttachFrame(forward_agent.Pass(), &client_properties); | 69 devtools_agent_->AttachFrame(forward_agent.Pass(), &client_properties); |
| 70 } | 70 } |
| 71 | 71 |
| 72 FrameTreeClient* frame_tree_client = frame_connection->frame_tree_client(); | 72 FrameTreeClient* frame_tree_client = frame_connection->frame_tree_client(); |
| 73 frame_tree_.reset(new FrameTree(content_, this, frame_tree_client, | 73 frame_tree_.reset(new FrameTree(content_, this, frame_tree_client, |
| 74 frame_connection.Pass(), client_properties)); | 74 frame_connection.Pass(), client_properties)); |
| 75 content_->Embed(view_manager_client.Pass()); | 75 content_->Embed(view_tree_client.Pass()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void WebViewImpl::GetViewManagerClient( | 78 void WebViewImpl::GetViewTreeClient( |
| 79 mojo::InterfaceRequest<mojo::ViewManagerClient> view_manager_client) { | 79 mojo::InterfaceRequest<mojo::ViewTreeClient> view_tree_client) { |
| 80 mojo::ViewManager::Create(nullptr, view_manager_client.Pass()); | 80 mojo::ViewManager::Create(nullptr, view_tree_client.Pass()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 //////////////////////////////////////////////////////////////////////////////// | 83 //////////////////////////////////////////////////////////////////////////////// |
| 84 // WebViewImpl, mojo::ViewManagerDelegate implementation: | 84 // WebViewImpl, mojo::ViewManagerDelegate implementation: |
| 85 | 85 |
| 86 void WebViewImpl::OnEmbed(mojo::View* root) { | 86 void WebViewImpl::OnEmbed(mojo::View* root) { |
| 87 root->view_manager()->SetEmbedRoot(); | 87 root->view_manager()->SetEmbedRoot(); |
| 88 root->AddObserver(this); | 88 root->AddObserver(this); |
| 89 content_ = root->view_manager()->CreateView(); | 89 content_ = root->view_manager()->CreateView(); |
| 90 content_->SetBounds(*mojo::Rect::From(gfx::Rect(0, 0, root->bounds().width, | 90 content_->SetBounds(*mojo::Rect::From(gfx::Rect(0, 0, root->bounds().width, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 void WebViewImpl::NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) { | 140 void WebViewImpl::NavigateTopLevel(Frame* source, mojo::URLRequestPtr request) { |
| 141 client_->TopLevelNavigate(request.Pass()); | 141 client_->TopLevelNavigate(request.Pass()); |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool WebViewImpl::CanNavigateFrame( | 144 bool WebViewImpl::CanNavigateFrame( |
| 145 Frame* target, | 145 Frame* target, |
| 146 mojo::URLRequestPtr request, | 146 mojo::URLRequestPtr request, |
| 147 FrameTreeClient** frame_tree_client, | 147 FrameTreeClient** frame_tree_client, |
| 148 scoped_ptr<FrameUserData>* frame_user_data, | 148 scoped_ptr<FrameUserData>* frame_user_data, |
| 149 mojo::ViewManagerClientPtr* view_manager_client) { | 149 mojo::ViewTreeClientPtr* view_tree_client) { |
| 150 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); | 150 scoped_ptr<FrameConnection> frame_connection(new FrameConnection); |
| 151 frame_connection->Init(app_, request.Pass(), view_manager_client); | 151 frame_connection->Init(app_, request.Pass(), view_tree_client); |
| 152 *frame_tree_client = frame_connection->frame_tree_client(); | 152 *frame_tree_client = frame_connection->frame_tree_client(); |
| 153 *frame_user_data = frame_connection.Pass(); | 153 *frame_user_data = frame_connection.Pass(); |
| 154 return true; | 154 return true; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void WebViewImpl::DidStartNavigation(Frame* frame) {} | 157 void WebViewImpl::DidStartNavigation(Frame* frame) {} |
| 158 | 158 |
| 159 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
| 160 // WebViewImpl, FrameDevToolsAgentDelegate implementation: | 160 // WebViewImpl, FrameDevToolsAgentDelegate implementation: |
| 161 | 161 |
| 162 void WebViewImpl::HandlePageNavigateRequest(const GURL& url) { | 162 void WebViewImpl::HandlePageNavigateRequest(const GURL& url) { |
| 163 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 163 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 164 request->url = url.spec(); | 164 request->url = url.spec(); |
| 165 client_->TopLevelNavigate(request.Pass()); | 165 client_->TopLevelNavigate(request.Pass()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace web_view | 168 } // namespace web_view |
| OLD | NEW |