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

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

Powered by Google App Engine
This is Rietveld 408576698