Home | History | Annotate | Download | only in apps
      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 #ifndef CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_
      6 #define CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_
      7 
      8 #include "base/callback.h"
      9 #include "base/memory/scoped_ptr.h"
     10 #include "content/public/browser/notification_observer.h"
     11 #include "content/public/browser/notification_registrar.h"
     12 #include "extensions/browser/app_window/app_delegate.h"
     13 #include "ui/base/window_open_disposition.h"
     14 #include "ui/gfx/rect.h"
     15 
     16 namespace content {
     17 class BrowserContext;
     18 class WebContents;
     19 }
     20 
     21 class ScopedKeepAlive;
     22 
     23 class ChromeAppDelegate : public extensions::AppDelegate,
     24                           public content::NotificationObserver {
     25  public:
     26   // Pass a ScopedKeepAlive to prevent the browser process from shutting down
     27   // while this object exists.
     28   explicit ChromeAppDelegate(scoped_ptr<ScopedKeepAlive> keep_alive);
     29   virtual ~ChromeAppDelegate();
     30 
     31   static void DisableExternalOpenForTesting();
     32 
     33  private:
     34   class NewWindowContentsDelegate;
     35 
     36   // extensions::AppDelegate:
     37   virtual void InitWebContents(content::WebContents* web_contents) OVERRIDE;
     38   virtual void ResizeWebContents(content::WebContents* web_contents,
     39                                  const gfx::Size& size) OVERRIDE;
     40   virtual content::WebContents* OpenURLFromTab(
     41       content::BrowserContext* context,
     42       content::WebContents* source,
     43       const content::OpenURLParams& params) OVERRIDE;
     44   virtual void AddNewContents(content::BrowserContext* context,
     45                               content::WebContents* new_contents,
     46                               WindowOpenDisposition disposition,
     47                               const gfx::Rect& initial_pos,
     48                               bool user_gesture,
     49                               bool* was_blocked) OVERRIDE;
     50   virtual content::ColorChooser* ShowColorChooser(
     51       content::WebContents* web_contents,
     52       SkColor initial_color) OVERRIDE;
     53   virtual void RunFileChooser(
     54       content::WebContents* tab,
     55       const content::FileChooserParams& params) OVERRIDE;
     56   virtual void RequestMediaAccessPermission(
     57       content::WebContents* web_contents,
     58       const content::MediaStreamRequest& request,
     59       const content::MediaResponseCallback& callback,
     60       const extensions::Extension* extension) OVERRIDE;
     61   virtual bool CheckMediaAccessPermission(
     62       content::WebContents* web_contents,
     63       const GURL& security_origin,
     64       content::MediaStreamType type,
     65       const extensions::Extension* extension) OVERRIDE;
     66   virtual int PreferredIconSize() OVERRIDE;
     67   virtual void SetWebContentsBlocked(content::WebContents* web_contents,
     68                                      bool blocked) OVERRIDE;
     69   virtual bool IsWebContentsVisible(
     70       content::WebContents* web_contents) OVERRIDE;
     71   virtual void SetTerminatingCallback(const base::Closure& callback) OVERRIDE;
     72 
     73   // content::NotificationObserver:
     74   virtual void Observe(int type,
     75                        const content::NotificationSource& source,
     76                        const content::NotificationDetails& details) OVERRIDE;
     77 
     78   scoped_ptr<ScopedKeepAlive> keep_alive_;
     79   scoped_ptr<NewWindowContentsDelegate> new_window_contents_delegate_;
     80   base::Closure terminating_callback_;
     81   content::NotificationRegistrar registrar_;
     82 
     83   DISALLOW_COPY_AND_ASSIGN(ChromeAppDelegate);
     84 };
     85 
     86 #endif  // CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_
     87