| 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.h" | 5 #include "mojo/services/html_viewer/html_document.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/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 11 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "media/blink/webencryptedmediaclient_impl.h" |
| 16 #include "media/cdm/default_cdm_factory.h" |
| 14 #include "mojo/public/cpp/application/connect.h" | 17 #include "mojo/public/cpp/application/connect.h" |
| 15 #include "mojo/public/cpp/system/data_pipe.h" | 18 #include "mojo/public/cpp/system/data_pipe.h" |
| 16 #include "mojo/public/interfaces/application/shell.mojom.h" | 19 #include "mojo/public/interfaces/application/shell.mojom.h" |
| 17 #include "mojo/services/html_viewer/blink_input_events_type_converters.h" | 20 #include "mojo/services/html_viewer/blink_input_events_type_converters.h" |
| 18 #include "mojo/services/html_viewer/blink_url_request_type_converters.h" | 21 #include "mojo/services/html_viewer/blink_url_request_type_converters.h" |
| 19 #include "mojo/services/html_viewer/weblayertreeview_impl.h" | 22 #include "mojo/services/html_viewer/weblayertreeview_impl.h" |
| 20 #include "mojo/services/html_viewer/webmediaplayer_factory.h" | 23 #include "mojo/services/html_viewer/webmediaplayer_factory.h" |
| 21 #include "mojo/services/html_viewer/webstoragenamespace_impl.h" | 24 #include "mojo/services/html_viewer/webstoragenamespace_impl.h" |
| 22 #include "mojo/services/html_viewer/weburlloader_impl.h" | 25 #include "mojo/services/html_viewer/weburlloader_impl.h" |
| 23 #include "mojo/services/surfaces/public/interfaces/surfaces_service.mojom.h" | 26 #include "mojo/services/surfaces/public/interfaces/surfaces_service.mojom.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } // namespace | 96 } // namespace |
| 94 | 97 |
| 95 HTMLDocument::HTMLDocument( | 98 HTMLDocument::HTMLDocument( |
| 96 mojo::ServiceProviderPtr provider, | 99 mojo::ServiceProviderPtr provider, |
| 97 URLResponsePtr response, | 100 URLResponsePtr response, |
| 98 mojo::Shell* shell, | 101 mojo::Shell* shell, |
| 99 scoped_refptr<base::MessageLoopProxy> compositor_thread, | 102 scoped_refptr<base::MessageLoopProxy> compositor_thread, |
| 100 WebMediaPlayerFactory* web_media_player_factory) | 103 WebMediaPlayerFactory* web_media_player_factory) |
| 101 : response_(response.Pass()), | 104 : response_(response.Pass()), |
| 102 shell_(shell), | 105 shell_(shell), |
| 103 web_view_(NULL), | 106 web_view_(nullptr), |
| 104 root_(NULL), | 107 root_(nullptr), |
| 105 view_manager_client_factory_(shell_, this), | 108 view_manager_client_factory_(shell_, this), |
| 106 compositor_thread_(compositor_thread), | 109 compositor_thread_(compositor_thread), |
| 107 web_media_player_factory_(web_media_player_factory) { | 110 web_media_player_factory_(web_media_player_factory), |
| 111 web_encrypted_media_client_(nullptr) { |
| 108 exported_services_.AddService(this); | 112 exported_services_.AddService(this); |
| 109 exported_services_.AddService(&view_manager_client_factory_); | 113 exported_services_.AddService(&view_manager_client_factory_); |
| 110 WeakBindToPipe(&exported_services_, provider.PassMessagePipe()); | 114 WeakBindToPipe(&exported_services_, provider.PassMessagePipe()); |
| 111 Load(response_.Pass()); | 115 Load(response_.Pass()); |
| 112 } | 116 } |
| 113 | 117 |
| 114 HTMLDocument::~HTMLDocument() { | 118 HTMLDocument::~HTMLDocument() { |
| 115 STLDeleteElements(&ax_provider_impls_); | 119 STLDeleteElements(&ax_provider_impls_); |
| 116 | 120 |
| 117 if (web_view_) | 121 if (web_view_) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 193 } |
| 190 | 194 |
| 191 blink::WebLayerTreeView* HTMLDocument::layerTreeView() { | 195 blink::WebLayerTreeView* HTMLDocument::layerTreeView() { |
| 192 return web_layer_tree_view_impl_.get(); | 196 return web_layer_tree_view_impl_.get(); |
| 193 } | 197 } |
| 194 | 198 |
| 195 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( | 199 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( |
| 196 blink::WebLocalFrame* frame, | 200 blink::WebLocalFrame* frame, |
| 197 const blink::WebURL& url, | 201 const blink::WebURL& url, |
| 198 blink::WebMediaPlayerClient* client) { | 202 blink::WebMediaPlayerClient* client) { |
| 199 return web_media_player_factory_->CreateMediaPlayer(frame, url, client, | 203 return createMediaPlayer(frame, url, client, nullptr); |
| 200 shell_); | |
| 201 } | 204 } |
| 202 | 205 |
| 203 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( | 206 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( |
| 204 blink::WebLocalFrame* frame, | 207 blink::WebLocalFrame* frame, |
| 205 const blink::WebURL& url, | 208 const blink::WebURL& url, |
| 206 blink::WebMediaPlayerClient* client, | 209 blink::WebMediaPlayerClient* client, |
| 207 blink::WebContentDecryptionModule* initial_cdm) { | 210 blink::WebContentDecryptionModule* initial_cdm) { |
| 208 return createMediaPlayer(frame, url, client); | 211 return web_media_player_factory_->CreateMediaPlayer(frame, url, client, |
| 212 initial_cdm, shell_); |
| 209 } | 213 } |
| 210 | 214 |
| 211 blink::WebFrame* HTMLDocument::createChildFrame( | 215 blink::WebFrame* HTMLDocument::createChildFrame( |
| 212 blink::WebLocalFrame* parent, | 216 blink::WebLocalFrame* parent, |
| 213 const blink::WebString& frameName) { | 217 const blink::WebString& frameName) { |
| 214 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(this); | 218 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(this); |
| 215 parent->appendChild(web_frame); | 219 parent->appendChild(web_frame); |
| 216 return web_frame; | 220 return web_frame; |
| 217 } | 221 } |
| 218 | 222 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 const blink::WebString& stack_trace) { | 258 const blink::WebString& stack_trace) { |
| 255 } | 259 } |
| 256 | 260 |
| 257 void HTMLDocument::didNavigateWithinPage( | 261 void HTMLDocument::didNavigateWithinPage( |
| 258 blink::WebLocalFrame* frame, | 262 blink::WebLocalFrame* frame, |
| 259 const blink::WebHistoryItem& history_item, | 263 const blink::WebHistoryItem& history_item, |
| 260 blink::WebHistoryCommitType commit_type) { | 264 blink::WebHistoryCommitType commit_type) { |
| 261 navigator_host_->DidNavigateLocally(history_item.urlString().utf8()); | 265 navigator_host_->DidNavigateLocally(history_item.urlString().utf8()); |
| 262 } | 266 } |
| 263 | 267 |
| 268 blink::WebEncryptedMediaClient* HTMLDocument::encryptedMediaClient() { |
| 269 if (!web_encrypted_media_client_) { |
| 270 web_encrypted_media_client_ = new media::WebEncryptedMediaClientImpl( |
| 271 make_scoped_ptr(new media::DefaultCdmFactory())); |
| 272 } |
| 273 return web_encrypted_media_client_; |
| 274 } |
| 275 |
| 264 void HTMLDocument::OnViewBoundsChanged(View* view, | 276 void HTMLDocument::OnViewBoundsChanged(View* view, |
| 265 const Rect& old_bounds, | 277 const Rect& old_bounds, |
| 266 const Rect& new_bounds) { | 278 const Rect& new_bounds) { |
| 267 DCHECK_EQ(view, root_); | 279 DCHECK_EQ(view, root_); |
| 268 web_view_->resize( | 280 web_view_->resize( |
| 269 blink::WebSize(view->bounds().width, view->bounds().height)); | 281 blink::WebSize(view->bounds().width, view->bounds().height)); |
| 270 } | 282 } |
| 271 | 283 |
| 272 void HTMLDocument::OnViewDestroyed(View* view) { | 284 void HTMLDocument::OnViewDestroyed(View* view) { |
| 273 DCHECK_EQ(view, root_); | 285 DCHECK_EQ(view, root_); |
| 274 root_ = nullptr; | 286 root_ = nullptr; |
| 275 } | 287 } |
| 276 | 288 |
| 277 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) { | 289 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) { |
| 278 scoped_ptr<blink::WebInputEvent> web_event = | 290 scoped_ptr<blink::WebInputEvent> web_event = |
| 279 event.To<scoped_ptr<blink::WebInputEvent>>(); | 291 event.To<scoped_ptr<blink::WebInputEvent>>(); |
| 280 if (web_event) | 292 if (web_event) |
| 281 web_view_->handleInputEvent(*web_event); | 293 web_view_->handleInputEvent(*web_event); |
| 282 } | 294 } |
| 283 | 295 |
| 284 } // namespace html_viewer | 296 } // namespace html_viewer |
| OLD | NEW |