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 "chrome/browser/extensions/chrome_mojo_service_registration.h" | 5 #include "chrome/browser/extensions/chrome_mojo_service_registration.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "content/public/browser/render_frame_host.h" | 11 #include "content/public/browser/render_frame_host.h" |
12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
13 #include "content/public/common/service_registry.h" | 13 #include "content/public/common/service_registry.h" |
14 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
15 #include "extensions/common/permissions/api_permission.h" | 15 #include "extensions/common/permissions/api_permission.h" |
16 #include "extensions/common/permissions/permissions_data.h" | 16 #include "extensions/common/permissions/permissions_data.h" |
17 #include "extensions/common/switches.h" | 17 #include "extensions/common/switches.h" |
18 | 18 |
19 #if defined(ENABLE_MEDIA_ROUTER) | 19 #if defined(ENABLE_MEDIA_ROUTER) |
20 #include "chrome/browser/media/router/media_router_mojo_impl.h" | 20 #include "chrome/browser/media/router/media_router_mojo_impl.h" |
21 #endif | 21 #endif |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
25 void RegisterChromeServicesForFrame(content::RenderFrameHost* render_frame_host, | 25 void RegisterChromeServicesForFrame(content::RenderFrameHost* render_frame_host, |
26 const Extension* extension) { | 26 const Extension* extension) { |
27 DCHECK(render_frame_host); | 27 DCHECK(render_frame_host); |
28 DCHECK(extension); | 28 DCHECK(extension); |
29 | 29 |
30 content::ServiceRegistry* service_registry = | |
31 render_frame_host->GetServiceRegistry(); | |
32 | |
33 #if defined(ENABLE_MEDIA_ROUTER) | 30 #if defined(ENABLE_MEDIA_ROUTER) |
34 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 31 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
35 ::switches::kEnableMediaRouter)) { | 32 ::switches::kEnableMediaRouter)) { |
36 if (extension->permissions_data()->HasAPIPermission( | 33 if (extension->permissions_data()->HasAPIPermission( |
37 APIPermission::kMediaRouterPrivate)) { | 34 APIPermission::kMediaRouterPrivate)) { |
38 service_registry->AddService(base::Bind( | 35 render_frame_host->GetServiceRegistry()->AddService(base::Bind( |
39 media_router::MediaRouterMojoImpl::BindToRequest, extension->id(), | 36 media_router::MediaRouterMojoImpl::BindToRequest, extension->id(), |
40 render_frame_host->GetProcess()->GetBrowserContext())); | 37 render_frame_host->GetProcess()->GetBrowserContext())); |
41 } | 38 } |
42 } | 39 } |
43 #endif // defined(ENABLE_MEDIA_ROUTER) | 40 #endif // defined(ENABLE_MEDIA_ROUTER) |
44 } | 41 } |
45 | 42 |
46 } // namespace extensions | 43 } // namespace extensions |
OLD | NEW |