| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "mojo/embedder/embedder.h" | 11 #include "mojo/embedder/embedder.h" |
| 12 #include "mojo/gles2/gles2_support_impl.h" | 12 #include "mojo/gles2/gles2_support_impl.h" |
| 13 #include "mojo/public/cpp/shell/application.h" | 13 #include "mojo/public/cpp/shell/application.h" |
| 14 #include "mojo/service_manager/background_service_loader.h" | 14 #include "mojo/service_manager/background_service_loader.h" |
| 15 #include "mojo/service_manager/service_loader.h" | 15 #include "mojo/service_manager/service_loader.h" |
| 16 #include "mojo/service_manager/service_manager.h" | 16 #include "mojo/service_manager/service_manager.h" |
| 17 #include "mojo/services/native_viewport/native_viewport_service.h" | 17 #include "mojo/services/native_viewport/native_viewport_service.h" |
| 18 #include "mojo/shell/dynamic_service_loader.h" | 18 #include "mojo/shell/dynamic_service_loader.h" |
| 19 #include "mojo/shell/in_process_dynamic_service_runner.h" | 19 #include "mojo/shell/in_process_dynamic_service_runner.h" |
| 20 #include "mojo/shell/network_delegate.h" | 20 #include "mojo/shell/network_delegate.h" |
| 21 #include "mojo/shell/out_of_process_dynamic_service_runner.h" | 21 #include "mojo/shell/out_of_process_dynamic_service_runner.h" |
| 22 #include "mojo/shell/switches.h" | 22 #include "mojo/shell/switches.h" |
| 23 #include "mojo/spy/spy.h" | 23 #include "mojo/spy/spy.h" |
| 24 | 24 |
| 25 #if defined(OS_LINUX) | 25 #if defined(OS_LINUX) |
| 26 #include "mojo/shell/dbus_service_loader_linux.h" | 26 #include "mojo/shell/dbus_service_loader_linux.h" |
| 27 #endif // defined(OS_LINUX) | 27 #endif // defined(OS_LINUX) |
| 28 | 28 |
| 29 #if defined(USE_AURA) | 29 #if defined(USE_AURA) |
| 30 #include "mojo/shell/view_manager_loader.h" | 30 #include "mojo/services/view_manager/root_node_manager.h" |
| 31 #include "mojo/services/view_manager/view_manager_connection.h" |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 namespace mojo { | 34 namespace mojo { |
| 34 namespace shell { | 35 namespace shell { |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 // Used to ensure we only init once. | 38 // Used to ensure we only init once. |
| 38 class Setup { | 39 class Setup { |
| 39 public: | 40 public: |
| 40 Setup() { | 41 Setup() { |
| 41 embedder::Init(); | 42 embedder::Init(); |
| 42 gles2::GLES2SupportImpl::Init(); | 43 gles2::GLES2SupportImpl::Init(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 ~Setup() { | 46 ~Setup() { |
| 46 } | 47 } |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 DISALLOW_COPY_AND_ASSIGN(Setup); | 50 DISALLOW_COPY_AND_ASSIGN(Setup); |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 static base::LazyInstance<Setup> setup = LAZY_INSTANCE_INITIALIZER; | 53 static base::LazyInstance<Setup> setup = LAZY_INSTANCE_INITIALIZER; |
| 53 | 54 |
| 55 #if defined(USE_AURA) |
| 56 class ViewManagerLoader : public ServiceLoader { |
| 57 public: |
| 58 ViewManagerLoader() {} |
| 59 virtual ~ViewManagerLoader() {} |
| 60 |
| 61 private: |
| 62 virtual void LoadService(ServiceManager* manager, |
| 63 const GURL& url, |
| 64 ScopedShellHandle shell_handle) OVERRIDE { |
| 65 scoped_ptr<Application> app(new Application(shell_handle.Pass())); |
| 66 app->AddServiceConnector( |
| 67 new ServiceConnector<services::view_manager::ViewManagerConnection, |
| 68 services::view_manager::RootNodeManager>( |
| 69 &root_node_manager_)); |
| 70 apps_.push_back(app.release()); |
| 71 } |
| 72 |
| 73 virtual void OnServiceError(ServiceManager* manager, |
| 74 const GURL& url) OVERRIDE { |
| 75 } |
| 76 |
| 77 services::view_manager::RootNodeManager root_node_manager_; |
| 78 ScopedVector<Application> apps_; |
| 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(ViewManagerLoader); |
| 81 }; |
| 82 #endif |
| 83 |
| 54 } // namespace | 84 } // namespace |
| 55 | 85 |
| 56 class Context::NativeViewportServiceLoader : public ServiceLoader { | 86 class Context::NativeViewportServiceLoader : public ServiceLoader { |
| 57 public: | 87 public: |
| 58 explicit NativeViewportServiceLoader(Context* context) : context_(context) {} | 88 explicit NativeViewportServiceLoader(Context* context) : context_(context) {} |
| 59 virtual ~NativeViewportServiceLoader() {} | 89 virtual ~NativeViewportServiceLoader() {} |
| 60 | 90 |
| 61 private: | 91 private: |
| 62 virtual void LoadService(ServiceManager* manager, | 92 virtual void LoadService(ServiceManager* manager, |
| 63 const GURL& url, | 93 const GURL& url, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 #if defined(USE_AURA) | 158 #if defined(USE_AURA) |
| 129 service_manager_.SetLoaderForURL( | 159 service_manager_.SetLoaderForURL( |
| 130 scoped_ptr<ServiceLoader>(), | 160 scoped_ptr<ServiceLoader>(), |
| 131 GURL("mojo:mojo_view_manager")); | 161 GURL("mojo:mojo_view_manager")); |
| 132 #endif | 162 #endif |
| 133 service_manager_.set_default_loader(scoped_ptr<ServiceLoader>()); | 163 service_manager_.set_default_loader(scoped_ptr<ServiceLoader>()); |
| 134 } | 164 } |
| 135 | 165 |
| 136 } // namespace shell | 166 } // namespace shell |
| 137 } // namespace mojo | 167 } // namespace mojo |
| OLD | NEW |