[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 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. |
| 4 | |
| 5 | #include "chrome/browser/extensions/chrome_extension_host_delegate.h" |
| 6 | |
[email protected] | 13e062e | 2014-08-09 10:21:55 | [diff] [blame] | 7 | #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 8 | #include "chrome/browser/extensions/extension_service.h" |
| 9 | #include "chrome/browser/extensions/extension_tab_util.h" |
| 10 | #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 11 | #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
oshima | f6539842 | 2014-11-18 23:30:42 | [diff] [blame^] | 12 | #include "components/app_modal/javascript_dialog_manager.h" |
[email protected] | 22401dc | 2014-03-21 01:38:57 | [diff] [blame] | 13 | #include "extensions/browser/extension_host.h" |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 14 | #include "extensions/browser/extension_system.h" |
| 15 | |
| 16 | namespace extensions { |
| 17 | |
| 18 | ChromeExtensionHostDelegate::ChromeExtensionHostDelegate() {} |
| 19 | |
| 20 | ChromeExtensionHostDelegate::~ChromeExtensionHostDelegate() {} |
| 21 | |
| 22 | void ChromeExtensionHostDelegate::OnExtensionHostCreated( |
| 23 | content::WebContents* web_contents) { |
[email protected] | 1ce1597 | 2014-03-20 19:25:48 | [diff] [blame] | 24 | ChromeExtensionWebContentsObserver::CreateForWebContents(web_contents); |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 25 | PrefsTabHelper::CreateForWebContents(web_contents); |
| 26 | } |
| 27 | |
| 28 | void ChromeExtensionHostDelegate::OnRenderViewCreatedForBackgroundPage( |
| 29 | ExtensionHost* host) { |
| 30 | ExtensionService* service = |
| 31 | ExtensionSystem::Get(host->browser_context())->extension_service(); |
| 32 | if (service) |
| 33 | service->DidCreateRenderViewForBackgroundPage(host); |
| 34 | } |
| 35 | |
| 36 | content::JavaScriptDialogManager* |
| 37 | ChromeExtensionHostDelegate::GetJavaScriptDialogManager() { |
| 38 | return GetJavaScriptDialogManagerInstance(); |
| 39 | } |
| 40 | |
| 41 | void ChromeExtensionHostDelegate::CreateTab(content::WebContents* web_contents, |
| 42 | const std::string& extension_id, |
| 43 | WindowOpenDisposition disposition, |
| 44 | const gfx::Rect& initial_pos, |
| 45 | bool user_gesture) { |
| 46 | ExtensionTabUtil::CreateTab( |
| 47 | web_contents, extension_id, disposition, initial_pos, user_gesture); |
| 48 | } |
| 49 | |
| 50 | void ChromeExtensionHostDelegate::ProcessMediaAccessRequest( |
| 51 | content::WebContents* web_contents, |
| 52 | const content::MediaStreamRequest& request, |
| 53 | const content::MediaResponseCallback& callback, |
| 54 | const Extension* extension) { |
| 55 | MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( |
| 56 | web_contents, request, callback, extension); |
| 57 | } |
| 58 | |
grunell | 657d4d8 | 2014-09-18 00:09:43 | [diff] [blame] | 59 | bool ChromeExtensionHostDelegate::CheckMediaAccessPermission( |
| 60 | content::WebContents* web_contents, |
| 61 | const GURL& security_origin, |
| 62 | content::MediaStreamType type, |
| 63 | const Extension* extension) { |
| 64 | return MediaCaptureDevicesDispatcher::GetInstance() |
| 65 | ->CheckMediaAccessPermission( |
| 66 | web_contents, security_origin, type, extension); |
| 67 | } |
| 68 | |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 69 | } // namespace extensions |