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

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

Issue 567803002: Hook WebMediaPlayerImpl up to Mojo's HTMLDocumentView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move factory ownership to HTMLViewer. Created 6 years, 3 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_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/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "mojo/public/cpp/application/connect.h" 12 #include "mojo/public/cpp/application/connect.h"
13 #include "mojo/public/cpp/application/service_provider_impl.h" 13 #include "mojo/public/cpp/application/service_provider_impl.h"
14 #include "mojo/public/cpp/system/data_pipe.h" 14 #include "mojo/public/cpp/system/data_pipe.h"
15 #include "mojo/public/interfaces/application/shell.mojom.h" 15 #include "mojo/public/interfaces/application/shell.mojom.h"
16 #include "mojo/services/html_viewer/blink_input_events_type_converters.h" 16 #include "mojo/services/html_viewer/blink_input_events_type_converters.h"
17 #include "mojo/services/html_viewer/blink_url_request_type_converters.h" 17 #include "mojo/services/html_viewer/blink_url_request_type_converters.h"
18 #include "mojo/services/html_viewer/webmediaplayer_factory.h"
18 #include "mojo/services/html_viewer/webstoragenamespace_impl.h" 19 #include "mojo/services/html_viewer/webstoragenamespace_impl.h"
19 #include "mojo/services/html_viewer/weburlloader_impl.h" 20 #include "mojo/services/html_viewer/weburlloader_impl.h"
20 #include "mojo/services/public/cpp/view_manager/view.h" 21 #include "mojo/services/public/cpp/view_manager/view.h"
21 #include "skia/ext/refptr.h" 22 #include "skia/ext/refptr.h"
22 #include "third_party/WebKit/public/platform/Platform.h" 23 #include "third_party/WebKit/public/platform/Platform.h"
23 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" 24 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h"
24 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 25 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
25 #include "third_party/WebKit/public/web/WebDocument.h" 26 #include "third_party/WebKit/public/web/WebDocument.h"
26 #include "third_party/WebKit/public/web/WebElement.h" 27 #include "third_party/WebKit/public/web/WebElement.h"
27 #include "third_party/WebKit/public/web/WebInputEvent.h" 28 #include "third_party/WebKit/public/web/WebInputEvent.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Otherwise we don't know if we're the right app to handle this request. Ask 78 // Otherwise we don't know if we're the right app to handle this request. Ask
78 // host to do the navigation for us. 79 // host to do the navigation for us.
79 return false; 80 return false;
80 } 81 }
81 82
82 } // namespace 83 } // namespace
83 84
84 HTMLDocumentView::HTMLDocumentView( 85 HTMLDocumentView::HTMLDocumentView(
85 URLResponsePtr response, 86 URLResponsePtr response,
86 InterfaceRequest<ServiceProvider> service_provider_request, 87 InterfaceRequest<ServiceProvider> service_provider_request,
87 Shell* shell) 88 Shell* shell,
89 WebMediaPlayerFactory* web_media_player_factory)
88 : shell_(shell), 90 : shell_(shell),
89 web_view_(NULL), 91 web_view_(NULL),
90 root_(NULL), 92 root_(NULL),
91 view_manager_client_factory_(shell, this), 93 view_manager_client_factory_(shell, this),
92 repaint_pending_(false), 94 repaint_pending_(false),
95 web_media_player_factory_(web_media_player_factory),
93 weak_factory_(this) { 96 weak_factory_(this) {
94 ServiceProviderImpl* exported_services = new ServiceProviderImpl(); 97 ServiceProviderImpl* exported_services = new ServiceProviderImpl();
95 exported_services->AddService(&view_manager_client_factory_); 98 exported_services->AddService(&view_manager_client_factory_);
96 BindToRequest(exported_services, &service_provider_request); 99 BindToRequest(exported_services, &service_provider_request);
97 Load(response.Pass()); 100 Load(response.Pass());
98 } 101 }
99 102
100 HTMLDocumentView::~HTMLDocumentView() { 103 HTMLDocumentView::~HTMLDocumentView() {
101 if (web_view_) 104 if (web_view_)
102 web_view_->close(); 105 web_view_->close();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 158
156 bool HTMLDocumentView::allowsBrokenNullLayerTreeView() const { 159 bool HTMLDocumentView::allowsBrokenNullLayerTreeView() const {
157 // TODO(darin): Switch to using compositor bindings. 160 // TODO(darin): Switch to using compositor bindings.
158 // 161 //
159 // NOTE: Note to Blink maintainers, feel free to break this code if it is the 162 // NOTE: Note to Blink maintainers, feel free to break this code if it is the
160 // last NOT using compositor bindings and you want to delete this code path. 163 // last NOT using compositor bindings and you want to delete this code path.
161 // 164 //
162 return true; 165 return true;
163 } 166 }
164 167
168 blink::WebMediaPlayer* HTMLDocumentView::createMediaPlayer(
169 blink::WebLocalFrame* frame,
170 const blink::WebURL& url,
171 blink::WebMediaPlayerClient* client) {
172 return web_media_player_factory_->CreateMediaPlayer(frame, url, client);
173 }
174
165 blink::WebFrame* HTMLDocumentView::createChildFrame( 175 blink::WebFrame* HTMLDocumentView::createChildFrame(
166 blink::WebLocalFrame* parent, 176 blink::WebLocalFrame* parent,
167 const blink::WebString& frameName) { 177 const blink::WebString& frameName) {
168 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(this); 178 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(this);
169 parent->appendChild(web_frame); 179 parent->appendChild(web_frame);
170 return web_frame; 180 return web_frame;
171 } 181 }
172 182
173 void HTMLDocumentView::frameDetached(blink::WebFrame* frame) { 183 void HTMLDocumentView::frameDetached(blink::WebFrame* frame) {
174 if (frame->parent()) 184 if (frame->parent())
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 255
246 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( 256 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster(
247 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); 257 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType)));
248 258
249 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); 259 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height));
250 260
251 root_->SetContents(canvas->getDevice()->accessBitmap(false)); 261 root_->SetContents(canvas->getDevice()->accessBitmap(false));
252 } 262 }
253 263
254 } // namespace mojo 264 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698