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 "extensions/shell/browser/shell_extension_host_delegate.h"
7 #include "base/lazy_instance.h"
8 #include "base/logging.h"
9 #include "extensions/browser/serial_extension_host_queue.h"
10 #include "extensions/shell/browser/media_capture_util.h"
11 #include "extensions/shell/browser/shell_extension_web_contents_observer.h"
13 namespace extensions
{
15 ShellExtensionHostDelegate::ShellExtensionHostDelegate() {
18 ShellExtensionHostDelegate::~ShellExtensionHostDelegate() {
21 void ShellExtensionHostDelegate::OnExtensionHostCreated(
22 content::WebContents
* web_contents
) {
23 ShellExtensionWebContentsObserver::CreateForWebContents(web_contents
);
26 void ShellExtensionHostDelegate::OnRenderViewCreatedForBackgroundPage(
27 ExtensionHost
* host
) {
30 content::JavaScriptDialogManager
*
31 ShellExtensionHostDelegate::GetJavaScriptDialogManager() {
32 // TODO(jamescook): Create a JavaScriptDialogManager or reuse the one from
38 void ShellExtensionHostDelegate::CreateTab(content::WebContents
* web_contents
,
39 const std::string
& extension_id
,
40 WindowOpenDisposition disposition
,
41 const gfx::Rect
& initial_rect
,
43 // TODO(jamescook): Should app_shell support opening popup windows?
47 void ShellExtensionHostDelegate::ProcessMediaAccessRequest(
48 content::WebContents
* web_contents
,
49 const content::MediaStreamRequest
& request
,
50 const content::MediaResponseCallback
& callback
,
51 const Extension
* extension
) {
52 // Allow access to the microphone and/or camera.
53 media_capture_util::GrantMediaStreamRequest(
54 web_contents
, request
, callback
, extension
);
57 bool ShellExtensionHostDelegate::CheckMediaAccessPermission(
58 content::WebContents
* web_contents
,
59 const GURL
& security_origin
,
60 content::MediaStreamType type
,
61 const Extension
* extension
) {
62 media_capture_util::VerifyMediaAccessPermission(type
, extension
);
66 static base::LazyInstance
<SerialExtensionHostQueue
> g_queue
=
67 LAZY_INSTANCE_INITIALIZER
;
69 ExtensionHostQueue
* ShellExtensionHostDelegate::GetExtensionHostQueue() const {
70 return g_queue
.Pointer();
73 } // namespace extensions