Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: chrome/browser/ui/views/extensions/extension_dialog.cc

Issue 8800032: Make BubbleWindow a Widget override with a BubbleFrameView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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)
25 #include "chrome/browser/chromeos/frame/bubble_window.h"
26 #endif
27
28 namespace {
29
30 views::Widget* CreateWindow(gfx::NativeWindow parent,
31 views::WidgetDelegate* delegate) {
32 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK)
33 // TODO(msw): revert to BubbleWindow for all ChromeOS cases when CL
34 // for crbug.com/98322 is landed.
35 // On Chrome OS we need to override the style to suppress padding around
36 // the borders.
37 return chromeos::BubbleWindow::Create(parent,
38 STYLE_FLUSH, delegate);
39 #else
40 return browser::CreateViewsWindow(parent, delegate, STYLE_GENERIC);
41 #endif
42 }
43
44 } // namespace
45
46 ExtensionDialog::ExtensionDialog(ExtensionHost* host, 24 ExtensionDialog::ExtensionDialog(ExtensionHost* host,
47 ExtensionDialogObserver* observer) 25 ExtensionDialogObserver* observer)
48 : window_(NULL), 26 : window_(NULL),
49 extension_host_(host), 27 extension_host_(host),
50 observer_(observer) { 28 observer_(observer) {
51 AddRef(); // Balanced in DeleteDelegate(); 29 AddRef(); // Balanced in DeleteDelegate();
52 30
53 // Listen for the containing view calling window.close(); 31 // Listen for the containing view calling window.close();
54 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 32 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
55 content::Source<Profile>(host->profile())); 33 content::Source<Profile>(host->profile()));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ExtensionProcessManager* manager = 65 ExtensionProcessManager* manager =
88 browser->profile()->GetExtensionProcessManager(); 66 browser->profile()->GetExtensionProcessManager();
89 DCHECK(manager); 67 DCHECK(manager);
90 if (!manager) 68 if (!manager)
91 return NULL; 69 return NULL;
92 return manager->CreateDialogHost(url, browser); 70 return manager->CreateDialogHost(url, browser);
93 } 71 }
94 72
95 void ExtensionDialog::InitWindow(Browser* browser, int width, int height) { 73 void ExtensionDialog::InitWindow(Browser* browser, int width, int height) {
96 gfx::NativeWindow parent = browser->window()->GetNativeHandle(); 74 gfx::NativeWindow parent = browser->window()->GetNativeHandle();
97 window_ = CreateWindow(parent, this /* views::WidgetDelegate */); 75 #if defined(OS_CHROMEOS)
76 DialogStyle style = STYLE_FLUSH;
77 #else
78 DialogStyle style = STYLE_GENERIC;
79 #endif
80 window_ = browser::CreateViewsWindow(parent, this, style);
98 81
99 // Center the window over the browser. 82 // Center the window over the browser.
100 gfx::Point center = browser->window()->GetBounds().CenterPoint(); 83 gfx::Point center = browser->window()->GetBounds().CenterPoint();
101 int x = center.x() - width / 2; 84 int x = center.x() - width / 2;
102 int y = center.y() - height / 2; 85 int y = center.y() - height / 2;
103 window_->SetBounds(gfx::Rect(x, y, width, height)); 86 window_->SetBounds(gfx::Rect(x, y, width, height));
104 87
105 window_->Show(); 88 window_->Show();
106 window_->Activate(); 89 window_->Activate();
107 } 90 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // If we aren't the host of the popup, then disregard the notification. 153 // If we aren't the host of the popup, then disregard the notification.
171 if (content::Details<ExtensionHost>(host()) != details) 154 if (content::Details<ExtensionHost>(host()) != details)
172 return; 155 return;
173 Close(); 156 Close();
174 break; 157 break;
175 default: 158 default:
176 NOTREACHED() << L"Received unexpected notification"; 159 NOTREACHED() << L"Received unexpected notification";
177 break; 160 break;
178 } 161 }
179 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698