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 "components/devtools_service/devtools_service_delegate.h" | 5 #include "components/devtools_service/devtools_service_delegate.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "components/devtools_service/devtools_registry_impl.h" | 10 #include "components/devtools_service/devtools_registry_impl.h" |
11 #include "components/devtools_service/devtools_service.h" | 11 #include "components/devtools_service/devtools_service.h" |
12 #include "mojo/common/url_type_converters.h" | 12 #include "mojo/common/url_type_converters.h" |
13 #include "mojo/shell/public/cpp/application_connection.h" | 13 #include "mojo/shell/public/cpp/application_connection.h" |
14 #include "mojo/shell/public/cpp/application_impl.h" | 14 #include "mojo/shell/public/cpp/shell.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 namespace devtools_service { | 17 namespace devtools_service { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 bool IsShell(const GURL& requestor_url) { | 21 bool IsShell(const GURL& requestor_url) { |
22 // TODO(yzshen): http://crbug.com/491656 "mojo://shell/" has to be used | 22 // TODO(yzshen): http://crbug.com/491656 "mojo://shell/" has to be used |
23 // instead of "mojo:shell" because "mojo" is not treated as a standard scheme. | 23 // instead of "mojo:shell" because "mojo" is not treated as a standard scheme. |
24 return requestor_url == GURL("mojo://shell/"); | 24 return requestor_url == GURL("mojo://shell/"); |
25 } | 25 } |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 DevToolsServiceDelegate::DevToolsServiceDelegate() { | 29 DevToolsServiceDelegate::DevToolsServiceDelegate() { |
30 } | 30 } |
31 | 31 |
32 DevToolsServiceDelegate::~DevToolsServiceDelegate() { | 32 DevToolsServiceDelegate::~DevToolsServiceDelegate() { |
33 } | 33 } |
34 | 34 |
35 void DevToolsServiceDelegate::Initialize(mojo::ApplicationImpl* app) { | 35 void DevToolsServiceDelegate::Initialize(mojo::Shell* shell, |
36 service_.reset(new DevToolsService(app)); | 36 const std::string& url, |
| 37 uint32_t id) { |
| 38 service_.reset(new DevToolsService(shell)); |
37 } | 39 } |
38 | 40 |
39 bool DevToolsServiceDelegate::AcceptConnection( | 41 bool DevToolsServiceDelegate::AcceptConnection( |
40 mojo::ApplicationConnection* connection) { | 42 mojo::ApplicationConnection* connection) { |
41 connection->AddService<DevToolsRegistry>(this); | 43 connection->AddService<DevToolsRegistry>(this); |
42 | 44 |
43 // DevToolsCoordinator is a privileged interface and only allowed for the | 45 // DevToolsCoordinator is a privileged interface and only allowed for the |
44 // shell. | 46 // shell. |
45 if (IsShell(GURL(connection->GetRemoteApplicationURL()))) | 47 if (IsShell(GURL(connection->GetRemoteApplicationURL()))) |
46 connection->AddService<DevToolsCoordinator>(this); | 48 connection->AddService<DevToolsCoordinator>(this); |
(...skipping 10 matching lines...) Expand all Loading... |
57 service_->registry()->BindToRegistryRequest(std::move(request)); | 59 service_->registry()->BindToRegistryRequest(std::move(request)); |
58 } | 60 } |
59 | 61 |
60 void DevToolsServiceDelegate::Create( | 62 void DevToolsServiceDelegate::Create( |
61 mojo::ApplicationConnection* connection, | 63 mojo::ApplicationConnection* connection, |
62 mojo::InterfaceRequest<DevToolsCoordinator> request) { | 64 mojo::InterfaceRequest<DevToolsCoordinator> request) { |
63 service_->BindToCoordinatorRequest(std::move(request)); | 65 service_->BindToCoordinatorRequest(std::move(request)); |
64 } | 66 } |
65 | 67 |
66 } // namespace devtools_service | 68 } // namespace devtools_service |
OLD | NEW |