Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: extensions/browser/mojo/service_registration.cc

Issue 2410743002: Remove the mojo serial interfaces and related infrastructure. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/browser/mojo/BUILD.gn ('k') | extensions/browser/mojo/stash_backend.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/api/serial/serial_service_factory.h"
15 #include "extensions/browser/extension_registry.h" 14 #include "extensions/browser/extension_registry.h"
16 #include "extensions/browser/extensions_browser_client.h" 15 #include "extensions/browser/extensions_browser_client.h"
17 #include "extensions/browser/mojo/keep_alive_impl.h" 16 #include "extensions/browser/mojo/keep_alive_impl.h"
18 #include "extensions/browser/process_map.h" 17 #include "extensions/browser/process_map.h"
19 #include "extensions/common/constants.h" 18 #include "extensions/common/constants.h"
20 #include "extensions/common/extension_api.h" 19 #include "extensions/common/extension_api.h"
21 #include "extensions/common/switches.h" 20 #include "extensions/common/switches.h"
22 #include "services/shell/public/cpp/interface_registry.h" 21 #include "services/shell/public/cpp/interface_registry.h"
23 22
24 #if defined(ENABLE_WIFI_DISPLAY) 23 #if defined(ENABLE_WIFI_DISPLAY)
25 #include "extensions/browser/api/display_source/wifi_display/wifi_display_media_ service_impl.h" 24 #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" 25 #include "extensions/browser/api/display_source/wifi_display/wifi_display_sessio n_service_impl.h"
27 #endif 26 #endif
28 27
29 namespace extensions { 28 namespace extensions {
30 namespace { 29 namespace {
31 30
31 #if defined(ENABLE_WIFI_DISPLAY)
32 bool ExtensionHasPermission(const Extension* extension, 32 bool ExtensionHasPermission(const Extension* extension,
33 content::RenderProcessHost* render_process_host, 33 content::RenderProcessHost* render_process_host,
34 const std::string& permission_name) { 34 const std::string& permission_name) {
35 Feature::Context context = 35 Feature::Context context =
36 ProcessMap::Get(render_process_host->GetBrowserContext()) 36 ProcessMap::Get(render_process_host->GetBrowserContext())
37 ->GetMostLikelyContextType(extension, render_process_host->GetID()); 37 ->GetMostLikelyContextType(extension, render_process_host->GetID());
38 38
39 return ExtensionAPI::GetSharedInstance() 39 return ExtensionAPI::GetSharedInstance()
40 ->IsAvailable(permission_name, extension, context, extension->url()) 40 ->IsAvailable(permission_name, extension, context, extension->url())
41 .is_available(); 41 .is_available();
42 } 42 }
43 #endif
43 44
44 } // namespace 45 } // namespace
45 46
46 void RegisterServicesForFrame(content::RenderFrameHost* render_frame_host, 47 void RegisterServicesForFrame(content::RenderFrameHost* render_frame_host,
47 const Extension* extension) { 48 const Extension* extension) {
48 DCHECK(extension); 49 DCHECK(extension);
49 50
50 shell::InterfaceRegistry* registry = 51 shell::InterfaceRegistry* registry =
51 render_frame_host->GetInterfaceRegistry(); 52 render_frame_host->GetInterfaceRegistry();
52 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
53 switches::kEnableMojoSerialService)) {
54 if (ExtensionHasPermission(extension, render_frame_host->GetProcess(),
55 "serial")) {
56 registry->AddInterface(base::Bind(&BindToSerialServiceRequest));
57 }
58 }
59 registry->AddInterface(base::Bind( 53 registry->AddInterface(base::Bind(
60 KeepAliveImpl::Create, 54 KeepAliveImpl::Create,
61 render_frame_host->GetProcess()->GetBrowserContext(), extension)); 55 render_frame_host->GetProcess()->GetBrowserContext(), extension));
62 56
63 #if defined(ENABLE_WIFI_DISPLAY) 57 #if defined(ENABLE_WIFI_DISPLAY)
64 if (ExtensionHasPermission(extension, render_frame_host->GetProcess(), 58 if (ExtensionHasPermission(extension, render_frame_host->GetProcess(),
65 "displaySource")) { 59 "displaySource")) {
66 registry->AddInterface( 60 registry->AddInterface(
67 base::Bind(WiFiDisplaySessionServiceImpl::BindToRequest, 61 base::Bind(WiFiDisplaySessionServiceImpl::BindToRequest,
68 render_frame_host->GetProcess()->GetBrowserContext())); 62 render_frame_host->GetProcess()->GetBrowserContext()));
69 registry->AddInterface( 63 registry->AddInterface(
70 base::Bind(WiFiDisplayMediaServiceImpl::BindToRequest)); 64 base::Bind(WiFiDisplayMediaServiceImpl::BindToRequest));
71 } 65 }
72 #endif 66 #endif
73 } 67 }
74 68
75 } // namespace extensions 69 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/mojo/BUILD.gn ('k') | extensions/browser/mojo/stash_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698