• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "athena/extensions/chrome/athena_chrome_app_delegate.h"
6 
7 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
8 #include "chrome/browser/favicon/favicon_tab_helper.h"
9 #include "chrome/browser/file_select_helper.h"
10 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
11 #include "chrome/browser/platform_util.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_dialogs.h"
14 #include "chrome/common/extensions/chrome_extension_messages.h"
15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents.h"
17 
18 #if defined(ENABLE_PRINTING)
19 #if defined(ENABLE_FULL_PRINTING)
20 #include "chrome/browser/printing/print_preview_message_handler.h"
21 #include "chrome/browser/printing/print_view_manager.h"
22 #else
23 #include "chrome/browser/printing/print_view_manager_basic.h"
24 #endif  // defined(ENABLE_FULL_PRINTING)
25 #endif  // defined(ENABLE_PRINTING)
26 
27 namespace athena {
28 
AthenaChromeAppDelegate()29 AthenaChromeAppDelegate::AthenaChromeAppDelegate() {
30 }
31 
~AthenaChromeAppDelegate()32 AthenaChromeAppDelegate::~AthenaChromeAppDelegate() {
33 }
34 
InitWebContents(content::WebContents * web_contents)35 void AthenaChromeAppDelegate::InitWebContents(
36     content::WebContents* web_contents) {
37   FaviconTabHelper::CreateForWebContents(web_contents);
38 
39 #if defined(ENABLE_PRINTING)
40 #if defined(ENABLE_FULL_PRINTING)
41   printing::PrintViewManager::CreateForWebContents(web_contents);
42   printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
43 #else
44   printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
45 #endif  // defined(ENABLE_FULL_PRINTING)
46 #endif  // defined(ENABLE_PRINTING)
47   extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
48       web_contents);
49 }
50 
ShowColorChooser(content::WebContents * web_contents,SkColor initial_color)51 content::ColorChooser* AthenaChromeAppDelegate::ShowColorChooser(
52     content::WebContents* web_contents,
53     SkColor initial_color) {
54   return chrome::ShowColorChooser(web_contents, initial_color);
55 }
56 
RunFileChooser(content::WebContents * tab,const content::FileChooserParams & params)57 void AthenaChromeAppDelegate::RunFileChooser(
58     content::WebContents* tab,
59     const content::FileChooserParams& params) {
60   FileSelectHelper::RunFileChooser(tab, params);
61 }
62 
RequestMediaAccessPermission(content::WebContents * web_contents,const content::MediaStreamRequest & request,const content::MediaResponseCallback & callback,const extensions::Extension * extension)63 void AthenaChromeAppDelegate::RequestMediaAccessPermission(
64     content::WebContents* web_contents,
65     const content::MediaStreamRequest& request,
66     const content::MediaResponseCallback& callback,
67     const extensions::Extension* extension) {
68   MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
69       web_contents, request, callback, extension);
70 }
71 
CheckMediaAccessPermission(content::WebContents * web_contents,const GURL & security_origin,content::MediaStreamType type,const extensions::Extension * extension)72 bool AthenaChromeAppDelegate::CheckMediaAccessPermission(
73     content::WebContents* web_contents,
74     const GURL& security_origin,
75     content::MediaStreamType type,
76     const extensions::Extension* extension) {
77   return MediaCaptureDevicesDispatcher::GetInstance()
78       ->CheckMediaAccessPermission(
79           web_contents, security_origin, type, extension);
80 }
81 
SetWebContentsBlocked(content::WebContents * web_contents,bool blocked)82 void AthenaChromeAppDelegate::SetWebContentsBlocked(
83     content::WebContents* web_contents,
84     bool blocked) {
85   // RenderViewHost may be NULL during shutdown.
86   content::RenderViewHost* host = web_contents->GetRenderViewHost();
87   if (host) {
88     host->Send(new ChromeViewMsg_SetVisuallyDeemphasized(host->GetRoutingID(),
89                                                          blocked));
90   }
91 }
92 
93 }  // namespace athena
94