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_app_delegate.h"
7 #include "content/public/browser/web_contents.h"
8 #include "extensions/common/constants.h"
9 #include "extensions/shell/browser/media_capture_util.h"
10 #include "extensions/shell/browser/shell_extension_web_contents_observer.h"
12 namespace extensions
{
14 ShellAppDelegate::ShellAppDelegate() {
17 ShellAppDelegate::~ShellAppDelegate() {
20 void ShellAppDelegate::InitWebContents(content::WebContents
* web_contents
) {
21 ShellExtensionWebContentsObserver::CreateForWebContents(web_contents
);
24 void ShellAppDelegate::RenderViewCreated(
25 content::RenderViewHost
* render_view_host
) {
26 // The views implementation of AppWindow takes focus via SetInitialFocus()
27 // and views::WebView but app_shell is aura-only and must do it manually.
28 content::WebContents::FromRenderViewHost(render_view_host
)->Focus();
31 void ShellAppDelegate::ResizeWebContents(content::WebContents
* web_contents
,
32 const gfx::Size
& size
) {
36 content::WebContents
* ShellAppDelegate::OpenURLFromTab(
37 content::BrowserContext
* context
,
38 content::WebContents
* source
,
39 const content::OpenURLParams
& params
) {
44 void ShellAppDelegate::AddNewContents(content::BrowserContext
* context
,
45 content::WebContents
* new_contents
,
46 WindowOpenDisposition disposition
,
47 const gfx::Rect
& initial_rect
,
53 content::ColorChooser
* ShellAppDelegate::ShowColorChooser(
54 content::WebContents
* web_contents
,
55 SkColor initial_color
) {
60 void ShellAppDelegate::RunFileChooser(
61 content::WebContents
* tab
,
62 const content::FileChooserParams
& params
) {
66 void ShellAppDelegate::RequestMediaAccessPermission(
67 content::WebContents
* web_contents
,
68 const content::MediaStreamRequest
& request
,
69 const content::MediaResponseCallback
& callback
,
70 const extensions::Extension
* extension
) {
71 media_capture_util::GrantMediaStreamRequest(
72 web_contents
, request
, callback
, extension
);
75 bool ShellAppDelegate::CheckMediaAccessPermission(
76 content::WebContents
* web_contents
,
77 const GURL
& security_origin
,
78 content::MediaStreamType type
,
79 const Extension
* extension
) {
80 media_capture_util::VerifyMediaAccessPermission(type
, extension
);
84 int ShellAppDelegate::PreferredIconSize() {
85 return extension_misc::EXTENSION_ICON_SMALL
;
88 void ShellAppDelegate::SetWebContentsBlocked(
89 content::WebContents
* web_contents
,
94 bool ShellAppDelegate::IsWebContentsVisible(
95 content::WebContents
* web_contents
) {
99 void ShellAppDelegate::SetTerminatingCallback(const base::Closure
& callback
) {
100 // TODO(jamescook): Should app_shell continue to close the app window
101 // manually or should it use a browser termination callback like Chrome?
104 } // namespace extensions