[AndroidWebViewShell] Replace rebaseline script with a new version using test_runner.py
[chromium-blink-merge.git] / components / devtools_service / devtools_service_delegate.cc
blob137d06d24435337872b68823f411139733f76c70
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_registry_impl.h"
9 #include "components/devtools_service/devtools_service.h"
10 #include "mojo/application/public/cpp/application_connection.h"
11 #include "mojo/application/public/cpp/application_impl.h"
12 #include "mojo/common/url_type_converters.h"
13 #include "url/gurl.h"
15 namespace devtools_service {
17 namespace {
19 bool IsShell(const GURL& requestor_url) {
20 // TODO(yzshen): http://crbug.com/491656 "mojo://shell/" has to be used
21 // instead of "mojo:shell" because "mojo" is not treated as a standard scheme.
22 return requestor_url == GURL("mojo://shell/");
25 } // namespace
27 DevToolsServiceDelegate::DevToolsServiceDelegate() {
30 DevToolsServiceDelegate::~DevToolsServiceDelegate() {
33 void DevToolsServiceDelegate::Initialize(mojo::ApplicationImpl* app) {
34 service_.reset(new DevToolsService(app));
37 bool DevToolsServiceDelegate::ConfigureIncomingConnection(
38 mojo::ApplicationConnection* connection) {
39 connection->AddService<DevToolsRegistry>(this);
41 // DevToolsCoordinator is a privileged interface and only allowed for the
42 // shell.
43 if (IsShell(GURL(connection->GetRemoteApplicationURL())))
44 connection->AddService<DevToolsCoordinator>(this);
45 return true;
48 void DevToolsServiceDelegate::Quit() {
49 service_.reset();
52 void DevToolsServiceDelegate::Create(
53 mojo::ApplicationConnection* connection,
54 mojo::InterfaceRequest<DevToolsRegistry> request) {
55 if (service_->IsInitialized())
56 service_->registry()->BindToRegistryRequest(request.Pass());
59 void DevToolsServiceDelegate::Create(
60 mojo::ApplicationConnection* connection,
61 mojo::InterfaceRequest<DevToolsCoordinator> request) {
62 service_->BindToCoordinatorRequest(request.Pass());
65 } // namespace devtools_service