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 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
12 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
13 | 13 |
14 class BaseWindow; | 14 class BaseWindow; |
15 class ExtensionDialogObserver; | 15 class ExtensionDialogObserver; |
16 class ExtensionHost; | |
17 class GURL; | 16 class GURL; |
18 class Profile; | 17 class Profile; |
19 | 18 |
20 namespace content { | 19 namespace content { |
21 class WebContents; | 20 class WebContents; |
22 } | 21 } |
23 | 22 |
| 23 namespace extensions { |
| 24 class ExtensionHost; |
| 25 } |
| 26 |
24 // Modal dialog containing contents provided by an extension. | 27 // Modal dialog containing contents provided by an extension. |
25 // Dialog is automatically centered in the owning window and has fixed size. | 28 // Dialog is automatically centered in the owning window and has fixed size. |
26 // For example, used by the Chrome OS file browser. | 29 // For example, used by the Chrome OS file browser. |
27 class ExtensionDialog : public views::WidgetDelegate, | 30 class ExtensionDialog : public views::WidgetDelegate, |
28 public content::NotificationObserver, | 31 public content::NotificationObserver, |
29 public base::RefCounted<ExtensionDialog> { | 32 public base::RefCounted<ExtensionDialog> { |
30 public: | 33 public: |
31 // Create and show a dialog with |url| centered over the provided window. | 34 // Create and show a dialog with |url| centered over the provided window. |
32 // |base_window| is the window to which the pop-up will be attached. | 35 // |base_window| is the window to which the pop-up will be attached. |
33 // |profile| is the profile that the extension is registered with. | 36 // |profile| is the profile that the extension is registered with. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 72 |
70 // Focus to the render view if possible. | 73 // Focus to the render view if possible. |
71 void MaybeFocusRenderView(); | 74 void MaybeFocusRenderView(); |
72 | 75 |
73 // Sets the window title. | 76 // Sets the window title. |
74 void set_title(const string16& title) { window_title_ = title; } | 77 void set_title(const string16& title) { window_title_ = title; } |
75 | 78 |
76 // Sets minimum contents size in pixels and makes the window resizable. | 79 // Sets minimum contents size in pixels and makes the window resizable. |
77 void SetMinimumContentsSize(int width, int height); | 80 void SetMinimumContentsSize(int width, int height); |
78 | 81 |
79 ExtensionHost* host() const { return extension_host_.get(); } | 82 extensions::ExtensionHost* host() const { return extension_host_.get(); } |
80 | 83 |
81 // views::WidgetDelegate overrides. | 84 // views::WidgetDelegate overrides. |
82 virtual bool CanResize() const OVERRIDE; | 85 virtual bool CanResize() const OVERRIDE; |
83 virtual ui::ModalType GetModalType() const OVERRIDE; | 86 virtual ui::ModalType GetModalType() const OVERRIDE; |
84 virtual bool ShouldShowWindowTitle() const OVERRIDE; | 87 virtual bool ShouldShowWindowTitle() const OVERRIDE; |
85 virtual string16 GetWindowTitle() const OVERRIDE; | 88 virtual string16 GetWindowTitle() const OVERRIDE; |
86 virtual void WindowClosing() OVERRIDE; | 89 virtual void WindowClosing() OVERRIDE; |
87 virtual void DeleteDelegate() OVERRIDE; | 90 virtual void DeleteDelegate() OVERRIDE; |
88 virtual views::Widget* GetWidget() OVERRIDE; | 91 virtual views::Widget* GetWidget() OVERRIDE; |
89 virtual const views::Widget* GetWidget() const OVERRIDE; | 92 virtual const views::Widget* GetWidget() const OVERRIDE; |
90 virtual views::View* GetContentsView() OVERRIDE; | 93 virtual views::View* GetContentsView() OVERRIDE; |
91 | 94 |
92 // content::NotificationObserver overrides. | 95 // content::NotificationObserver overrides. |
93 virtual void Observe(int type, | 96 virtual void Observe(int type, |
94 const content::NotificationSource& source, | 97 const content::NotificationSource& source, |
95 const content::NotificationDetails& details) OVERRIDE; | 98 const content::NotificationDetails& details) OVERRIDE; |
96 | 99 |
97 protected: | 100 protected: |
98 virtual ~ExtensionDialog(); | 101 virtual ~ExtensionDialog(); |
99 | 102 |
100 private: | 103 private: |
101 friend class base::RefCounted<ExtensionDialog>; | 104 friend class base::RefCounted<ExtensionDialog>; |
102 | 105 |
103 // Use Show() to create instances. | 106 // Use Show() to create instances. |
104 ExtensionDialog(ExtensionHost* host, ExtensionDialogObserver* observer); | 107 ExtensionDialog(extensions::ExtensionHost* host, |
| 108 ExtensionDialogObserver* observer); |
105 | 109 |
106 static ExtensionDialog* ShowInternal(const GURL& url, | 110 static ExtensionDialog* ShowInternal(const GURL& url, |
107 BaseWindow* base_window, | 111 BaseWindow* base_window, |
108 ExtensionHost* host, | 112 extensions::ExtensionHost* host, |
109 int width, | 113 int width, |
110 int height, | 114 int height, |
111 bool fullscreen, | 115 bool fullscreen, |
112 const string16& title, | 116 const string16& title, |
113 ExtensionDialogObserver* observer); | 117 ExtensionDialogObserver* observer); |
114 | 118 |
115 static ExtensionHost* CreateExtensionHost(const GURL& url, | 119 static extensions::ExtensionHost* CreateExtensionHost(const GURL& url, |
116 Profile* profile); | 120 Profile* profile); |
117 | 121 |
118 void InitWindow(BaseWindow* base_window, int width, int height); | 122 void InitWindow(BaseWindow* base_window, int width, int height); |
119 void InitWindowFullscreen(); | 123 void InitWindowFullscreen(); |
120 | 124 |
121 // Window that holds the extension host view. | 125 // Window that holds the extension host view. |
122 views::Widget* window_; | 126 views::Widget* window_; |
123 | 127 |
124 // Window Title | 128 // Window Title |
125 string16 window_title_; | 129 string16 window_title_; |
126 | 130 |
127 // The contained host for the view. | 131 // The contained host for the view. |
128 scoped_ptr<ExtensionHost> extension_host_; | 132 scoped_ptr<extensions::ExtensionHost> extension_host_; |
129 | 133 |
130 content::NotificationRegistrar registrar_; | 134 content::NotificationRegistrar registrar_; |
131 | 135 |
132 // The observer of this popup. | 136 // The observer of this popup. |
133 ExtensionDialogObserver* observer_; | 137 ExtensionDialogObserver* observer_; |
134 | 138 |
135 DISALLOW_COPY_AND_ASSIGN(ExtensionDialog); | 139 DISALLOW_COPY_AND_ASSIGN(ExtensionDialog); |
136 }; | 140 }; |
137 | 141 |
138 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ | 142 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_ |
OLD | NEW |