| 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 "mojo/services/html_viewer/html_document_view.h" | 5 #include "mojo/services/html_viewer/html_document_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "mojo/public/cpp/application/connect.h" | 13 #include "mojo/public/cpp/application/connect.h" |
| 14 #include "mojo/public/cpp/application/service_provider_impl.h" | 14 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 15 #include "mojo/public/cpp/system/data_pipe.h" | 15 #include "mojo/public/cpp/system/data_pipe.h" |
| 16 #include "mojo/public/interfaces/application/shell.mojom.h" | 16 #include "mojo/public/interfaces/application/shell.mojom.h" |
| 17 #include "mojo/services/html_viewer/blink_input_events_type_converters.h" | 17 #include "mojo/services/html_viewer/blink_input_events_type_converters.h" |
| 18 #include "mojo/services/html_viewer/blink_url_request_type_converters.h" | 18 #include "mojo/services/html_viewer/blink_url_request_type_converters.h" |
| 19 #include "mojo/services/html_viewer/weblayertreeview_impl.h" | 19 #include "mojo/services/html_viewer/weblayertreeview_impl.h" |
| 20 #include "mojo/services/html_viewer/webmediaplayer_factory.h" |
| 20 #include "mojo/services/html_viewer/webstoragenamespace_impl.h" | 21 #include "mojo/services/html_viewer/webstoragenamespace_impl.h" |
| 21 #include "mojo/services/html_viewer/weburlloader_impl.h" | 22 #include "mojo/services/html_viewer/weburlloader_impl.h" |
| 22 #include "mojo/services/public/cpp/view_manager/view.h" | 23 #include "mojo/services/public/cpp/view_manager/view.h" |
| 23 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" | 24 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" |
| 24 #include "skia/ext/refptr.h" | 25 #include "skia/ext/refptr.h" |
| 25 #include "third_party/WebKit/public/platform/Platform.h" | 26 #include "third_party/WebKit/public/platform/Platform.h" |
| 26 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" | 27 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" |
| 27 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 28 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 28 #include "third_party/WebKit/public/web/WebDocument.h" | 29 #include "third_party/WebKit/public/web/WebDocument.h" |
| 29 #include "third_party/WebKit/public/web/WebElement.h" | 30 #include "third_party/WebKit/public/web/WebElement.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // host to do the navigation for us. | 81 // host to do the navigation for us. |
| 81 return false; | 82 return false; |
| 82 } | 83 } |
| 83 | 84 |
| 84 } // namespace | 85 } // namespace |
| 85 | 86 |
| 86 HTMLDocumentView::HTMLDocumentView( | 87 HTMLDocumentView::HTMLDocumentView( |
| 87 URLResponsePtr response, | 88 URLResponsePtr response, |
| 88 InterfaceRequest<ServiceProvider> service_provider_request, | 89 InterfaceRequest<ServiceProvider> service_provider_request, |
| 89 Shell* shell, | 90 Shell* shell, |
| 90 scoped_refptr<base::MessageLoopProxy> compositor_thread) | 91 scoped_refptr<base::MessageLoopProxy> compositor_thread, |
| 92 WebMediaPlayerFactory* web_media_player_factory) |
| 91 : shell_(shell), | 93 : shell_(shell), |
| 92 web_view_(NULL), | 94 web_view_(NULL), |
| 93 root_(NULL), | 95 root_(NULL), |
| 94 view_manager_client_factory_(shell, this), | 96 view_manager_client_factory_(shell, this), |
| 95 compositor_thread_(compositor_thread), | 97 compositor_thread_(compositor_thread), |
| 98 web_media_player_factory_(web_media_player_factory), |
| 96 weak_factory_(this) { | 99 weak_factory_(this) { |
| 97 ServiceProviderImpl* exported_services = new ServiceProviderImpl(); | 100 ServiceProviderImpl* exported_services = new ServiceProviderImpl(); |
| 98 exported_services->AddService(&view_manager_client_factory_); | 101 exported_services->AddService(&view_manager_client_factory_); |
| 99 BindToRequest(exported_services, &service_provider_request); | 102 BindToRequest(exported_services, &service_provider_request); |
| 100 Load(response.Pass()); | 103 Load(response.Pass()); |
| 101 } | 104 } |
| 102 | 105 |
| 103 HTMLDocumentView::~HTMLDocumentView() { | 106 HTMLDocumentView::~HTMLDocumentView() { |
| 104 if (web_view_) | 107 if (web_view_) |
| 105 web_view_->close(); | 108 web_view_->close(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 InterfacePtr<Gpu> gpu_service; | 166 InterfacePtr<Gpu> gpu_service; |
| 164 ConnectToService(gpu_service_provider.get(), &gpu_service); | 167 ConnectToService(gpu_service_provider.get(), &gpu_service); |
| 165 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( | 168 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( |
| 166 compositor_thread_, surfaces_service.Pass(), gpu_service.Pass())); | 169 compositor_thread_, surfaces_service.Pass(), gpu_service.Pass())); |
| 167 } | 170 } |
| 168 | 171 |
| 169 blink::WebLayerTreeView* HTMLDocumentView::layerTreeView() { | 172 blink::WebLayerTreeView* HTMLDocumentView::layerTreeView() { |
| 170 return web_layer_tree_view_impl_.get(); | 173 return web_layer_tree_view_impl_.get(); |
| 171 } | 174 } |
| 172 | 175 |
| 176 blink::WebMediaPlayer* HTMLDocumentView::createMediaPlayer( |
| 177 blink::WebLocalFrame* frame, |
| 178 const blink::WebURL& url, |
| 179 blink::WebMediaPlayerClient* client) { |
| 180 return web_media_player_factory_->CreateMediaPlayer(frame, url, client); |
| 181 } |
| 182 |
| 173 blink::WebFrame* HTMLDocumentView::createChildFrame( | 183 blink::WebFrame* HTMLDocumentView::createChildFrame( |
| 174 blink::WebLocalFrame* parent, | 184 blink::WebLocalFrame* parent, |
| 175 const blink::WebString& frameName) { | 185 const blink::WebString& frameName) { |
| 176 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(this); | 186 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(this); |
| 177 parent->appendChild(web_frame); | 187 parent->appendChild(web_frame); |
| 178 return web_frame; | 188 return web_frame; |
| 179 } | 189 } |
| 180 | 190 |
| 181 void HTMLDocumentView::frameDetached(blink::WebFrame* frame) { | 191 void HTMLDocumentView::frameDetached(blink::WebFrame* frame) { |
| 182 if (frame->parent()) | 192 if (frame->parent()) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 243 } |
| 234 | 244 |
| 235 void HTMLDocumentView::OnViewInputEvent(View* view, const EventPtr& event) { | 245 void HTMLDocumentView::OnViewInputEvent(View* view, const EventPtr& event) { |
| 236 scoped_ptr<blink::WebInputEvent> web_event = | 246 scoped_ptr<blink::WebInputEvent> web_event = |
| 237 event.To<scoped_ptr<blink::WebInputEvent> >(); | 247 event.To<scoped_ptr<blink::WebInputEvent> >(); |
| 238 if (web_event) | 248 if (web_event) |
| 239 web_view_->handleInputEvent(*web_event); | 249 web_view_->handleInputEvent(*web_event); |
| 240 } | 250 } |
| 241 | 251 |
| 242 } // namespace mojo | 252 } // namespace mojo |
| OLD | NEW |