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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/threading/thread.h" | 7 #include "base/threading/thread.h" |
8 #include "mojo/application/application_runner_chromium.h" | 8 #include "mojo/application/application_runner_chromium.h" |
9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
10 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // --args-for='mojo://html_viewer --enable-mojo-media-renderer' | 30 // --args-for='mojo://html_viewer --enable-mojo-media-renderer' |
31 | 31 |
32 // Enable mojo::MediaRenderer in media pipeline instead of using the internal | 32 // Enable mojo::MediaRenderer in media pipeline instead of using the internal |
33 // media::Renderer implementation. | 33 // media::Renderer implementation. |
34 const char kEnableMojoMediaRenderer[] = "--enable-mojo-media-renderer"; | 34 const char kEnableMojoMediaRenderer[] = "--enable-mojo-media-renderer"; |
35 | 35 |
36 class HTMLViewer; | 36 class HTMLViewer; |
37 | 37 |
38 class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { | 38 class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { |
39 public: | 39 public: |
40 ContentHandlerImpl(Shell* shell, | 40 ContentHandlerImpl(scoped_refptr<base::MessageLoopProxy> compositor_thread, |
41 scoped_refptr<base::MessageLoopProxy> compositor_thread, | |
42 WebMediaPlayerFactory* web_media_player_factory) | 41 WebMediaPlayerFactory* web_media_player_factory) |
43 : shell_(shell), | 42 : compositor_thread_(compositor_thread), |
44 compositor_thread_(compositor_thread), | |
45 web_media_player_factory_(web_media_player_factory) {} | 43 web_media_player_factory_(web_media_player_factory) {} |
46 ~ContentHandlerImpl() override {} | 44 ~ContentHandlerImpl() override {} |
47 | 45 |
48 private: | 46 private: |
49 // Overridden from ContentHandler: | 47 // Overridden from ContentHandler: |
50 void OnConnect( | 48 void StartApplication(ShellPtr shell, URLResponsePtr response) override { |
51 const mojo::String& requestor_url, | |
52 URLResponsePtr response, | |
53 InterfaceRequest<ServiceProvider> service_provider_request) override { | |
54 new HTMLDocumentView(response.Pass(), | 49 new HTMLDocumentView(response.Pass(), |
55 service_provider_request.Pass(), | 50 shell.Pass(), |
56 shell_, | |
57 compositor_thread_, | 51 compositor_thread_, |
58 web_media_player_factory_); | 52 web_media_player_factory_); |
59 } | 53 } |
60 | 54 |
61 Shell* shell_; | |
62 scoped_refptr<base::MessageLoopProxy> compositor_thread_; | 55 scoped_refptr<base::MessageLoopProxy> compositor_thread_; |
63 WebMediaPlayerFactory* web_media_player_factory_; | 56 WebMediaPlayerFactory* web_media_player_factory_; |
64 | 57 |
65 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); | 58 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); |
66 }; | 59 }; |
67 | 60 |
68 class HTMLViewer : public ApplicationDelegate, | 61 class HTMLViewer : public ApplicationDelegate, |
69 public InterfaceFactory<ContentHandler> { | 62 public InterfaceFactory<ContentHandler> { |
70 public: | 63 public: |
71 HTMLViewer() : compositor_thread_("compositor thread") {} | 64 HTMLViewer() : compositor_thread_("compositor thread") {} |
72 | 65 |
73 ~HTMLViewer() override { blink::shutdown(); } | 66 ~HTMLViewer() override { blink::shutdown(); } |
74 | 67 |
75 private: | 68 private: |
76 // Overridden from ApplicationDelegate: | 69 // Overridden from ApplicationDelegate: |
77 void Initialize(ApplicationImpl* app) override { | 70 void Initialize(ApplicationImpl* app) override { |
78 shell_ = app->shell(); | |
79 blink_platform_impl_.reset(new BlinkPlatformImpl(app)); | 71 blink_platform_impl_.reset(new BlinkPlatformImpl(app)); |
80 blink::initialize(blink_platform_impl_.get()); | 72 blink::initialize(blink_platform_impl_.get()); |
81 #if !defined(COMPONENT_BUILD) | 73 #if !defined(COMPONENT_BUILD) |
82 base::i18n::InitializeICU(); | 74 base::i18n::InitializeICU(); |
83 | 75 |
84 ui::RegisterPathProvider(); | 76 ui::RegisterPathProvider(); |
85 | 77 |
86 base::FilePath ui_test_pak_path; | 78 base::FilePath ui_test_pak_path; |
87 CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); | 79 CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); |
88 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); | 80 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); |
(...skipping 14 matching lines...) Expand all Loading... |
103 | 95 |
104 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 96 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
105 connection->AddService(this); | 97 connection->AddService(this); |
106 return true; | 98 return true; |
107 } | 99 } |
108 | 100 |
109 // Overridden from InterfaceFactory<ContentHandler> | 101 // Overridden from InterfaceFactory<ContentHandler> |
110 void Create(ApplicationConnection* connection, | 102 void Create(ApplicationConnection* connection, |
111 InterfaceRequest<ContentHandler> request) override { | 103 InterfaceRequest<ContentHandler> request) override { |
112 BindToRequest( | 104 BindToRequest( |
113 new ContentHandlerImpl(shell_, compositor_thread_.message_loop_proxy(), | 105 new ContentHandlerImpl(compositor_thread_.message_loop_proxy(), |
114 web_media_player_factory_.get()), | 106 web_media_player_factory_.get()), |
115 &request); | 107 &request); |
116 } | 108 } |
117 | 109 |
118 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; | 110 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; |
119 Shell* shell_; | |
120 base::Thread compositor_thread_; | 111 base::Thread compositor_thread_; |
121 scoped_ptr<WebMediaPlayerFactory> web_media_player_factory_; | 112 scoped_ptr<WebMediaPlayerFactory> web_media_player_factory_; |
122 | 113 |
123 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); | 114 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); |
124 }; | 115 }; |
125 | 116 |
126 } // namespace mojo | 117 } // namespace mojo |
127 | 118 |
128 MojoResult MojoMain(MojoHandle shell_handle) { | 119 MojoResult MojoMain(MojoHandle shell_handle) { |
129 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer); | 120 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer); |
130 return runner.Run(shell_handle); | 121 return runner.Run(shell_handle); |
131 } | 122 } |
OLD | NEW |