OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/views/extensions/extension_dialog.h" | 5 #include "chrome/browser/ui/views/extensions/extension_dialog.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/browser/ui/dialog_style.h" | 12 #include "chrome/browser/ui/dialog_style.h" |
13 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" | 13 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" |
14 #include "chrome/browser/ui/views/window.h" // CreateViewsWindow | 14 #include "chrome/browser/ui/views/window.h" // CreateViewsWindow |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "content/browser/renderer_host/render_view_host.h" | 16 #include "content/browser/renderer_host/render_view_host.h" |
17 #include "content/browser/renderer_host/render_widget_host_view.h" | 17 #include "content/browser/renderer_host/render_widget_host_view.h" |
18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
19 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
23 | 23 |
24 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
25 #include "chrome/browser/chromeos/frame/bubble_window.h" | 25 #include "chrome/browser/chromeos/frame/bubble_frame_view.h" |
26 #endif | 26 #endif |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 views::Widget* CreateWindow(gfx::NativeWindow parent, | 30 views::Widget* CreateWindow(gfx::NativeWindow parent, |
31 views::WidgetDelegate* delegate) { | 31 views::WidgetDelegate* delegate) { |
32 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) | 32 #if defined(OS_CHROMEOS) |
33 // TODO(msw): revert to BubbleWindow for all ChromeOS cases when CL | 33 views::Widget* window = new views::Widget; |
34 // for crbug.com/98322 is landed. | 34 views::Widget::InitParams params; |
35 // On Chrome OS we need to override the style to suppress padding around | 35 params.delegate = delegate; |
36 // the borders. | 36 params.parent = reinterpret_cast<gfx::NativeView>(parent); |
37 return chromeos::BubbleWindow::Create(parent, | 37 window->Init(params); |
38 STYLE_FLUSH, delegate); | 38 return window; |
39 #else | 39 #else |
40 return browser::CreateViewsWindow(parent, delegate, STYLE_GENERIC); | 40 return browser::CreateViewsWindow(parent, delegate, STYLE_GENERIC); |
41 #endif | 41 #endif |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 ExtensionDialog::ExtensionDialog(ExtensionHost* host, | 46 ExtensionDialog::ExtensionDialog(ExtensionHost* host, |
47 ExtensionDialogObserver* observer) | 47 ExtensionDialogObserver* observer) |
48 : window_(NULL), | 48 : window_(NULL), |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 | 153 |
154 const views::Widget* ExtensionDialog::GetWidget() const { | 154 const views::Widget* ExtensionDialog::GetWidget() const { |
155 return extension_host_->view()->GetWidget(); | 155 return extension_host_->view()->GetWidget(); |
156 } | 156 } |
157 | 157 |
158 views::View* ExtensionDialog::GetContentsView() { | 158 views::View* ExtensionDialog::GetContentsView() { |
159 return extension_host_->view(); | 159 return extension_host_->view(); |
160 } | 160 } |
161 | 161 |
| 162 #if defined(OS_CHROMEOS) |
| 163 views::NonClientFrameView* ExtensionDialog::CreateNonClientFrameView() { |
| 164 return new chromeos::BubbleFrameView(this, STYLE_FLUSH); |
| 165 } |
| 166 #endif |
| 167 |
162 ///////////////////////////////////////////////////////////////////////////// | 168 ///////////////////////////////////////////////////////////////////////////// |
163 // content::NotificationObserver overrides. | 169 // content::NotificationObserver overrides. |
164 | 170 |
165 void ExtensionDialog::Observe(int type, | 171 void ExtensionDialog::Observe(int type, |
166 const content::NotificationSource& source, | 172 const content::NotificationSource& source, |
167 const content::NotificationDetails& details) { | 173 const content::NotificationDetails& details) { |
168 switch (type) { | 174 switch (type) { |
169 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: | 175 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: |
170 // If we aren't the host of the popup, then disregard the notification. | 176 // If we aren't the host of the popup, then disregard the notification. |
171 if (content::Details<ExtensionHost>(host()) != details) | 177 if (content::Details<ExtensionHost>(host()) != details) |
172 return; | 178 return; |
173 Close(); | 179 Close(); |
174 break; | 180 break; |
175 default: | 181 default: |
176 NOTREACHED() << L"Received unexpected notification"; | 182 NOTREACHED() << L"Received unexpected notification"; |
177 break; | 183 break; |
178 } | 184 } |
179 } | 185 } |
OLD | NEW |