| 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/files/file_path.h" | 5 #include "base/files/file_path.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/common/tracing_impl.h" | 9 #include "mojo/common/tracing_impl.h" |
| 10 #include "mojo/icu/icu.h" |
| 10 #include "mojo/public/c/system/main.h" | 11 #include "mojo/public/c/system/main.h" |
| 11 #include "mojo/public/cpp/application/application_connection.h" | 12 #include "mojo/public/cpp/application/application_connection.h" |
| 12 #include "mojo/public/cpp/application/application_delegate.h" | 13 #include "mojo/public/cpp/application/application_delegate.h" |
| 13 #include "mojo/public/cpp/application/application_impl.h" | 14 #include "mojo/public/cpp/application/application_impl.h" |
| 14 #include "mojo/public/cpp/application/interface_factory_impl.h" | 15 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 15 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" | 16 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" |
| 16 #include "sky/compositor/display_delegate_bitmap.h" | 17 #include "sky/compositor/display_delegate_bitmap.h" |
| 17 #include "sky/compositor/display_delegate_ganesh.h" | 18 #include "sky/compositor/display_delegate_ganesh.h" |
| 18 #include "sky/engine/public/web/Sky.h" | 19 #include "sky/engine/public/web/Sky.h" |
| 19 #include "sky/viewer/content_handler_impl.h" | 20 #include "sky/viewer/content_handler_impl.h" |
| 20 #include "sky/viewer/document_view.h" | 21 #include "sky/viewer/document_view.h" |
| 21 #include "sky/viewer/platform/platform_impl.h" | 22 #include "sky/viewer/platform/platform_impl.h" |
| 22 | 23 |
| 23 #if !defined(COMPONENT_BUILD) | |
| 24 #include "base/i18n/icu_util.h" | |
| 25 #endif | |
| 26 | |
| 27 namespace sky { | 24 namespace sky { |
| 28 | 25 |
| 29 // Load the viewer in testing mode so we can dump pixels. | 26 // Load the viewer in testing mode so we can dump pixels. |
| 30 const char kTesting[] = "--testing"; | 27 const char kTesting[] = "--testing"; |
| 31 | 28 |
| 32 class Viewer : public mojo::ApplicationDelegate, | 29 class Viewer : public mojo::ApplicationDelegate, |
| 33 public mojo::InterfaceFactory<mojo::ContentHandler> { | 30 public mojo::InterfaceFactory<mojo::ContentHandler> { |
| 34 public: | 31 public: |
| 35 Viewer() {} | 32 Viewer() {} |
| 36 | 33 |
| 37 virtual ~Viewer() { blink::shutdown(); } | 34 virtual ~Viewer() { blink::shutdown(); } |
| 38 | 35 |
| 39 private: | 36 private: |
| 40 // Overridden from ApplicationDelegate: | 37 // Overridden from ApplicationDelegate: |
| 41 virtual void Initialize(mojo::ApplicationImpl* app) override { | 38 virtual void Initialize(mojo::ApplicationImpl* app) override { |
| 42 if (app->HasArg(kTesting)) { | 39 if (app->HasArg(kTesting)) { |
| 43 DisplayDelegate::setDisplayDelegateCreateFunction( | 40 DisplayDelegate::setDisplayDelegateCreateFunction( |
| 44 DisplayDelegateBitmap::create); | 41 DisplayDelegateBitmap::create); |
| 45 } else { | 42 } else { |
| 46 DisplayDelegate::setDisplayDelegateCreateFunction( | 43 DisplayDelegate::setDisplayDelegateCreateFunction( |
| 47 DisplayDelegateGanesh::create); | 44 DisplayDelegateGanesh::create); |
| 48 } | 45 } |
| 49 | 46 |
| 50 platform_impl_.reset(new PlatformImpl(app)); | 47 platform_impl_.reset(new PlatformImpl(app)); |
| 51 blink::initialize(platform_impl_.get()); | 48 blink::initialize(platform_impl_.get()); |
| 52 | 49 |
| 53 // TODO(eseidel): Haven't solved ICU data loading for MojoShell.apk yet. | 50 mojo::icu::Initialize(app); |
| 54 #if !defined(OS_ANDROID) | |
| 55 base::i18n::InitializeICU(); | |
| 56 #endif | |
| 57 | |
| 58 mojo::TracingImpl::Create(app); | 51 mojo::TracingImpl::Create(app); |
| 59 } | 52 } |
| 60 | 53 |
| 61 virtual bool ConfigureIncomingConnection( | 54 virtual bool ConfigureIncomingConnection( |
| 62 mojo::ApplicationConnection* connection) override { | 55 mojo::ApplicationConnection* connection) override { |
| 63 connection->AddService<mojo::ContentHandler>(this); | 56 connection->AddService<mojo::ContentHandler>(this); |
| 64 return true; | 57 return true; |
| 65 } | 58 } |
| 66 | 59 |
| 67 // Overridden from InterfaceFactory<ContentHandler> | 60 // Overridden from InterfaceFactory<ContentHandler> |
| 68 virtual void Create(mojo::ApplicationConnection* connection, | 61 virtual void Create(mojo::ApplicationConnection* connection, |
| 69 mojo::InterfaceRequest<mojo::ContentHandler> request) over
ride { | 62 mojo::InterfaceRequest<mojo::ContentHandler> request) over
ride { |
| 70 mojo::BindToRequest(new ContentHandlerImpl(), &request); | 63 mojo::BindToRequest(new ContentHandlerImpl(), &request); |
| 71 } | 64 } |
| 72 | 65 |
| 73 scoped_ptr<PlatformImpl> platform_impl_; | 66 scoped_ptr<PlatformImpl> platform_impl_; |
| 74 | 67 |
| 75 DISALLOW_COPY_AND_ASSIGN(Viewer); | 68 DISALLOW_COPY_AND_ASSIGN(Viewer); |
| 76 }; | 69 }; |
| 77 | 70 |
| 78 } // namespace mojo | 71 } // namespace mojo |
| 79 | 72 |
| 80 MojoResult MojoMain(MojoHandle shell_handle) { | 73 MojoResult MojoMain(MojoHandle shell_handle) { |
| 81 mojo::ApplicationRunnerChromium runner(new sky::Viewer); | 74 mojo::ApplicationRunnerChromium runner(new sky::Viewer); |
| 82 return runner.Run(shell_handle); | 75 return runner.Run(shell_handle); |
| 83 } | 76 } |
| OLD | NEW |