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) | 23 explicit ContentHandlerImpl(Shell* shell) |
25 : shell_(shell) { | 24 : shell_(shell) { |
26 } | 25 } |
27 virtual ~ContentHandlerImpl() {} | 26 virtual ~ContentHandlerImpl() {} |
28 | 27 |
29 private: | 28 private: |
30 // Overridden from ContentHandler: | 29 // Overridden from ContentHandler: |
31 virtual void OnConnect( | 30 virtual void OnConnect( |
32 const mojo::String& url, | 31 const mojo::String& url, |
33 URLResponsePtr response, | 32 URLResponsePtr response, |
34 InterfaceRequest<ServiceProvider> service_provider) OVERRIDE { | 33 InterfaceRequest<ServiceProvider> service_provider_request) OVERRIDE { |
35 ServiceProviderImpl* exported_services = new ServiceProviderImpl(); | 34 new HTMLDocumentView( |
36 BindToRequest(exported_services, &service_provider); | 35 response.Pass(), service_provider_request.Pass(), shell_); |
37 scoped_ptr<ServiceProvider> remote( | |
38 exported_services->CreateRemoteServiceProvider()); | |
39 new HTMLDocumentView(response.Pass(), remote.Pass(), exported_services, | |
40 shell_); | |
41 } | 36 } |
42 | 37 |
43 Shell* shell_; | 38 Shell* shell_; |
44 | 39 |
45 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); | 40 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); |
46 }; | 41 }; |
47 | 42 |
48 class HTMLViewer : public ApplicationDelegate { | 43 class HTMLViewer : public ApplicationDelegate { |
49 public: | 44 public: |
50 HTMLViewer() { | 45 HTMLViewer() { |
(...skipping 25 matching lines...) Expand all Loading... |
76 | 71 |
77 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); | 72 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); |
78 }; | 73 }; |
79 | 74 |
80 } // namespace mojo | 75 } // namespace mojo |
81 | 76 |
82 MojoResult MojoMain(MojoHandle shell_handle) { | 77 MojoResult MojoMain(MojoHandle shell_handle) { |
83 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer); | 78 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer); |
84 return runner.Run(shell_handle); | 79 return runner.Run(shell_handle); |
85 } | 80 } |
OLD | NEW |