| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/html_viewer/html_document.h" | 5 #include "components/html_viewer/html_document.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } // namespace | 144 } // namespace |
| 145 | 145 |
| 146 HTMLDocument::HTMLDocument(mojo::ApplicationImpl* html_document_app, | 146 HTMLDocument::HTMLDocument(mojo::ApplicationImpl* html_document_app, |
| 147 mojo::ApplicationConnection* connection, | 147 mojo::ApplicationConnection* connection, |
| 148 URLResponsePtr response, | 148 URLResponsePtr response, |
| 149 Setup* setup) | 149 Setup* setup) |
| 150 : app_refcount_( | 150 : app_refcount_( |
| 151 html_document_app->app_lifetime_helper()->CreateAppRefCount()), | 151 html_document_app->app_lifetime_helper()->CreateAppRefCount()), |
| 152 html_document_app_(html_document_app), | 152 html_document_app_(html_document_app), |
| 153 response_(response.Pass()), | 153 response_(response.Pass()), |
| 154 navigator_host_(connection->GetServiceProvider()), |
| 154 web_view_(nullptr), | 155 web_view_(nullptr), |
| 155 root_(nullptr), | 156 root_(nullptr), |
| 156 view_manager_client_factory_(html_document_app->shell(), this), | 157 view_manager_client_factory_(html_document_app->shell(), this), |
| 157 setup_(setup), | 158 setup_(setup), |
| 158 frame_tree_manager_binding_(&frame_tree_manager_) { | 159 frame_tree_manager_binding_(&frame_tree_manager_) { |
| 159 embedder_exported_services_.AddService( | 160 connection->AddService( |
| 160 static_cast<mojo::InterfaceFactory<mandoline::FrameTreeClient>*>(this)); | 161 static_cast<mojo::InterfaceFactory<mandoline::FrameTreeClient>*>(this)); |
| 161 | |
| 162 connection->AddService( | 162 connection->AddService( |
| 163 static_cast<InterfaceFactory<mojo::AxProvider>*>(this)); | 163 static_cast<InterfaceFactory<mojo::AxProvider>*>(this)); |
| 164 connection->AddService(&view_manager_client_factory_); | 164 connection->AddService(&view_manager_client_factory_); |
| 165 | 165 |
| 166 if (setup_->did_init()) | 166 if (setup_->did_init()) |
| 167 Load(response_.Pass()); | 167 Load(response_.Pass()); |
| 168 } | 168 } |
| 169 | 169 |
| 170 HTMLDocument::~HTMLDocument() { | 170 HTMLDocument::~HTMLDocument() { |
| 171 STLDeleteElements(&ax_providers_); | 171 STLDeleteElements(&ax_providers_); |
| 172 STLDeleteElements(&ax_provider_requests_); | 172 STLDeleteElements(&ax_provider_requests_); |
| 173 | 173 |
| 174 if (web_view_) | 174 if (web_view_) |
| 175 web_view_->close(); | 175 web_view_->close(); |
| 176 if (root_) | 176 if (root_) |
| 177 root_->RemoveObserver(this); | 177 root_->RemoveObserver(this); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void HTMLDocument::OnEmbed( | 180 void HTMLDocument::OnEmbed(View* root) { |
| 181 View* root, | |
| 182 mojo::InterfaceRequest<mojo::ServiceProvider> services, | |
| 183 mojo::ServiceProviderPtr exposed_services) { | |
| 184 DCHECK(!setup_->is_headless()); | 181 DCHECK(!setup_->is_headless()); |
| 185 root_ = root; | 182 root_ = root; |
| 186 root_->AddObserver(this); | 183 root_->AddObserver(this); |
| 187 embedder_service_provider_ = exposed_services.Pass(); | |
| 188 navigator_host_.set_service_provider(embedder_service_provider_.get()); | |
| 189 | |
| 190 embedder_exported_services_.Bind(services.Pass()); | |
| 191 | 184 |
| 192 InitSetupAndLoadIfNecessary(); | 185 InitSetupAndLoadIfNecessary(); |
| 193 } | 186 } |
| 194 | 187 |
| 195 void HTMLDocument::OnViewManagerDestroyed(ViewManager* view_manager) { | 188 void HTMLDocument::OnViewManagerDestroyed(ViewManager* view_manager) { |
| 196 delete this; | 189 delete this; |
| 197 } | 190 } |
| 198 | 191 |
| 199 void HTMLDocument::Create(mojo::ApplicationConnection* connection, | 192 void HTMLDocument::Create(mojo::ApplicationConnection* connection, |
| 200 mojo::InterfaceRequest<AxProvider> request) { | 193 mojo::InterfaceRequest<AxProvider> request) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // Either it should, as it once did, or we should find another solution here. | 338 // Either it should, as it once did, or we should find another solution here. |
| 346 return blink::Platform::current()->cookieJar(); | 339 return blink::Platform::current()->cookieJar(); |
| 347 } | 340 } |
| 348 | 341 |
| 349 blink::WebNavigationPolicy HTMLDocument::decidePolicyForNavigation( | 342 blink::WebNavigationPolicy HTMLDocument::decidePolicyForNavigation( |
| 350 const NavigationPolicyInfo& info) { | 343 const NavigationPolicyInfo& info) { |
| 351 std::string frame_name = info.frame ? info.frame->assignedName().utf8() : ""; | 344 std::string frame_name = info.frame ? info.frame->assignedName().utf8() : ""; |
| 352 if (info.frame->parent() && EnableOOPIFs()) { | 345 if (info.frame->parent() && EnableOOPIFs()) { |
| 353 mojo::View* view = frame_to_view_[info.frame].view; | 346 mojo::View* view = frame_to_view_[info.frame].view; |
| 354 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest); | 347 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest); |
| 355 view->Embed(url_request.Pass(), nullptr, nullptr); | 348 view->EmbedAllowingReembed(url_request.Pass()); |
| 356 // TODO(sky): I tried swapping the frame types here, but that resulted in | 349 // TODO(sky): I tried swapping the frame types here, but that resulted in |
| 357 // the view never getting sized. Figure out why. | 350 // the view never getting sized. Figure out why. |
| 358 // TODO(sky): there are timing conditions here, and we should only do this | 351 // TODO(sky): there are timing conditions here, and we should only do this |
| 359 // once. | 352 // once. |
| 360 base::MessageLoop::current()->PostTask( | 353 base::MessageLoop::current()->PostTask( |
| 361 FROM_HERE, base::Bind(&HTMLDocument::ConvertLocalFrameToRemoteFrame, | 354 FROM_HERE, base::Bind(&HTMLDocument::ConvertLocalFrameToRemoteFrame, |
| 362 base::Unretained(this), info.frame)); | 355 base::Unretained(this), info.frame)); |
| 363 return blink::WebNavigationPolicyIgnore; | 356 return blink::WebNavigationPolicyIgnore; |
| 364 } | 357 } |
| 365 | 358 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 touch_handler_->OnTouchEvent(*event); | 435 touch_handler_->OnTouchEvent(*event); |
| 443 return; | 436 return; |
| 444 } | 437 } |
| 445 scoped_ptr<blink::WebInputEvent> web_event = | 438 scoped_ptr<blink::WebInputEvent> web_event = |
| 446 event.To<scoped_ptr<blink::WebInputEvent>>(); | 439 event.To<scoped_ptr<blink::WebInputEvent>>(); |
| 447 if (web_event) | 440 if (web_event) |
| 448 web_view_->handleInputEvent(*web_event); | 441 web_view_->handleInputEvent(*web_event); |
| 449 } | 442 } |
| 450 | 443 |
| 451 } // namespace html_viewer | 444 } // namespace html_viewer |
| OLD | NEW |