| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shell/context.h" | 5 #include "mojo/shell/context.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "mojo/application_manager/application_loader.h" | 14 #include "mojo/application_manager/application_loader.h" |
| 15 #include "mojo/application_manager/application_manager.h" | 15 #include "mojo/application_manager/application_manager.h" |
| 16 #include "mojo/application_manager/background_shell_application_loader.h" | 16 #include "mojo/application_manager/background_shell_application_loader.h" |
| 17 #include "mojo/embedder/embedder.h" | 17 #include "mojo/embedder/embedder.h" |
| 18 #include "mojo/public/cpp/application/application_connection.h" | 18 #include "mojo/public/cpp/application/application_connection.h" |
| 19 #include "mojo/public/cpp/application/application_delegate.h" | 19 #include "mojo/public/cpp/application/application_delegate.h" |
| 20 #include "mojo/public/cpp/application/application_impl.h" | 20 #include "mojo/public/cpp/application/application_impl.h" |
| 21 #include "mojo/services/native_viewport/native_viewport_impl.h" | |
| 22 #include "mojo/shell/dynamic_application_loader.h" | 21 #include "mojo/shell/dynamic_application_loader.h" |
| 23 #include "mojo/shell/in_process_dynamic_service_runner.h" | 22 #include "mojo/shell/in_process_dynamic_service_runner.h" |
| 24 #include "mojo/shell/out_of_process_dynamic_service_runner.h" | 23 #include "mojo/shell/out_of_process_dynamic_service_runner.h" |
| 25 #include "mojo/shell/switches.h" | 24 #include "mojo/shell/switches.h" |
| 26 #include "mojo/shell/ui_application_loader_android.h" | 25 #include "mojo/shell/ui_application_loader_android.h" |
| 27 #include "mojo/spy/spy.h" | 26 #include "mojo/spy/spy.h" |
| 28 | 27 |
| 29 #if defined(OS_LINUX) | 28 #if defined(OS_LINUX) |
| 30 #include "mojo/shell/dbus_application_loader_linux.h" | 29 #include "mojo/shell/dbus_application_loader_linux.h" |
| 31 #endif // defined(OS_LINUX) | 30 #endif // defined(OS_LINUX) |
| 32 | 31 |
| 33 #if defined(OS_ANDROID) | 32 #if defined(OS_ANDROID) |
| 33 #include "mojo/services/native_viewport/native_viewport_impl.h" |
| 34 #include "mojo/shell/network_application_loader.h" | 34 #include "mojo/shell/network_application_loader.h" |
| 35 #endif // defined(OS_ANDROID) | 35 #endif // defined(OS_ANDROID) |
| 36 | 36 |
| 37 #if defined(USE_AURA) | 37 #if defined(USE_AURA) |
| 38 #include "mojo/shell/view_manager_loader.h" | 38 #include "mojo/shell/view_manager_loader.h" |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 namespace mojo { | 41 namespace mojo { |
| 42 namespace shell { | 42 namespace shell { |
| 43 namespace { | 43 namespace { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers | 85 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers |
| 86 << ": '" << parts[i + 1] << "' is not a valid URL."; | 86 << ": '" << parts[i + 1] << "' is not a valid URL."; |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 loader->RegisterContentHandler(parts[i], url); | 89 loader->RegisterContentHandler(parts[i], url); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace | 93 } // namespace |
| 94 | 94 |
| 95 class Context::NativeViewportApplicationLoader | 95 #if defined(OS_ANDROID) |
| 96 class NativeViewportApplicationLoader |
| 96 : public ApplicationLoader, | 97 : public ApplicationLoader, |
| 97 public ApplicationDelegate, | 98 public ApplicationDelegate, |
| 98 public InterfaceFactory<NativeViewport> { | 99 public InterfaceFactory<NativeViewport> { |
| 99 public: | 100 public: |
| 100 NativeViewportApplicationLoader() {} | 101 NativeViewportApplicationLoader() {} |
| 101 virtual ~NativeViewportApplicationLoader() {} | 102 virtual ~NativeViewportApplicationLoader() {} |
| 102 | 103 |
| 103 private: | 104 private: |
| 104 // ApplicationLoader implementation. | 105 // ApplicationLoader implementation. |
| 105 virtual void Load(ApplicationManager* manager, | 106 virtual void Load(ApplicationManager* manager, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 122 | 123 |
| 123 // InterfaceFactory<NativeViewport> implementation. | 124 // InterfaceFactory<NativeViewport> implementation. |
| 124 virtual void Create(ApplicationConnection* connection, | 125 virtual void Create(ApplicationConnection* connection, |
| 125 InterfaceRequest<NativeViewport> request) OVERRIDE { | 126 InterfaceRequest<NativeViewport> request) OVERRIDE { |
| 126 BindToRequest(new NativeViewportImpl, &request); | 127 BindToRequest(new NativeViewportImpl, &request); |
| 127 } | 128 } |
| 128 | 129 |
| 129 scoped_ptr<ApplicationImpl> app_; | 130 scoped_ptr<ApplicationImpl> app_; |
| 130 DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader); | 131 DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader); |
| 131 }; | 132 }; |
| 133 #endif |
| 132 | 134 |
| 133 Context::Context() { | 135 Context::Context() { |
| 134 DCHECK(!base::MessageLoop::current()); | 136 DCHECK(!base::MessageLoop::current()); |
| 135 } | 137 } |
| 136 | 138 |
| 137 void Context::Init() { | 139 void Context::Init() { |
| 138 setup.Get(); | 140 setup.Get(); |
| 139 task_runners_.reset( | 141 task_runners_.reset( |
| 140 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); | 142 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); |
| 141 | 143 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 157 | 159 |
| 158 // The native viewport service synchronously waits for certain messages. If we | 160 // The native viewport service synchronously waits for certain messages. If we |
| 159 // don't run it on its own thread we can easily deadlock. Long term native | 161 // don't run it on its own thread we can easily deadlock. Long term native |
| 160 // viewport should run its own process so that this isn't an issue. | 162 // viewport should run its own process so that this isn't an issue. |
| 161 #if defined(OS_ANDROID) | 163 #if defined(OS_ANDROID) |
| 162 application_manager_.SetLoaderForURL( | 164 application_manager_.SetLoaderForURL( |
| 163 scoped_ptr<ApplicationLoader>(new UIApplicationLoader( | 165 scoped_ptr<ApplicationLoader>(new UIApplicationLoader( |
| 164 scoped_ptr<ApplicationLoader>(new NativeViewportApplicationLoader()), | 166 scoped_ptr<ApplicationLoader>(new NativeViewportApplicationLoader()), |
| 165 this)), | 167 this)), |
| 166 GURL("mojo:mojo_native_viewport_service")); | 168 GURL("mojo:mojo_native_viewport_service")); |
| 167 #else | |
| 168 { | |
| 169 scoped_ptr<BackgroundShellApplicationLoader> loader( | |
| 170 new BackgroundShellApplicationLoader( | |
| 171 scoped_ptr<ApplicationLoader>( | |
| 172 new NativeViewportApplicationLoader()), | |
| 173 "native_viewport", | |
| 174 base::MessageLoop::TYPE_UI)); | |
| 175 application_manager_.SetLoaderForURL( | |
| 176 loader.PassAs<ApplicationLoader>(), | |
| 177 GURL("mojo:mojo_native_viewport_service")); | |
| 178 } | |
| 179 #endif | 169 #endif |
| 180 #if defined(USE_AURA) | 170 #if defined(USE_AURA) |
| 181 // TODO(sky): need a better way to find this. It shouldn't be linked in. | 171 // TODO(sky): need a better way to find this. It shouldn't be linked in. |
| 182 application_manager_.SetLoaderForURL( | 172 application_manager_.SetLoaderForURL( |
| 183 scoped_ptr<ApplicationLoader>(new ViewManagerLoader()), | 173 scoped_ptr<ApplicationLoader>(new ViewManagerLoader()), |
| 184 GURL("mojo:mojo_view_manager")); | 174 GURL("mojo:mojo_view_manager")); |
| 185 #endif | 175 #endif |
| 186 | 176 |
| 187 #if defined(OS_LINUX) | 177 #if defined(OS_LINUX) |
| 188 application_manager_.SetLoaderForScheme( | 178 application_manager_.SetLoaderForScheme( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 209 } | 199 } |
| 210 #endif | 200 #endif |
| 211 } | 201 } |
| 212 | 202 |
| 213 Context::~Context() { | 203 Context::~Context() { |
| 214 DCHECK(!base::MessageLoop::current()); | 204 DCHECK(!base::MessageLoop::current()); |
| 215 } | 205 } |
| 216 | 206 |
| 217 } // namespace shell | 207 } // namespace shell |
| 218 } // namespace mojo | 208 } // namespace mojo |
| OLD | NEW |