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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "gin/public/isolate_holder.h" | 11 #include "gin/public/isolate_holder.h" |
12 #include "mojo/application/application_runner_chromium.h" | 12 #include "mojo/application/application_runner_chromium.h" |
13 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom. h" | 13 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom. h" |
14 #include "mojo/services/html_viewer/html_document.h" | 14 #include "mojo/services/html_viewer/html_document.h" |
15 #include "mojo/services/html_viewer/mojo_blink_platform_impl.h" | 15 #include "mojo/services/html_viewer/mojo_blink_platform_impl.h" |
16 #include "mojo/services/html_viewer/webmediaplayer_factory.h" | 16 #include "mojo/services/html_viewer/webmediaplayer_factory.h" |
17 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 17 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
18 #include "third_party/WebKit/public/web/WebKit.h" | 18 #include "third_party/WebKit/public/web/WebKit.h" |
19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
20 #include "third_party/mojo/src/mojo/public/c/system/main.h" | 20 #include "third_party/mojo/src/mojo/public/c/system/main.h" |
21 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio n.h" | 21 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio n.h" |
22 #include "third_party/mojo/src/mojo/public/cpp/application/application_delegate. h" | 22 #include "third_party/mojo/src/mojo/public/cpp/application/application_delegate. h" |
23 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h" | 23 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h" |
24 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h" | 24 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h" |
25 #include "third_party/mojo/src/mojo/public/cpp/application/interface_factory_imp l.h" | 25 #include "third_party/mojo/src/mojo/public/cpp/application/interface_factory_imp l.h" |
26 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | |
26 | 27 |
27 #if !defined(COMPONENT_BUILD) | 28 #if !defined(COMPONENT_BUILD) |
28 #include "base/i18n/icu_util.h" | 29 #include "base/i18n/icu_util.h" |
29 #include "base/path_service.h" | 30 #include "base/path_service.h" |
30 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
31 #include "ui/base/ui_base_paths.h" | 32 #include "ui/base/ui_base_paths.h" |
32 #endif | 33 #endif |
33 | 34 |
34 using mojo::ApplicationConnection; | 35 using mojo::ApplicationConnection; |
35 using mojo::Array; | 36 using mojo::Array; |
(...skipping 16 matching lines...) Expand all Loading... | |
52 // media::Renderer implementation. | 53 // media::Renderer implementation. |
53 const char kEnableMojoMediaRenderer[] = "enable-mojo-media-renderer"; | 54 const char kEnableMojoMediaRenderer[] = "enable-mojo-media-renderer"; |
54 | 55 |
55 // Disables support for (unprefixed) Encrypted Media Extensions. | 56 // Disables support for (unprefixed) Encrypted Media Extensions. |
56 const char kDisableEncryptedMedia[] = "disable-encrypted-media"; | 57 const char kDisableEncryptedMedia[] = "disable-encrypted-media"; |
57 | 58 |
58 class HTMLViewer; | 59 class HTMLViewer; |
59 | 60 |
60 class HTMLViewerApplication : public mojo::Application { | 61 class HTMLViewerApplication : public mojo::Application { |
61 public: | 62 public: |
62 HTMLViewerApplication(ShellPtr shell, | 63 HTMLViewerApplication(InterfaceRequest<Application> request, |
63 URLResponsePtr response, | 64 URLResponsePtr response, |
64 scoped_refptr<base::MessageLoopProxy> compositor_thread, | 65 scoped_refptr<base::MessageLoopProxy> compositor_thread, |
65 WebMediaPlayerFactory* web_media_player_factory) | 66 WebMediaPlayerFactory* web_media_player_factory) |
66 : url_(response->url), | 67 : url_(response->url), |
67 shell_(shell.Pass()), | 68 binding_(this, request.Pass()), |
68 initial_response_(response.Pass()), | 69 initial_response_(response.Pass()), |
69 compositor_thread_(compositor_thread), | 70 compositor_thread_(compositor_thread), |
70 web_media_player_factory_(web_media_player_factory) { | 71 web_media_player_factory_(web_media_player_factory) {} |
71 shell_.set_client(this); | 72 |
73 void Initialize(mojo::ShellPtr shell, | |
74 mojo::Array<mojo::String> args) override { | |
jamesr
2015/01/28 18:46:25
we have 'using mojo::Array' and 'mojo::String' dec
blundell
2015/01/29 11:39:31
Done.
| |
72 ServiceProviderPtr service_provider; | 75 ServiceProviderPtr service_provider; |
73 shell_->ConnectToApplication("mojo:network_service", | 76 shell_->ConnectToApplication("mojo:network_service", |
jamesr
2015/01/28 18:46:24
you probably want to assign shell to shell_ before
blundell
2015/01/29 11:39:31
whoops! good catch, thanks.
| |
74 GetProxy(&service_provider), nullptr); | 77 GetProxy(&service_provider), nullptr); |
75 ConnectToService(service_provider.get(), &network_service_); | 78 ConnectToService(service_provider.get(), &network_service_); |
76 } | 79 } |
77 | 80 |
78 void Initialize(Array<String> args) override {} | |
79 | |
80 void AcceptConnection(const String& requestor_url, | 81 void AcceptConnection(const String& requestor_url, |
81 InterfaceRequest<ServiceProvider> services, | 82 InterfaceRequest<ServiceProvider> services, |
82 ServiceProviderPtr exposed_services) override { | 83 ServiceProviderPtr exposed_services) override { |
83 if (initial_response_) { | 84 if (initial_response_) { |
84 OnResponseReceived(URLLoaderPtr(), services.Pass(), | 85 OnResponseReceived(URLLoaderPtr(), services.Pass(), |
85 initial_response_.Pass()); | 86 initial_response_.Pass()); |
86 } else { | 87 } else { |
87 URLLoaderPtr loader; | 88 URLLoaderPtr loader; |
88 network_service_->CreateURLLoader(GetProxy(&loader)); | 89 network_service_->CreateURLLoader(GetProxy(&loader)); |
89 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 90 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
(...skipping 16 matching lines...) Expand all Loading... | |
106 | 107 |
107 private: | 108 private: |
108 void OnResponseReceived(URLLoaderPtr loader, | 109 void OnResponseReceived(URLLoaderPtr loader, |
109 InterfaceRequest<ServiceProvider> services, | 110 InterfaceRequest<ServiceProvider> services, |
110 URLResponsePtr response) { | 111 URLResponsePtr response) { |
111 new HTMLDocument(services.Pass(), response.Pass(), shell_.get(), | 112 new HTMLDocument(services.Pass(), response.Pass(), shell_.get(), |
112 compositor_thread_, web_media_player_factory_); | 113 compositor_thread_, web_media_player_factory_); |
113 } | 114 } |
114 | 115 |
115 String url_; | 116 String url_; |
117 mojo::StrongBinding<mojo::Application> binding_; | |
116 ShellPtr shell_; | 118 ShellPtr shell_; |
117 mojo::NetworkServicePtr network_service_; | 119 mojo::NetworkServicePtr network_service_; |
118 URLResponsePtr initial_response_; | 120 URLResponsePtr initial_response_; |
119 scoped_refptr<base::MessageLoopProxy> compositor_thread_; | 121 scoped_refptr<base::MessageLoopProxy> compositor_thread_; |
120 WebMediaPlayerFactory* web_media_player_factory_; | 122 WebMediaPlayerFactory* web_media_player_factory_; |
121 }; | 123 }; |
122 | 124 |
123 class ContentHandlerImpl : public mojo::InterfaceImpl<ContentHandler> { | 125 class ContentHandlerImpl : public mojo::InterfaceImpl<ContentHandler> { |
124 public: | 126 public: |
125 ContentHandlerImpl(scoped_refptr<base::MessageLoopProxy> compositor_thread, | 127 ContentHandlerImpl(scoped_refptr<base::MessageLoopProxy> compositor_thread, |
126 WebMediaPlayerFactory* web_media_player_factory) | 128 WebMediaPlayerFactory* web_media_player_factory) |
127 : compositor_thread_(compositor_thread), | 129 : compositor_thread_(compositor_thread), |
128 web_media_player_factory_(web_media_player_factory) {} | 130 web_media_player_factory_(web_media_player_factory) {} |
129 ~ContentHandlerImpl() override {} | 131 ~ContentHandlerImpl() override {} |
130 | 132 |
131 private: | 133 private: |
132 // Overridden from ContentHandler: | 134 // Overridden from ContentHandler: |
133 void StartApplication(ShellPtr shell, URLResponsePtr response) override { | 135 void StartApplication(InterfaceRequest<mojo::Application> request, |
134 new HTMLViewerApplication(shell.Pass(), response.Pass(), compositor_thread_, | 136 URLResponsePtr response) override { |
137 new HTMLViewerApplication(request.Pass(), response.Pass(), compositor_thread _, | |
135 web_media_player_factory_); | 138 web_media_player_factory_); |
136 } | 139 } |
137 | 140 |
138 scoped_refptr<base::MessageLoopProxy> compositor_thread_; | 141 scoped_refptr<base::MessageLoopProxy> compositor_thread_; |
139 WebMediaPlayerFactory* web_media_player_factory_; | 142 WebMediaPlayerFactory* web_media_player_factory_; |
140 | 143 |
141 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); | 144 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); |
142 }; | 145 }; |
143 | 146 |
144 class HTMLViewer : public mojo::ApplicationDelegate, | 147 class HTMLViewer : public mojo::ApplicationDelegate, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 | 217 |
215 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); | 218 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); |
216 }; | 219 }; |
217 | 220 |
218 } // namespace html_viewer | 221 } // namespace html_viewer |
219 | 222 |
220 MojoResult MojoMain(MojoHandle shell_handle) { | 223 MojoResult MojoMain(MojoHandle shell_handle) { |
221 mojo::ApplicationRunnerChromium runner(new html_viewer::HTMLViewer); | 224 mojo::ApplicationRunnerChromium runner(new html_viewer::HTMLViewer); |
222 return runner.Run(shell_handle); | 225 return runner.Run(shell_handle); |
223 } | 226 } |
OLD | NEW |