| 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "mojo/public/c/system/main.h" | 6 #include "mojo/public/c/system/main.h" |
| 7 #include "mojo/public/cpp/application/application_connection.h" | 7 #include "mojo/public/cpp/application/application_connection.h" |
| 8 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.h" |
| 9 #include "mojo/public/cpp/application/application_impl.h" | 9 #include "mojo/public/cpp/application/application_impl.h" |
| 10 #include "mojo/public/cpp/application/application_runner_chromium.h" | 10 #include "mojo/public/cpp/application/application_runner_chromium.h" |
| 11 #include "mojo/public/cpp/application/interface_factory_impl.h" | 11 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 12 #include "mojo/public/cpp/application/service_provider_impl.h" | |
| 13 #include "mojo/services/html_viewer/blink_platform_impl.h" | 12 #include "mojo/services/html_viewer/blink_platform_impl.h" |
| 14 #include "mojo/services/html_viewer/html_document_view.h" | 13 #include "mojo/services/html_viewer/html_document_view.h" |
| 15 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" | 14 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" |
| 16 #include "third_party/WebKit/public/web/WebKit.h" | 15 #include "third_party/WebKit/public/web/WebKit.h" |
| 17 | 16 |
| 18 namespace mojo { | 17 namespace mojo { |
| 19 | 18 |
| 20 class HTMLViewer; | 19 class HTMLViewer; |
| 21 | 20 |
| 22 class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { | 21 class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { |
| 23 public: | 22 public: |
| 24 explicit ContentHandlerImpl(Shell* shell) : shell_(shell) {} | 23 explicit ContentHandlerImpl(Shell* shell) : shell_(shell) {} |
| 25 virtual ~ContentHandlerImpl() {} | 24 virtual ~ContentHandlerImpl() {} |
| 26 | 25 |
| 27 private: | 26 private: |
| 28 // Overridden from ContentHandler: | 27 // Overridden from ContentHandler: |
| 29 virtual void OnConnect( | 28 virtual void OnConnect( |
| 30 const mojo::String& url, | 29 const mojo::String& url, |
| 31 URLResponsePtr response, | 30 URLResponsePtr response, |
| 32 InterfaceRequest<ServiceProvider> service_provider) OVERRIDE { | 31 InterfaceRequest<ServiceProvider> service_provider_request) OVERRIDE { |
| 33 ServiceProviderImpl* exported_services = new ServiceProviderImpl(); | |
| 34 BindToRequest(exported_services, &service_provider); | |
| 35 scoped_ptr<ServiceProvider> remote( | |
| 36 exported_services->CreateRemoteServiceProvider()); | |
| 37 new HTMLDocumentView( | 32 new HTMLDocumentView( |
| 38 response.Pass(), remote.Pass(), exported_services, shell_); | 33 response.Pass(), service_provider_request.Pass(), shell_); |
| 39 } | 34 } |
| 40 | 35 |
| 41 Shell* shell_; | 36 Shell* shell_; |
| 42 | 37 |
| 43 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); | 38 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); |
| 44 }; | 39 }; |
| 45 | 40 |
| 46 class HTMLViewer : public ApplicationDelegate { | 41 class HTMLViewer : public ApplicationDelegate { |
| 47 public: | 42 public: |
| 48 HTMLViewer() {} | 43 HTMLViewer() {} |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 | 66 |
| 72 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); | 67 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); |
| 73 }; | 68 }; |
| 74 | 69 |
| 75 } // namespace mojo | 70 } // namespace mojo |
| 76 | 71 |
| 77 MojoResult MojoMain(MojoHandle shell_handle) { | 72 MojoResult MojoMain(MojoHandle shell_handle) { |
| 78 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer); | 73 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer); |
| 79 return runner.Run(shell_handle); | 74 return runner.Run(shell_handle); |
| 80 } | 75 } |
| OLD | NEW |