Make the ChromeOS chromecast system tray integration use a private API.
[chromium-blink-merge.git] / chrome / browser / extensions / chrome_extension_host_delegate.cc
blob1a1de87ff7d6fd32c33e8ab8ed7b50f06c3dd6f9
1 // Copyright 2014 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_extension_host_delegate.h"
7 #include "base/lazy_instance.h"
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_tab_util.h"
11 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
12 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
13 #include "components/app_modal/javascript_dialog_manager.h"
14 #include "extensions/browser/extension_host.h"
15 #include "extensions/browser/extension_system.h"
16 #include "extensions/browser/load_monitoring_extension_host_queue.h"
17 #include "extensions/browser/serial_extension_host_queue.h"
19 namespace extensions {
21 namespace {
23 // Singleton for GetExtensionHostQueue().
24 struct QueueWrapper {
25 QueueWrapper() {
26 queue.reset(new LoadMonitoringExtensionHostQueue(
27 scoped_ptr<ExtensionHostQueue>(new SerialExtensionHostQueue())));
29 scoped_ptr<ExtensionHostQueue> queue;
31 base::LazyInstance<QueueWrapper> g_queue = LAZY_INSTANCE_INITIALIZER;
33 } // namespace
35 ChromeExtensionHostDelegate::ChromeExtensionHostDelegate() {}
37 ChromeExtensionHostDelegate::~ChromeExtensionHostDelegate() {}
39 void ChromeExtensionHostDelegate::OnExtensionHostCreated(
40 content::WebContents* web_contents) {
41 ChromeExtensionWebContentsObserver::CreateForWebContents(web_contents);
42 PrefsTabHelper::CreateForWebContents(web_contents);
45 void ChromeExtensionHostDelegate::OnRenderViewCreatedForBackgroundPage(
46 ExtensionHost* host) {
47 ExtensionService* service =
48 ExtensionSystem::Get(host->browser_context())->extension_service();
49 if (service)
50 service->DidCreateRenderViewForBackgroundPage(host);
53 content::JavaScriptDialogManager*
54 ChromeExtensionHostDelegate::GetJavaScriptDialogManager() {
55 return app_modal::JavaScriptDialogManager::GetInstance();
58 void ChromeExtensionHostDelegate::CreateTab(content::WebContents* web_contents,
59 const std::string& extension_id,
60 WindowOpenDisposition disposition,
61 const gfx::Rect& initial_rect,
62 bool user_gesture) {
63 ExtensionTabUtil::CreateTab(
64 web_contents, extension_id, disposition, initial_rect, user_gesture);
67 void ChromeExtensionHostDelegate::ProcessMediaAccessRequest(
68 content::WebContents* web_contents,
69 const content::MediaStreamRequest& request,
70 const content::MediaResponseCallback& callback,
71 const Extension* extension) {
72 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
73 web_contents, request, callback, extension);
76 bool ChromeExtensionHostDelegate::CheckMediaAccessPermission(
77 content::WebContents* web_contents,
78 const GURL& security_origin,
79 content::MediaStreamType type,
80 const Extension* extension) {
81 return MediaCaptureDevicesDispatcher::GetInstance()
82 ->CheckMediaAccessPermission(
83 web_contents, security_origin, type, extension);
86 ExtensionHostQueue* ChromeExtensionHostDelegate::GetExtensionHostQueue() const {
87 return g_queue.Get().queue.get();
90 } // namespace extensions