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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm

Issue 287123002: [WebModals] New API for browser-scoped popup management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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) 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 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/devtools/devtools_window.h" 11 #include "chrome/browser/devtools/devtools_window.h"
12 #include "chrome/browser/extensions/extension_view_host.h" 12 #include "chrome/browser/extensions/extension_view_host.h"
13 #include "chrome/browser/extensions/extension_view_host_factory.h" 13 #include "chrome/browser/extensions/extension_view_host_factory.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_finder.h"
17 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 18 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
18 #import "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" 19 #import "chrome/browser/ui/cocoa/extensions/extension_view_mac.h"
19 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 20 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
20 #include "components/web_modal/web_contents_modal_dialog_manager.h" 21 #include "components/web_modal/popup_manager.h"
21 #include "content/public/browser/devtools_agent_host.h" 22 #include "content/public/browser/devtools_agent_host.h"
22 #include "content/public/browser/devtools_manager.h" 23 #include "content/public/browser/devtools_manager.h"
23 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
24 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
25 #include "content/public/browser/notification_source.h" 26 #include "content/public/browser/notification_source.h"
26 #include "ui/base/cocoa/window_size_constants.h" 27 #include "ui/base/cocoa/window_size_constants.h"
27 28
28 using content::BrowserContext; 29 using content::BrowserContext;
29 using content::RenderViewHost; 30 using content::RenderViewHost;
30 31
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 [super dealloc]; 207 [super dealloc];
207 } 208 }
208 209
209 - (void)showDevTools { 210 - (void)showDevTools {
210 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); 211 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host());
211 } 212 }
212 213
213 - (void)close { 214 - (void)close {
214 // |windowWillClose:| could have already been called. http://crbug.com/279505 215 // |windowWillClose:| could have already been called. http://crbug.com/279505
215 if (host_) { 216 if (host_) {
216 web_modal::WebContentsModalDialogManager* modalDialogManager = 217 // TODO(gbillock): Change this API to say directly if the current popup
217 web_modal::WebContentsModalDialogManager::FromWebContents( 218 // should block tab close? This is a bit over-reaching.
218 host_->host_contents()); 219 web_modal::PopupManager* popup_manager =
219 if (modalDialogManager && 220 web_modal::PopupManager::FromWebContents(host_->host_contents());
220 modalDialogManager->IsDialogActive()) { 221 if (popup_manager && popup_manager->IsWebModalDialogActive(
222 host_->host_contents())) {
221 return; 223 return;
222 } 224 }
223 } 225 }
224 [super close]; 226 [super close];
225 } 227 }
226 228
227 - (void)windowWillClose:(NSNotification *)notification { 229 - (void)windowWillClose:(NSNotification *)notification {
228 [super windowWillClose:notification]; 230 [super windowWillClose:notification];
229 if (gPopup == self) 231 if (gPopup == self)
230 gPopup = nil; 232 gPopup = nil;
231 if (host_->view()) 233 if (host_->view())
232 static_cast<ExtensionViewMac*>(host_->view())->set_container(NULL); 234 static_cast<ExtensionViewMac*>(host_->view())->set_container(NULL);
233 host_.reset(); 235 host_.reset();
234 } 236 }
235 237
236 - (void)windowDidResignKey:(NSNotification*)notification { 238 - (void)windowDidResignKey:(NSNotification*)notification {
237 // |windowWillClose:| could have already been called. http://crbug.com/279505 239 // |windowWillClose:| could have already been called. http://crbug.com/279505
238 if (host_) { 240 if (host_) {
239 // When a modal dialog is opened on top of the popup and when it's closed, 241 // When a modal dialog is opened on top of the popup and when it's closed,
240 // it steals key-ness from the popup. Don't close the popup when this 242 // it steals key-ness from the popup. Don't close the popup when this
241 // happens. There's an extra windowDidResignKey: notification after the 243 // happens. There's an extra windowDidResignKey: notification after the
242 // modal dialog closes that should also be ignored. 244 // modal dialog closes that should also be ignored.
243 web_modal::WebContentsModalDialogManager* modalDialogManager = 245 web_modal::PopupManager* popupManager =
244 web_modal::WebContentsModalDialogManager::FromWebContents( 246 web_modal::PopupManager::FromWebContents(
245 host_->host_contents()); 247 host_->host_contents());
246 if (modalDialogManager && 248 if (popupManager &&
247 modalDialogManager->IsDialogActive()) { 249 popupManager->IsWebModalDialogActive(host_->host_contents())) {
248 ignoreWindowDidResignKey_ = YES; 250 ignoreWindowDidResignKey_ = YES;
249 return; 251 return;
250 } 252 }
251 if (ignoreWindowDidResignKey_) { 253 if (ignoreWindowDidResignKey_) {
252 ignoreWindowDidResignKey_ = NO; 254 ignoreWindowDidResignKey_ = NO;
253 return; 255 return;
254 } 256 }
255 } 257 }
256 if (!beingInspected_) 258 if (!beingInspected_)
257 [super windowDidResignKey:notification]; 259 [super windowDidResignKey:notification];
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 return minSize; 431 return minSize;
430 } 432 }
431 433
432 // Private (TestingAPI) 434 // Private (TestingAPI)
433 + (NSSize)maxPopupSize { 435 + (NSSize)maxPopupSize {
434 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; 436 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight};
435 return maxSize; 437 return maxSize;
436 } 438 }
437 439
438 @end 440 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698