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

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

Issue 8068020: Converts usage of GetBrowserViewForNativeWindow to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback, and make ShowPageInfo platform specific Created 9 years, 2 months 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_popup.h" 5 #include "chrome/browser/ui/views/extensions/extension_popup.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "chrome/browser/debugger/devtools_window.h" 9 #include "chrome/browser/debugger/devtools_window.h"
10 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
11 #include "chrome/browser/extensions/extension_process_manager.h" 11 #include "chrome/browser/extensions/extension_process_manager.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
18 #include "content/browser/renderer_host/render_view_host.h" 17 #include "content/browser/renderer_host/render_view_host.h"
19 #include "content/browser/renderer_host/render_widget_host_view.h" 18 #include "content/browser/renderer_host/render_widget_host_view.h"
20 #include "content/common/notification_details.h" 19 #include "content/common/notification_details.h"
21 #include "content/common/notification_source.h" 20 #include "content/common/notification_source.h"
22 #include "views/widget/root_view.h" 21 #include "views/widget/root_view.h"
23 #include "views/widget/widget.h" 22 #include "views/widget/widget.h"
24 23
25 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
26 #include "chrome/browser/chromeos/wm_ipc.h" 25 #include "chrome/browser/chromeos/wm_ipc.h"
27 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" 26 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h"
28 #endif 27 #endif
29 28
30 using std::vector; 29 using std::vector;
31 using views::Widget; 30 using views::Widget;
32 31
33 // The minimum/maximum dimensions of the popup. 32 // The minimum/maximum dimensions of the popup.
34 // The minimum is just a little larger than the size of the button itself. 33 // The minimum is just a little larger than the size of the button itself.
35 // The maximum is an arbitrary number that should be smaller than most screens. 34 // The maximum is an arbitrary number that should be smaller than most screens.
36 const int ExtensionPopup::kMinWidth = 25; 35 const int ExtensionPopup::kMinWidth = 25;
37 const int ExtensionPopup::kMinHeight = 25; 36 const int ExtensionPopup::kMinHeight = 25;
38 const int ExtensionPopup::kMaxWidth = 800; 37 const int ExtensionPopup::kMaxWidth = 800;
39 const int ExtensionPopup::kMaxHeight = 600; 38 const int ExtensionPopup::kMaxHeight = 600;
40 39
41 ExtensionPopup::ExtensionPopup( 40 ExtensionPopup::ExtensionPopup(
41 Browser* browser,
42 ExtensionHost* host, 42 ExtensionHost* host,
43 views::Widget* frame,
44 const gfx::Rect& relative_to, 43 const gfx::Rect& relative_to,
45 views::BubbleBorder::ArrowLocation arrow_location, 44 views::BubbleBorder::ArrowLocation arrow_location,
46 bool inspect_with_devtools, 45 bool inspect_with_devtools,
47 Observer* observer) 46 Observer* observer)
48 : BrowserBubble(host->view(), 47 : BrowserBubble(browser,
49 frame, 48 host->view(),
50 relative_to, 49 relative_to,
51 arrow_location), 50 arrow_location),
52 relative_to_(relative_to), 51 relative_to_(relative_to),
53 extension_host_(host), 52 extension_host_(host),
54 inspect_with_devtools_(inspect_with_devtools), 53 inspect_with_devtools_(inspect_with_devtools),
55 close_on_lost_focus_(true), 54 close_on_lost_focus_(true),
56 closing_(false), 55 closing_(false),
57 observer_(observer) { 56 observer_(observer) {
58 AddRef(); // Balanced in Close(); 57 AddRef(); // Balanced in Close();
59 set_delegate(this); 58 set_delegate(this);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 views::BubbleBorder::ArrowLocation arrow_location, 179 views::BubbleBorder::ArrowLocation arrow_location,
181 bool inspect_with_devtools, 180 bool inspect_with_devtools,
182 Observer* observer) { 181 Observer* observer) {
183 ExtensionProcessManager* manager = 182 ExtensionProcessManager* manager =
184 browser->profile()->GetExtensionProcessManager(); 183 browser->profile()->GetExtensionProcessManager();
185 DCHECK(manager); 184 DCHECK(manager);
186 if (!manager) 185 if (!manager)
187 return NULL; 186 return NULL;
188 187
189 ExtensionHost* host = manager->CreatePopupHost(url, browser); 188 ExtensionHost* host = manager->CreatePopupHost(url, browser);
190 views::Widget* frame = BrowserView::GetBrowserViewForNativeWindow( 189 ExtensionPopup* popup = new ExtensionPopup(browser, host, relative_to,
191 browser->window()->GetNativeHandle())->GetWidget();
192 ExtensionPopup* popup = new ExtensionPopup(host, frame, relative_to,
193 arrow_location, 190 arrow_location,
194 inspect_with_devtools, observer); 191 inspect_with_devtools, observer);
195 192
196 // If the host had somehow finished loading, then we'd miss the notification 193 // If the host had somehow finished loading, then we'd miss the notification
197 // and not show. This seems to happen in single-process mode. 194 // and not show. This seems to happen in single-process mode.
198 if (host->did_stop_loading()) 195 if (host->did_stop_loading())
199 popup->Show(true); 196 popup->Show(true);
200 197
201 return popup; 198 return popup;
202 } 199 }
203 200
204 void ExtensionPopup::Close() { 201 void ExtensionPopup::Close() {
205 if (closing_) 202 if (closing_)
206 return; 203 return;
207 closing_ = true; 204 closing_ = true;
208 DetachFromBrowser(); 205 DetachFromBrowser();
209 206
210 if (observer_) 207 if (observer_)
211 observer_->ExtensionPopupIsClosing(this); 208 observer_->ExtensionPopupIsClosing(this);
212 209
213 Release(); // Balanced in ctor. 210 Release(); // Balanced in ctor.
214 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698