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
3 // found in the LICENSE file.
5 #include "components/devtools_service/devtools_service_delegate.h"
7 #include "base/logging.h"
8 #include "components/devtools_service/devtools_service.h"
9 #include "mojo/application/public/cpp/application_connection.h"
10 #include "mojo/application/public/cpp/application_impl.h"
11 #include "mojo/common/url_type_converters.h"
14 namespace devtools_service
{
18 bool IsShell(const GURL
& requestor_url
) {
19 // TODO(yzshen): http://crbug.com/491656 "mojo://shell/" has to be used
20 // instead of "mojo:shell" because "mojo" is not treated as a standard scheme.
21 return requestor_url
== GURL("mojo://shell/");
26 DevToolsServiceDelegate::DevToolsServiceDelegate() {
29 DevToolsServiceDelegate::~DevToolsServiceDelegate() {
32 void DevToolsServiceDelegate::Initialize(mojo::ApplicationImpl
* app
) {
33 service_
.reset(new DevToolsService(app
));
36 bool DevToolsServiceDelegate::ConfigureIncomingConnection(
37 mojo::ApplicationConnection
* connection
) {
38 connection
->AddService
<DevToolsRegistry
>(this);
40 // DevToolsCoordinator is a privileged interface and only allowed for the
42 if (IsShell(GURL(connection
->GetRemoteApplicationURL())))
43 connection
->AddService
<DevToolsCoordinator
>(this);
47 void DevToolsServiceDelegate::Quit() {
51 void DevToolsServiceDelegate::Create(
52 mojo::ApplicationConnection
* connection
,
53 mojo::InterfaceRequest
<DevToolsRegistry
> request
) {
54 service_
->BindToRegistryRequest(request
.Pass());
57 void DevToolsServiceDelegate::Create(
58 mojo::ApplicationConnection
* connection
,
59 mojo::InterfaceRequest
<DevToolsCoordinator
> request
) {
60 service_
->BindToCoordinatorRequest(request
.Pass());
63 } // namespace devtools_service