Chromium Code Reviews| 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 | |
| 6 #include "base/i18n/icu_util.h" | 5 #include "base/i18n/icu_util.h" |
| 6 #include "gin/array_buffer.h" | |
| 7 #include "gin/public/isolate_holder.h" | |
| 7 #include "mojo/application/application_runner_chromium.h" | 8 #include "mojo/application/application_runner_chromium.h" |
| 8 #include "mojo/apps/js/application_delegate_impl.h" | 9 #include "mojo/application/content_handler_factory.h" |
| 9 #include "mojo/apps/js/content_handler_impl.h" | 10 #include "mojo/apps/js/js_app.h" |
| 10 #include "mojo/public/c/system/main.h" | 11 #include "mojo/public/c/system/main.h" |
| 11 #include "mojo/public/cpp/application/application_impl.h" | 12 #include "mojo/public/cpp/application/application_impl.h" |
| 12 #include "mojo/public/cpp/application/interface_factory_impl.h" | 13 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 13 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom. h" | |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace apps { | 16 namespace apps { |
| 17 | 17 |
| 18 class ContentHandlerApplicationDelegateImpl : public ApplicationDelegateImpl { | 18 class JsContentHandler : public ApplicationDelegate, |
| 19 public ContentHandlerFactory::Delegate { | |
| 19 public: | 20 public: |
| 20 ContentHandlerApplicationDelegateImpl() : content_handler_factory_(this) { | 21 JsContentHandler() : content_handler_factory_(this) {} |
| 22 | |
| 23 private: | |
| 24 // Overridden from ApplicationDelegate: | |
| 25 void Initialize(ApplicationImpl* app) override { | |
| 26 base::i18n::InitializeICU(); | |
| 27 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, | |
| 28 gin::ArrayBufferAllocator::SharedInstance()); | |
| 21 } | 29 } |
| 22 | 30 |
| 23 private: | 31 // Overridden from ApplicationDelegate: |
| 24 void Initialize(ApplicationImpl* app) override { | 32 virtual bool ConfigureIncomingConnection( |
|
hansmuller
2014/10/31 16:14:44
Is the virtual keyword needed here? Likewise most
qsr
2014/10/31 16:31:36
Done.
| |
| 25 base::i18n::InitializeICU(); | 33 ApplicationConnection* connection) override { |
| 26 ApplicationDelegateImpl::Initialize(app); | |
| 27 } | |
| 28 | |
| 29 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | |
| 30 connection->AddService(&content_handler_factory_); | 34 connection->AddService(&content_handler_factory_); |
| 31 return true; | 35 return true; |
| 32 } | 36 } |
| 33 | 37 |
| 34 InterfaceFactoryImplWithContext<ContentHandlerImpl, ApplicationDelegateImpl> | 38 // Overridden from ContentHandlerFactory::Delegate: |
| 35 content_handler_factory_; | 39 virtual scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> |
| 40 CreateApplication(ShellPtr shell, URLResponsePtr response) override { | |
| 41 return make_scoped_ptr(new JSApp(shell.Pass(), response.Pass())); | |
| 42 } | |
| 43 | |
| 44 ContentHandlerFactory content_handler_factory_; | |
| 45 | |
| 46 DISALLOW_COPY_AND_ASSIGN(JsContentHandler); | |
| 36 }; | 47 }; |
| 37 | 48 |
| 38 } // namespace apps | 49 } // namespace apps |
| 39 } // namespace mojo | 50 } // namespace mojo |
| 40 | 51 |
| 41 MojoResult MojoMain(MojoHandle shell_handle) { | 52 MojoResult MojoMain(MojoHandle shell_handle) { |
| 42 mojo::ApplicationRunnerChromium runner( | 53 mojo::ApplicationRunnerChromium runner(new mojo::apps::JsContentHandler); |
| 43 new mojo::apps::ContentHandlerApplicationDelegateImpl()); | |
| 44 return runner.Run(shell_handle); | 54 return runner.Run(shell_handle); |
| 45 } | 55 } |
| OLD | NEW |