| 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 virtual ~ExtensionDialog(); | 32 virtual ~ExtensionDialog(); |
| 33 | 33 |
| 34 // Create and show a dialog with |url| centered over the browser window. | 34 // Create and show a dialog with |url| centered over the provided window. |
| 35 // |browser| is the browser to which the pop-up will be attached. | 35 // |base_window| is the window to which the pop-up will be attached. |
| 36 // |profile| is the profile that the extension is registered with. |
| 36 // |web_contents| is the tab that spawned the dialog. | 37 // |web_contents| is the tab that spawned the dialog. |
| 37 // |width| and |height| are the size of the dialog in pixels. | 38 // |width| and |height| are the size of the dialog in pixels. |
| 38 static ExtensionDialog* Show(const GURL& url, | 39 static ExtensionDialog* Show(const GURL& url, |
| 39 Browser* browser, | 40 BaseWindow* base_window, |
| 41 Profile* profile, |
| 40 content::WebContents* web_contents, | 42 content::WebContents* web_contents, |
| 41 int width, | 43 int width, |
| 42 int height, | 44 int height, |
| 43 const string16& title, | 45 const string16& title, |
| 44 ExtensionDialogObserver* observer); | 46 ExtensionDialogObserver* observer); |
| 45 | 47 |
| 46 #if defined(USE_AURA) | 48 #if defined(USE_AURA) |
| 47 // Create and show a fullscreen dialog with |url|. | 49 // Create and show a fullscreen dialog with |url|. |
| 48 // |profile| is the profile that the extension is registered with. | 50 // |profile| is the profile that the extension is registered with. |
| 49 // |web_contents| is the tab that spawned the dialog. | 51 // |web_contents| is the tab that spawned the dialog. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // content::NotificationObserver overrides. | 92 // content::NotificationObserver overrides. |
| 91 virtual void Observe(int type, | 93 virtual void Observe(int type, |
| 92 const content::NotificationSource& source, | 94 const content::NotificationSource& source, |
| 93 const content::NotificationDetails& details) OVERRIDE; | 95 const content::NotificationDetails& details) OVERRIDE; |
| 94 | 96 |
| 95 private: | 97 private: |
| 96 // Use Show() to create instances. | 98 // Use Show() to create instances. |
| 97 ExtensionDialog(ExtensionHost* host, ExtensionDialogObserver* observer); | 99 ExtensionDialog(ExtensionHost* host, ExtensionDialogObserver* observer); |
| 98 | 100 |
| 99 static ExtensionDialog* ShowInternal(const GURL& url, | 101 static ExtensionDialog* ShowInternal(const GURL& url, |
| 100 Browser* browser, | 102 BaseWindow* base_window, |
| 101 ExtensionHost* host, | 103 ExtensionHost* host, |
| 102 int width, | 104 int width, |
| 103 int height, | 105 int height, |
| 104 bool fullscreen, | 106 bool fullscreen, |
| 105 const string16& title, | 107 const string16& title, |
| 106 ExtensionDialogObserver* observer); | 108 ExtensionDialogObserver* observer); |
| 107 | 109 |
| 108 static ExtensionHost* CreateExtensionHost(const GURL& url, | 110 static ExtensionHost* CreateExtensionHost(const GURL& url, |
| 109 Browser* browser, | |
| 110 Profile* profile); | 111 Profile* profile); |
| 111 | 112 |
| 112 void InitWindow(Browser* browser, int width, int height); | 113 void InitWindow(BaseWindow* base_window, int width, int height); |
| 113 void InitWindowFullscreen(); | 114 void InitWindowFullscreen(); |
| 114 | 115 |
| 115 // Window that holds the extension host view. | 116 // Window that holds the extension host view. |
| 116 views::Widget* window_; | 117 views::Widget* window_; |
| 117 | 118 |
| 118 // Window Title | 119 // Window Title |
| 119 string16 window_title_; | 120 string16 window_title_; |
| 120 | 121 |
| 121 // The contained host for the view. | 122 // The contained host for the view. |
| 122 scoped_ptr<ExtensionHost> extension_host_; | 123 scoped_ptr<ExtensionHost> extension_host_; |
| 123 | 124 |
| 124 content::NotificationRegistrar registrar_; | 125 content::NotificationRegistrar registrar_; |
| 125 | 126 |
| 126 // The observer of this popup. | 127 // The observer of this popup. |
| 127 ExtensionDialogObserver* observer_; | 128 ExtensionDialogObserver* observer_; |
| 128 | 129 |
| 129 DISALLOW_COPY_AND_ASSIGN(ExtensionDialog); | 130 DISALLOW_COPY_AND_ASSIGN(ExtensionDialog); |
| 130 }; | 131 }; |
| 131 | 132 |
| 132 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ | 133 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ |
| OLD | NEW |