| 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 "extensions/browser/mojo/service_registration.h" | 5 #include "extensions/browser/mojo/service_registration.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.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/browser/site_instance.h" | 13 #include "content/public/browser/site_instance.h" |
| 14 #include "extensions/browser/extension_registry.h" | 14 #include "extensions/browser/extension_registry.h" |
| 15 #include "extensions/browser/extensions_browser_client.h" | 15 #include "extensions/browser/extensions_browser_client.h" |
| 16 #include "extensions/browser/mojo/keep_alive_impl.h" | 16 #include "extensions/browser/mojo/keep_alive_impl.h" |
| 17 #include "extensions/browser/process_map.h" | 17 #include "extensions/browser/process_map.h" |
| 18 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
| 19 #include "extensions/common/extension_api.h" | 19 #include "extensions/common/extension_api.h" |
| 20 #include "extensions/common/switches.h" | 20 #include "extensions/common/switches.h" |
| 21 #include "extensions/features/features.h" | 21 #include "extensions/features/features.h" |
| 22 #include "services/service_manager/public/cpp/interface_registry.h" | 22 #include "services/service_manager/public/cpp/binder_registry.h" |
| 23 | 23 |
| 24 #if BUILDFLAG(ENABLE_WIFI_DISPLAY) | 24 #if BUILDFLAG(ENABLE_WIFI_DISPLAY) |
| 25 #include "extensions/browser/api/display_source/wifi_display/wifi_display_media_
service_impl.h" | 25 #include "extensions/browser/api/display_source/wifi_display/wifi_display_media_
service_impl.h" |
| 26 #include "extensions/browser/api/display_source/wifi_display/wifi_display_sessio
n_service_impl.h" | 26 #include "extensions/browser/api/display_source/wifi_display/wifi_display_sessio
n_service_impl.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace extensions { | 29 namespace extensions { |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 #if BUILDFLAG(ENABLE_WIFI_DISPLAY) | 32 #if BUILDFLAG(ENABLE_WIFI_DISPLAY) |
| 33 bool ExtensionHasPermission(const Extension* extension, | 33 bool ExtensionHasPermission(const Extension* extension, |
| 34 content::RenderProcessHost* render_process_host, | 34 content::RenderProcessHost* render_process_host, |
| 35 const std::string& permission_name) { | 35 const std::string& permission_name) { |
| 36 Feature::Context context = | 36 Feature::Context context = |
| 37 ProcessMap::Get(render_process_host->GetBrowserContext()) | 37 ProcessMap::Get(render_process_host->GetBrowserContext()) |
| 38 ->GetMostLikelyContextType(extension, render_process_host->GetID()); | 38 ->GetMostLikelyContextType(extension, render_process_host->GetID()); |
| 39 | 39 |
| 40 return ExtensionAPI::GetSharedInstance() | 40 return ExtensionAPI::GetSharedInstance() |
| 41 ->IsAvailable(permission_name, extension, context, extension->url()) | 41 ->IsAvailable(permission_name, extension, context, extension->url()) |
| 42 .is_available(); | 42 .is_available(); |
| 43 } | 43 } |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 void RegisterServicesForFrame(content::RenderFrameHost* render_frame_host, | 48 void RegisterServicesForFrame(content::RenderFrameHost* render_frame_host, |
| 49 const Extension* extension) { | 49 const Extension* extension) { |
| 50 DCHECK(extension); | 50 DCHECK(extension); |
| 51 | 51 |
| 52 service_manager::InterfaceRegistry* registry = | 52 service_manager::BinderRegistry* registry = |
| 53 render_frame_host->GetInterfaceRegistry(); | 53 render_frame_host->GetInterfaceRegistry(); |
| 54 registry->AddInterface(base::Bind( | 54 registry->AddInterface(base::Bind( |
| 55 KeepAliveImpl::Create, | 55 KeepAliveImpl::Create, |
| 56 render_frame_host->GetProcess()->GetBrowserContext(), extension)); | 56 render_frame_host->GetProcess()->GetBrowserContext(), extension)); |
| 57 | 57 |
| 58 #if BUILDFLAG(ENABLE_WIFI_DISPLAY) | 58 #if BUILDFLAG(ENABLE_WIFI_DISPLAY) |
| 59 if (ExtensionHasPermission(extension, render_frame_host->GetProcess(), | 59 if (ExtensionHasPermission(extension, render_frame_host->GetProcess(), |
| 60 "displaySource")) { | 60 "displaySource")) { |
| 61 registry->AddInterface( | 61 registry->AddInterface( |
| 62 base::Bind(WiFiDisplaySessionServiceImpl::BindToRequest, | 62 base::Bind(WiFiDisplaySessionServiceImpl::BindToRequest, |
| 63 render_frame_host->GetProcess()->GetBrowserContext())); | 63 render_frame_host->GetProcess()->GetBrowserContext())); |
| 64 registry->AddInterface( | 64 registry->AddInterface( |
| 65 base::Bind(WiFiDisplayMediaServiceImpl::BindToRequest)); | 65 base::Bind(WiFiDisplayMediaServiceImpl::BindToRequest)); |
| 66 } | 66 } |
| 67 #endif | 67 #endif |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace extensions | 70 } // namespace extensions |
| OLD | NEW |