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 "sky/viewer/content_handler_impl.h" | 5 #include "sky/viewer/content_handler_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "mojo/public/cpp/application/connect.h" | 8 #include "mojo/public/cpp/application/connect.h" |
9 #include "mojo/public/cpp/bindings/strong_binding.h" | 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
10 #include "mojo/public/cpp/utility/run_loop.h" | 10 #include "mojo/public/cpp/utility/run_loop.h" |
11 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 11 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
12 #include "sky/viewer/document_view.h" | 12 #include "sky/viewer/document_view.h" |
13 | 13 |
14 namespace sky { | 14 namespace sky { |
15 | 15 |
16 class SkyApplication : public mojo::Application { | 16 class SkyApplication : public mojo::Application { |
17 public: | 17 public: |
18 SkyApplication(mojo::InterfaceRequest<mojo::Application> application, | 18 SkyApplication(mojo::InterfaceRequest<mojo::Application> application, |
19 mojo::URLResponsePtr response) | 19 mojo::URLResponsePtr response) |
20 : binding_(this, application.Pass()), | 20 : binding_(this, application.Pass()), |
21 initial_response_(response.Pass()) {} | 21 initial_response_(response.Pass()) {} |
22 | 22 |
23 void Initialize(mojo::ShellPtr shell, | 23 void Initialize(mojo::ShellPtr shell, |
24 mojo::Array<mojo::String> args, | 24 mojo::Array<mojo::String> args, |
25 const mojo::String& url) override { | 25 const mojo::String& url) override { |
26 shell_ = shell.Pass(); | 26 shell_ = shell.Pass(); |
27 mojo::ServiceProviderPtr service_provider; | 27 mojo::ServiceProviderPtr service_provider; |
28 shell_->ConnectToApplication("mojo:network_service", | 28 shell_->ConnectToApplication("mojo:authenticated_network_service", |
29 mojo::GetProxy(&service_provider), nullptr); | 29 mojo::GetProxy(&service_provider), nullptr); |
30 mojo::ConnectToService(service_provider.get(), &network_service_); | 30 mojo::ConnectToService(service_provider.get(), &network_service_); |
31 } | 31 } |
32 | 32 |
33 void AcceptConnection(const mojo::String& requestor_url, | 33 void AcceptConnection(const mojo::String& requestor_url, |
34 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 34 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
35 mojo::ServiceProviderPtr exposed_services, | 35 mojo::ServiceProviderPtr exposed_services, |
36 const mojo::String& url) override { | 36 const mojo::String& url) override { |
37 if (initial_response_) { | 37 if (initial_response_) { |
38 OnResponseReceived(mojo::URLLoaderPtr(), services.Pass(), | 38 OnResponseReceived(mojo::URLLoaderPtr(), services.Pass(), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 ContentHandlerImpl::~ContentHandlerImpl() { | 84 ContentHandlerImpl::~ContentHandlerImpl() { |
85 } | 85 } |
86 | 86 |
87 void ContentHandlerImpl::StartApplication( | 87 void ContentHandlerImpl::StartApplication( |
88 mojo::InterfaceRequest<mojo::Application> application, | 88 mojo::InterfaceRequest<mojo::Application> application, |
89 mojo::URLResponsePtr response) { | 89 mojo::URLResponsePtr response) { |
90 new SkyApplication(application.Pass(), response.Pass()); | 90 new SkyApplication(application.Pass(), response.Pass()); |
91 } | 91 } |
92 | 92 |
93 } // namespace sky | 93 } // namespace sky |
OLD | NEW |