| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/files/file_path.h" | |
| 6 #include "base/message_loop/message_loop.h" | |
| 7 #include "base/threading/thread.h" | |
| 8 #include "mojo/application/application_runner_chromium.h" | |
| 9 #include "mojo/common/tracing_impl.h" | |
| 10 #include "mojo/icu/icu.h" | |
| 11 #include "mojo/public/c/system/main.h" | |
| 12 #include "mojo/public/cpp/application/application_connection.h" | |
| 13 #include "mojo/public/cpp/application/application_delegate.h" | |
| 14 #include "mojo/public/cpp/application/application_impl.h" | |
| 15 #include "mojo/public/cpp/application/interface_factory_impl.h" | |
| 16 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" | |
| 17 #include "sky/engine/public/web/Sky.h" | |
| 18 #include "sky/engine/public/web/WebRuntimeFeatures.h" | |
| 19 #include "sky/services/platform/platform_impl.h" | |
| 20 #include "sky/viewer/content_handler_impl.h" | |
| 21 #include "sky/viewer/document_view.h" | |
| 22 #include "sky/viewer/runtime_flags.h" | |
| 23 | |
| 24 namespace sky { | |
| 25 | |
| 26 class Viewer : public mojo::ApplicationDelegate, | |
| 27 public mojo::InterfaceFactory<mojo::ContentHandler> { | |
| 28 public: | |
| 29 Viewer() {} | |
| 30 | |
| 31 ~Viewer() override { blink::shutdown(); } | |
| 32 | |
| 33 private: | |
| 34 // Overridden from ApplicationDelegate: | |
| 35 void Initialize(mojo::ApplicationImpl* app) override { | |
| 36 RuntimeFlags::Initialize(app); | |
| 37 | |
| 38 blink::WebRuntimeFeatures::enableObservatory(!RuntimeFlags::Get().testing())
; | |
| 39 | |
| 40 mojo::NetworkServicePtr network_service; | |
| 41 app->ConnectToService("mojo:authenticated_network_service", | |
| 42 &network_service); | |
| 43 platform_impl_.reset(new PlatformImpl(network_service.Pass())); | |
| 44 blink::initialize(platform_impl_.get()); | |
| 45 | |
| 46 mojo::icu::Initialize(app); | |
| 47 tracing_.Initialize(app); | |
| 48 } | |
| 49 | |
| 50 bool ConfigureIncomingConnection( | |
| 51 mojo::ApplicationConnection* connection) override { | |
| 52 connection->AddService<mojo::ContentHandler>(this); | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 // Overridden from InterfaceFactory<ContentHandler> | |
| 57 void Create(mojo::ApplicationConnection* connection, | |
| 58 mojo::InterfaceRequest<mojo::ContentHandler> request) override { | |
| 59 new ContentHandlerImpl(request.Pass()); | |
| 60 } | |
| 61 | |
| 62 scoped_ptr<PlatformImpl> platform_impl_; | |
| 63 mojo::TracingImpl tracing_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(Viewer); | |
| 66 }; | |
| 67 | |
| 68 } // namespace sky | |
| 69 | |
| 70 MojoResult MojoMain(MojoHandle application_request) { | |
| 71 mojo::ApplicationRunnerChromium runner(new sky::Viewer); | |
| 72 return runner.Run(application_request); | |
| 73 } | |
| OLD | NEW |