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

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: Make PopupManager a thin API for WCMDM Created 6 years, 6 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"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 [super dealloc]; 200 [super dealloc];
201 } 201 }
202 202
203 - (void)showDevTools { 203 - (void)showDevTools {
204 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); 204 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host());
205 } 205 }
206 206
207 - (void)close { 207 - (void)close {
208 // |windowWillClose:| could have already been called. http://crbug.com/279505 208 // |windowWillClose:| could have already been called. http://crbug.com/279505
209 if (host_) { 209 if (host_) {
210 web_modal::WebContentsModalDialogManager* modalDialogManager = 210 // TODO(gbillock): Change this API to say directly if the current popup
211 web_modal::WebContentsModalDialogManager::FromWebContents( 211 // should block tab close? This is a bit over-reaching.
212 host_->host_contents()); 212 Browser* browser = chrome::BrowserFromWebContents(host_->host_contents());
213 if (modalDialogManager && 213 if (browser && browser->popup_manager()->IsWebModalDialogActive(
214 modalDialogManager->IsDialogActive()) { 214 host_->host_contents())) {
215 return; 215 return;
216 } 216 }
217 } 217 }
218 [super close]; 218 [super close];
219 } 219 }
220 220
221 - (void)windowWillClose:(NSNotification *)notification { 221 - (void)windowWillClose:(NSNotification *)notification {
222 [super windowWillClose:notification]; 222 [super windowWillClose:notification];
223 if (gPopup == self) 223 if (gPopup == self)
224 gPopup = nil; 224 gPopup = nil;
225 if (host_->view()) 225 if (host_->view())
226 host_->view()->set_container(NULL); 226 host_->view()->set_container(NULL);
227 host_.reset(); 227 host_.reset();
228 } 228 }
229 229
230 - (void)windowDidResignKey:(NSNotification*)notification { 230 - (void)windowDidResignKey:(NSNotification*)notification {
231 // |windowWillClose:| could have already been called. http://crbug.com/279505 231 // |windowWillClose:| could have already been called. http://crbug.com/279505
232 if (host_) { 232 if (host_) {
233 // When a modal dialog is opened on top of the popup and when it's closed, 233 // When a modal dialog is opened on top of the popup and when it's closed,
234 // it steals key-ness from the popup. Don't close the popup when this 234 // it steals key-ness from the popup. Don't close the popup when this
235 // happens. There's an extra windowDidResignKey: notification after the 235 // happens. There's an extra windowDidResignKey: notification after the
236 // modal dialog closes that should also be ignored. 236 // modal dialog closes that should also be ignored.
237 // TODO(gbillock): Repoint to the PopupManager. Is this even an issue this
238 // class needs to worry about? Or can we eliminate this case through the
239 // PopupManager itself?
237 web_modal::WebContentsModalDialogManager* modalDialogManager = 240 web_modal::WebContentsModalDialogManager* modalDialogManager =
238 web_modal::WebContentsModalDialogManager::FromWebContents( 241 web_modal::WebContentsModalDialogManager::FromWebContents(
239 host_->host_contents()); 242 host_->host_contents());
240 if (modalDialogManager && 243 if (modalDialogManager &&
241 modalDialogManager->IsDialogActive()) { 244 modalDialogManager->IsDialogActive()) {
242 ignoreWindowDidResignKey_ = YES; 245 ignoreWindowDidResignKey_ = YES;
243 return; 246 return;
244 } 247 }
245 if (ignoreWindowDidResignKey_) { 248 if (ignoreWindowDidResignKey_) {
246 ignoreWindowDidResignKey_ = NO; 249 ignoreWindowDidResignKey_ = NO;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 return minSize; 408 return minSize;
406 } 409 }
407 410
408 // Private (TestingAPI) 411 // Private (TestingAPI)
409 + (NSSize)maxPopupSize { 412 + (NSSize)maxPopupSize {
410 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; 413 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight};
411 return maxSize; 414 return maxSize;
412 } 415 }
413 416
414 @end 417 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698