OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/ui/content_viewer_app.h" | 5 #include "mojo/ui/content_viewer_app.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 10 #include "mojo/ui/view_provider_app.h" |
9 | 11 |
10 namespace mojo { | 12 namespace mojo { |
11 namespace ui { | 13 namespace ui { |
12 | 14 |
13 class ContentViewerApp::DelegatingContentHandler : public mojo::ContentHandler { | 15 class ContentViewerApp::DelegatingContentHandler : public mojo::ContentHandler { |
14 public: | 16 public: |
15 DelegatingContentHandler(ContentViewerApp* app, | 17 DelegatingContentHandler(ContentViewerApp* app, |
16 const std::string& content_handler_url) | 18 const std::string& content_handler_url) |
17 : app_(app), content_handler_url_(content_handler_url) {} | 19 : app_(app), content_handler_url_(content_handler_url) {} |
18 | 20 |
(...skipping 11 matching lines...) Expand all Loading... |
30 ContentViewerApp* app_; | 32 ContentViewerApp* app_; |
31 std::string content_handler_url_; | 33 std::string content_handler_url_; |
32 | 34 |
33 MOJO_DISALLOW_COPY_AND_ASSIGN(DelegatingContentHandler); | 35 MOJO_DISALLOW_COPY_AND_ASSIGN(DelegatingContentHandler); |
34 }; | 36 }; |
35 | 37 |
36 ContentViewerApp::ContentViewerApp() {} | 38 ContentViewerApp::ContentViewerApp() {} |
37 | 39 |
38 ContentViewerApp::~ContentViewerApp() {} | 40 ContentViewerApp::~ContentViewerApp() {} |
39 | 41 |
40 void ContentViewerApp::Initialize(mojo::ApplicationImpl* app_impl) { | 42 void ContentViewerApp::OnInitialize() { |
41 app_impl_ = app_impl; | |
42 | |
43 auto command_line = base::CommandLine::ForCurrentProcess(); | 43 auto command_line = base::CommandLine::ForCurrentProcess(); |
44 command_line->InitFromArgv(app_impl_->args()); | 44 command_line->InitFromArgv(args()); |
45 logging::LoggingSettings settings; | 45 logging::LoggingSettings settings; |
46 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 46 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
47 logging::InitLogging(settings); | 47 logging::InitLogging(settings); |
48 } | 48 } |
49 | 49 |
50 bool ContentViewerApp::ConfigureIncomingConnection( | 50 bool ContentViewerApp::OnAcceptConnection( |
51 ServiceProviderImpl* service_provider_impl) { | 51 ServiceProviderImpl* service_provider_impl) { |
52 service_provider_impl->AddService<ContentHandler>([this]( | 52 service_provider_impl->AddService<ContentHandler>([this]( |
53 const ConnectionContext& connection_context, | 53 const ConnectionContext& connection_context, |
54 InterfaceRequest<ContentHandler> content_handler_request) { | 54 InterfaceRequest<ContentHandler> content_handler_request) { |
55 bindings_.AddBinding( | 55 bindings_.AddBinding( |
56 new DelegatingContentHandler(this, connection_context.connection_url), | 56 new DelegatingContentHandler(this, connection_context.connection_url), |
57 content_handler_request.Pass()); | 57 content_handler_request.Pass()); |
58 }); | 58 }); |
59 return true; | 59 return true; |
60 } | 60 } |
61 | 61 |
62 void ContentViewerApp::StartViewer( | 62 void ContentViewerApp::StartViewer( |
63 const std::string& content_handler_url, | 63 const std::string& content_handler_url, |
64 mojo::InterfaceRequest<mojo::Application> application_request, | 64 mojo::InterfaceRequest<mojo::Application> application_request, |
65 mojo::URLResponsePtr response) { | 65 mojo::URLResponsePtr response) { |
| 66 // TODO(vtl): This is usually leaky, since |*app| (the returned |
| 67 // |ApplicationImplBase|/|ViewProviderApp| implementation) typically doesn't |
| 68 // own itself. Probably |LoadContent()| should take the |application_request|, |
| 69 // and not return anything. This method doesn't really appear to add anything. |
66 ViewProviderApp* app = LoadContent(content_handler_url, response.Pass()); | 70 ViewProviderApp* app = LoadContent(content_handler_url, response.Pass()); |
67 if (app) { | 71 if (app) |
68 // TODO(vtl): This is leaky, since |ApplicationImpl| doesn't own itself. | 72 app->Bind(application_request.Pass()); |
69 // (Also, who owns |*app|?) | |
70 new mojo::ApplicationImpl(app, application_request.Pass()); | |
71 } | |
72 } | 73 } |
73 | 74 |
74 } // namespace ui | 75 } // namespace ui |
75 } // namespace mojo | 76 } // namespace mojo |
OLD | NEW |