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

Side by Side Diff: mojo/services/html_viewer/html_viewer.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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "mojo/public/c/system/main.h" 6 #include "mojo/public/c/system/main.h"
7 #include "mojo/public/cpp/application/application_connection.h" 7 #include "mojo/public/cpp/application/application_connection.h"
8 #include "mojo/public/cpp/application/application_delegate.h" 8 #include "mojo/public/cpp/application/application_delegate.h"
9 #include "mojo/public/cpp/application/application_impl.h" 9 #include "mojo/public/cpp/application/application_impl.h"
10 #include "mojo/public/cpp/application/application_runner_chromium.h" 10 #include "mojo/public/cpp/application/application_runner_chromium.h"
11 #include "mojo/public/cpp/application/interface_factory_impl.h" 11 #include "mojo/public/cpp/application/interface_factory_impl.h"
12 #include "mojo/services/html_viewer/blink_platform_impl.h" 12 #include "mojo/services/html_viewer/blink_platform_impl.h"
13 #include "mojo/services/html_viewer/html_document_view.h" 13 #include "mojo/services/html_viewer/html_document_view.h"
14 #include "mojo/services/html_viewer/webmediaplayer_factory.h"
14 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom. h" 15 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom. h"
15 #include "third_party/WebKit/public/web/WebKit.h" 16 #include "third_party/WebKit/public/web/WebKit.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 19
19 class HTMLViewer; 20 class HTMLViewer;
20 21
21 class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { 22 class ContentHandlerImpl : public InterfaceImpl<ContentHandler> {
22 public: 23 public:
23 explicit ContentHandlerImpl(Shell* shell) : shell_(shell) {} 24 explicit ContentHandlerImpl(HTMLViewer* html_viewer)
25 : html_viewer_(html_viewer) {
26 }
24 virtual ~ContentHandlerImpl() {} 27 virtual ~ContentHandlerImpl() {}
25 28
26 private: 29 private:
27 // Overridden from ContentHandler: 30 // Overridden from ContentHandler:
28 virtual void OnConnect( 31 virtual void OnConnect(
29 const mojo::String& url, 32 const mojo::String& url,
30 URLResponsePtr response, 33 URLResponsePtr response,
31 InterfaceRequest<ServiceProvider> service_provider_request) OVERRIDE { 34 InterfaceRequest<ServiceProvider> service_provider_request) OVERRIDE;
32 new HTMLDocumentView(
33 response.Pass(), service_provider_request.Pass(), shell_);
34 }
35 35
36 Shell* shell_; 36 HTMLViewer* html_viewer_;
37 37
38 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); 38 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl);
39 }; 39 };
40 40
41 class HTMLViewer : public ApplicationDelegate { 41 class HTMLViewer : public ApplicationDelegate {
42 public: 42 public:
43 HTMLViewer() {} 43 HTMLViewer() {}
44 44
45 virtual ~HTMLViewer() { blink::shutdown(); } 45 virtual ~HTMLViewer() { blink::shutdown(); }
46 46
47 WebMediaPlayerFactory* web_media_player_factory() const {
48 return web_media_player_factory_.get();
49 }
50
51 Shell* shell() const { return app_->shell(); }
52
47 private: 53 private:
48 // Overridden from ApplicationDelegate: 54 // Overridden from ApplicationDelegate:
49 virtual void Initialize(ApplicationImpl* app) OVERRIDE { 55 virtual void Initialize(ApplicationImpl* app) OVERRIDE {
56 app_ = app;
57 web_media_player_factory_.reset(new WebMediaPlayerFactory());
50 content_handler_factory_.reset( 58 content_handler_factory_.reset(
51 new InterfaceFactoryImplWithContext<ContentHandlerImpl, Shell>( 59 new InterfaceFactoryImplWithContext<ContentHandlerImpl, HTMLViewer>(
52 app->shell())); 60 this));
53 blink_platform_impl_.reset(new BlinkPlatformImpl(app)); 61 blink_platform_impl_.reset(new BlinkPlatformImpl(app));
54 blink::initialize(blink_platform_impl_.get()); 62 blink::initialize(blink_platform_impl_.get());
55 } 63 }
56 64
57 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 65 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
58 OVERRIDE { 66 OVERRIDE {
59 connection->AddService(content_handler_factory_.get()); 67 connection->AddService(content_handler_factory_.get());
60 return true; 68 return true;
61 } 69 }
62 70
71 ApplicationImpl* app_;
63 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; 72 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_;
64 scoped_ptr<InterfaceFactoryImplWithContext<ContentHandlerImpl, Shell> > 73 scoped_ptr<WebMediaPlayerFactory> web_media_player_factory_;
74 scoped_ptr<InterfaceFactoryImplWithContext<ContentHandlerImpl, HTMLViewer> >
65 content_handler_factory_; 75 content_handler_factory_;
66 76
67 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); 77 DISALLOW_COPY_AND_ASSIGN(HTMLViewer);
68 }; 78 };
69 79
80 void ContentHandlerImpl::OnConnect(
81 const mojo::String& url,
82 URLResponsePtr response,
83 InterfaceRequest<ServiceProvider> service_provider_request) {
84 new HTMLDocumentView(
85 response.Pass(),
86 service_provider_request.Pass(),
87 html_viewer_->shell(),
88 html_viewer_->web_media_player_factory());
89 }
90
70 } // namespace mojo 91 } // namespace mojo
71 92
72 MojoResult MojoMain(MojoHandle shell_handle) { 93 MojoResult MojoMain(MojoHandle shell_handle) {
73 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer); 94 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer);
74 return runner.Run(shell_handle); 95 return runner.Run(shell_handle);
75 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698