| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "ui/views/widget/widget_delegate.h" | 13 #include "ui/views/widget/widget_delegate.h" |
| 14 | 14 |
| 15 class Browser; | 15 class BaseWindow; |
| 16 class ExtensionDialogObserver; | 16 class ExtensionDialogObserver; |
| 17 class ExtensionHost; | 17 class ExtensionHost; |
| 18 class GURL; | 18 class GURL; |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 class WebContents; | 22 class WebContents; |
| 23 } | 23 } |
| 24 | 24 |
| 25 // Modal dialog containing contents provided by an extension. | 25 // Modal dialog containing contents provided by an extension. |
| 26 // Dialog is automatically centered in the browser window and has fixed size. | 26 // Dialog is automatically centered in the owning window and has fixed size. |
| 27 // For example, used by the Chrome OS file browser. | 27 // For example, used by the Chrome OS file browser. |
| 28 class ExtensionDialog : public views::WidgetDelegate, | 28 class ExtensionDialog : public views::WidgetDelegate, |
| 29 public content::NotificationObserver, | 29 public content::NotificationObserver, |
| 30 public base::RefCounted<ExtensionDialog> { | 30 public base::RefCounted<ExtensionDialog> { |
| 31 public: | 31 public: |
| 32 // Create and show a dialog with |url| centered over the browser window. | 32 // Create and show a dialog with |url| centered over the provided window. |
| 33 // |browser| is the browser to which the pop-up will be attached. | 33 // |base_window| is the window to which the pop-up will be attached. |
| 34 // |profile| is the profile that the extension is registered with. |
| 34 // |web_contents| is the tab that spawned the dialog. | 35 // |web_contents| is the tab that spawned the dialog. |
| 35 // |width| and |height| are the size of the dialog in pixels. | 36 // |width| and |height| are the size of the dialog in pixels. |
| 36 static ExtensionDialog* Show(const GURL& url, | 37 static ExtensionDialog* Show(const GURL& url, |
| 37 Browser* browser, | 38 BaseWindow* base_window, |
| 39 Profile* profile, |
| 38 content::WebContents* web_contents, | 40 content::WebContents* web_contents, |
| 39 int width, | 41 int width, |
| 40 int height, | 42 int height, |
| 41 const string16& title, | 43 const string16& title, |
| 42 ExtensionDialogObserver* observer); | 44 ExtensionDialogObserver* observer); |
| 43 | 45 |
| 44 #if defined(USE_AURA) | 46 #if defined(USE_AURA) |
| 45 // Create and show a fullscreen dialog with |url|. | 47 // Create and show a fullscreen dialog with |url|. |
| 46 // |profile| is the profile that the extension is registered with. | 48 // |profile| is the profile that the extension is registered with. |
| 47 // |web_contents| is the tab that spawned the dialog. | 49 // |web_contents| is the tab that spawned the dialog. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 protected: | 95 protected: |
| 94 virtual ~ExtensionDialog(); | 96 virtual ~ExtensionDialog(); |
| 95 | 97 |
| 96 private: | 98 private: |
| 97 friend class base::RefCounted<ExtensionDialog>; | 99 friend class base::RefCounted<ExtensionDialog>; |
| 98 | 100 |
| 99 // Use Show() to create instances. | 101 // Use Show() to create instances. |
| 100 ExtensionDialog(ExtensionHost* host, ExtensionDialogObserver* observer); | 102 ExtensionDialog(ExtensionHost* host, ExtensionDialogObserver* observer); |
| 101 | 103 |
| 102 static ExtensionDialog* ShowInternal(const GURL& url, | 104 static ExtensionDialog* ShowInternal(const GURL& url, |
| 103 Browser* browser, | 105 BaseWindow* base_window, |
| 104 ExtensionHost* host, | 106 ExtensionHost* host, |
| 105 int width, | 107 int width, |
| 106 int height, | 108 int height, |
| 107 bool fullscreen, | 109 bool fullscreen, |
| 108 const string16& title, | 110 const string16& title, |
| 109 ExtensionDialogObserver* observer); | 111 ExtensionDialogObserver* observer); |
| 110 | 112 |
| 111 static ExtensionHost* CreateExtensionHost(const GURL& url, | 113 static ExtensionHost* CreateExtensionHost(const GURL& url, |
| 112 Browser* browser, | |
| 113 Profile* profile); | 114 Profile* profile); |
| 114 | 115 |
| 115 void InitWindow(Browser* browser, int width, int height); | 116 void InitWindow(BaseWindow* base_window, int width, int height); |
| 116 void InitWindowFullscreen(); | 117 void InitWindowFullscreen(); |
| 117 | 118 |
| 118 // Window that holds the extension host view. | 119 // Window that holds the extension host view. |
| 119 views::Widget* window_; | 120 views::Widget* window_; |
| 120 | 121 |
| 121 // Window Title | 122 // Window Title |
| 122 string16 window_title_; | 123 string16 window_title_; |
| 123 | 124 |
| 124 // The contained host for the view. | 125 // The contained host for the view. |
| 125 scoped_ptr<ExtensionHost> extension_host_; | 126 scoped_ptr<ExtensionHost> extension_host_; |
| 126 | 127 |
| 127 content::NotificationRegistrar registrar_; | 128 content::NotificationRegistrar registrar_; |
| 128 | 129 |
| 129 // The observer of this popup. | 130 // The observer of this popup. |
| 130 ExtensionDialogObserver* observer_; | 131 ExtensionDialogObserver* observer_; |
| 131 | 132 |
| 132 DISALLOW_COPY_AND_ASSIGN(ExtensionDialog); | 133 DISALLOW_COPY_AND_ASSIGN(ExtensionDialog); |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ | 136 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ |
| OLD | NEW |