Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / chrome_mojo_service_registration.cc
blobdc6651b0242b06ed490aa02ab8e82d62e59562c9
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 "chrome/browser/extensions/chrome_mojo_service_registration.h"
7 #include "base/bind.h"
8 #include "base/command_line.h"
9 #include "base/logging.h"
10 #include "chrome/common/chrome_switches.h"
11 #include "content/public/browser/render_frame_host.h"
12 #include "content/public/browser/render_process_host.h"
13 #include "content/public/common/service_registry.h"
14 #include "extensions/common/extension.h"
15 #include "extensions/common/permissions/api_permission.h"
16 #include "extensions/common/permissions/permissions_data.h"
17 #include "extensions/common/switches.h"
19 #if defined(ENABLE_MEDIA_ROUTER)
20 #include "chrome/browser/media/router/media_router_mojo_impl.h"
21 #endif
23 namespace extensions {
25 void RegisterChromeServicesForFrame(content::RenderFrameHost* render_frame_host,
26 const Extension* extension) {
27 DCHECK(render_frame_host);
28 DCHECK(extension);
30 #if defined(ENABLE_MEDIA_ROUTER)
31 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
32 ::switches::kEnableMediaRouter)) {
33 if (extension->permissions_data()->HasAPIPermission(
34 APIPermission::kMediaRouterPrivate)) {
35 render_frame_host->GetServiceRegistry()->AddService(base::Bind(
36 media_router::MediaRouterMojoImpl::BindToRequest, extension->id(),
37 render_frame_host->GetProcess()->GetBrowserContext()));
40 #endif // defined(ENABLE_MEDIA_ROUTER)
43 } // namespace extensions