Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: mojo/services/html_viewer/html_document.cc

Issue 887873003: media: Add DefaultMediaPermission. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "media/blink/webencryptedmediaclient_impl.h" 15 #include "media/blink/webencryptedmediaclient_impl.h"
16 #include "media/cdm/default_cdm_factory.h" 16 #include "media/cdm/default_cdm_factory.h"
17 #include "media/filters/default_media_permission.h"
17 #include "mojo/services/html_viewer/blink_input_events_type_converters.h" 18 #include "mojo/services/html_viewer/blink_input_events_type_converters.h"
18 #include "mojo/services/html_viewer/blink_url_request_type_converters.h" 19 #include "mojo/services/html_viewer/blink_url_request_type_converters.h"
19 #include "mojo/services/html_viewer/weblayertreeview_impl.h" 20 #include "mojo/services/html_viewer/weblayertreeview_impl.h"
20 #include "mojo/services/html_viewer/webmediaplayer_factory.h" 21 #include "mojo/services/html_viewer/webmediaplayer_factory.h"
21 #include "mojo/services/html_viewer/webstoragenamespace_impl.h" 22 #include "mojo/services/html_viewer/webstoragenamespace_impl.h"
22 #include "mojo/services/html_viewer/weburlloader_impl.h" 23 #include "mojo/services/html_viewer/weburlloader_impl.h"
23 #include "skia/ext/refptr.h" 24 #include "skia/ext/refptr.h"
24 #include "third_party/WebKit/public/platform/Platform.h" 25 #include "third_party/WebKit/public/platform/Platform.h"
25 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" 26 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h"
26 #include "third_party/WebKit/public/platform/WebSize.h" 27 #include "third_party/WebKit/public/platform/WebSize.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 const blink::WebURL& url, 201 const blink::WebURL& url,
201 blink::WebMediaPlayerClient* client) { 202 blink::WebMediaPlayerClient* client) {
202 return createMediaPlayer(frame, url, client, nullptr); 203 return createMediaPlayer(frame, url, client, nullptr);
203 } 204 }
204 205
205 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( 206 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer(
206 blink::WebLocalFrame* frame, 207 blink::WebLocalFrame* frame,
207 const blink::WebURL& url, 208 const blink::WebURL& url,
208 blink::WebMediaPlayerClient* client, 209 blink::WebMediaPlayerClient* client,
209 blink::WebContentDecryptionModule* initial_cdm) { 210 blink::WebContentDecryptionModule* initial_cdm) {
210 return web_media_player_factory_->CreateMediaPlayer(frame, url, client, 211 if (!media_permission_)
211 initial_cdm, shell_); 212 media_permission_.reset(new media::DefaultMediaPermission(true));
213
214 return web_media_player_factory_->CreateMediaPlayer(
215 frame, url, client, media_permission_.get(), initial_cdm, shell_);
212 } 216 }
213 217
214 blink::WebFrame* HTMLDocument::createChildFrame( 218 blink::WebFrame* HTMLDocument::createChildFrame(
215 blink::WebLocalFrame* parent, 219 blink::WebLocalFrame* parent,
216 const blink::WebString& frameName, 220 const blink::WebString& frameName,
217 blink::WebSandboxFlags sandboxFlags) { 221 blink::WebSandboxFlags sandboxFlags) {
218 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(this); 222 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(this);
219 parent->appendChild(web_frame); 223 parent->appendChild(web_frame);
220 return web_frame; 224 return web_frame;
221 } 225 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 void HTMLDocument::didNavigateWithinPage( 267 void HTMLDocument::didNavigateWithinPage(
264 blink::WebLocalFrame* frame, 268 blink::WebLocalFrame* frame,
265 const blink::WebHistoryItem& history_item, 269 const blink::WebHistoryItem& history_item,
266 blink::WebHistoryCommitType commit_type) { 270 blink::WebHistoryCommitType commit_type) {
267 if (navigator_host_.get()) 271 if (navigator_host_.get())
268 navigator_host_->DidNavigateLocally(history_item.urlString().utf8()); 272 navigator_host_->DidNavigateLocally(history_item.urlString().utf8());
269 } 273 }
270 274
271 blink::WebEncryptedMediaClient* HTMLDocument::encryptedMediaClient() { 275 blink::WebEncryptedMediaClient* HTMLDocument::encryptedMediaClient() {
272 if (!web_encrypted_media_client_) { 276 if (!web_encrypted_media_client_) {
273 // TODO(xhwang): Hook up permission services and add a MediaPermission 277 if (!media_permission_)
274 // implementation for HTMLDocument. 278 media_permission_.reset(new media::DefaultMediaPermission(true));
275 web_encrypted_media_client_.reset(new media::WebEncryptedMediaClientImpl( 279 web_encrypted_media_client_.reset(new media::WebEncryptedMediaClientImpl(
276 make_scoped_ptr(new media::DefaultCdmFactory()), nullptr)); 280 make_scoped_ptr(new media::DefaultCdmFactory()),
281 media_permission_.get()));
277 } 282 }
278 return web_encrypted_media_client_.get(); 283 return web_encrypted_media_client_.get();
279 } 284 }
280 285
281 void HTMLDocument::OnViewBoundsChanged(View* view, 286 void HTMLDocument::OnViewBoundsChanged(View* view,
282 const Rect& old_bounds, 287 const Rect& old_bounds,
283 const Rect& new_bounds) { 288 const Rect& new_bounds) {
284 DCHECK_EQ(view, root_); 289 DCHECK_EQ(view, root_);
285 web_view_->resize( 290 web_view_->resize(
286 blink::WebSize(view->bounds().width, view->bounds().height)); 291 blink::WebSize(view->bounds().width, view->bounds().height));
287 } 292 }
288 293
289 void HTMLDocument::OnViewDestroyed(View* view) { 294 void HTMLDocument::OnViewDestroyed(View* view) {
290 DCHECK_EQ(view, root_); 295 DCHECK_EQ(view, root_);
291 root_ = nullptr; 296 root_ = nullptr;
292 } 297 }
293 298
294 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) { 299 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) {
295 scoped_ptr<blink::WebInputEvent> web_event = 300 scoped_ptr<blink::WebInputEvent> web_event =
296 event.To<scoped_ptr<blink::WebInputEvent>>(); 301 event.To<scoped_ptr<blink::WebInputEvent>>();
297 if (web_event) 302 if (web_event)
298 web_view_->handleInputEvent(*web_event); 303 web_view_->handleInputEvent(*web_event);
299 } 304 }
300 305
301 } // namespace html_viewer 306 } // namespace html_viewer
OLDNEW
« no previous file with comments | « mojo/services/html_viewer/html_document.h ('k') | mojo/services/html_viewer/webmediaplayer_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698