| 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 "content/public/common/service_registry.h" | 14 #include "content/public/common/service_registry.h" |
| 15 #include "extensions/browser/api/serial/serial_service_factory.h" | 15 #include "extensions/browser/api/serial/serial_service_factory.h" |
| 16 #include "extensions/browser/extension_registry.h" | 16 #include "extensions/browser/extension_registry.h" |
| 17 #include "extensions/browser/extensions_browser_client.h" | 17 #include "extensions/browser/extensions_browser_client.h" |
| 18 #include "extensions/browser/mojo/keep_alive_impl.h" | 18 #include "extensions/browser/mojo/keep_alive_impl.h" |
| 19 #include "extensions/browser/process_map.h" | 19 #include "extensions/browser/process_map.h" |
| 20 #include "extensions/common/constants.h" | 20 #include "extensions/common/constants.h" |
| 21 #include "extensions/common/extension_api.h" | 21 #include "extensions/common/extension_api.h" |
| 22 #include "extensions/common/switches.h" | 22 #include "extensions/common/switches.h" |
| 23 | 23 |
| 24 #if defined(ENABLE_WIFI_DISPLAY) |
| 25 #include "extensions/browser/api/display_source/wifi_display/wifi_display_sessio
n_service_impl.h" |
| 26 #endif |
| 27 |
| 24 namespace extensions { | 28 namespace extensions { |
| 25 namespace { | 29 namespace { |
| 26 | 30 |
| 27 bool ExtensionHasPermission(const Extension* extension, | 31 bool ExtensionHasPermission(const Extension* extension, |
| 28 content::RenderProcessHost* render_process_host, | 32 content::RenderProcessHost* render_process_host, |
| 29 const std::string& permission_name) { | 33 const std::string& permission_name) { |
| 30 Feature::Context context = | 34 Feature::Context context = |
| 31 ProcessMap::Get(render_process_host->GetBrowserContext()) | 35 ProcessMap::Get(render_process_host->GetBrowserContext()) |
| 32 ->GetMostLikelyContextType(extension, render_process_host->GetID()); | 36 ->GetMostLikelyContextType(extension, render_process_host->GetID()); |
| 33 | 37 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 47 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 51 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 48 switches::kEnableMojoSerialService)) { | 52 switches::kEnableMojoSerialService)) { |
| 49 if (ExtensionHasPermission(extension, render_frame_host->GetProcess(), | 53 if (ExtensionHasPermission(extension, render_frame_host->GetProcess(), |
| 50 "serial")) { | 54 "serial")) { |
| 51 service_registry->AddService(base::Bind(&BindToSerialServiceRequest)); | 55 service_registry->AddService(base::Bind(&BindToSerialServiceRequest)); |
| 52 } | 56 } |
| 53 } | 57 } |
| 54 service_registry->AddService(base::Bind( | 58 service_registry->AddService(base::Bind( |
| 55 KeepAliveImpl::Create, | 59 KeepAliveImpl::Create, |
| 56 render_frame_host->GetProcess()->GetBrowserContext(), extension)); | 60 render_frame_host->GetProcess()->GetBrowserContext(), extension)); |
| 61 |
| 62 #if defined(ENABLE_WIFI_DISPLAY) |
| 63 if (ExtensionHasPermission(extension, render_frame_host->GetProcess(), |
| 64 "displaySource")) { |
| 65 service_registry->AddService( |
| 66 base::Bind(WiFiDisplaySessionServiceImpl::BindToRequest, |
| 67 render_frame_host->GetProcess()->GetBrowserContext())); |
| 68 } |
| 69 #endif |
| 57 } | 70 } |
| 58 | 71 |
| 59 } // namespace extensions | 72 } // namespace extensions |
| OLD | NEW |