| OLD | NEW |
| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); | 203 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); |
| 204 } | 204 } |
| 205 | 205 |
| 206 - (void)close { | 206 - (void)close { |
| 207 // |windowWillClose:| could have already been called. http://crbug.com/279505 | 207 // |windowWillClose:| could have already been called. http://crbug.com/279505 |
| 208 if (host_) { | 208 if (host_) { |
| 209 web_modal::WebContentsModalDialogManager* modalDialogManager = | 209 web_modal::WebContentsModalDialogManager* modalDialogManager = |
| 210 web_modal::WebContentsModalDialogManager::FromWebContents( | 210 web_modal::WebContentsModalDialogManager::FromWebContents( |
| 211 host_->host_contents()); | 211 host_->host_contents()); |
| 212 if (modalDialogManager && | 212 if (modalDialogManager && |
| 213 modalDialogManager->IsShowingDialog()) { | 213 modalDialogManager->IsDialogActive()) { |
| 214 return; | 214 return; |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 [super close]; | 217 [super close]; |
| 218 } | 218 } |
| 219 | 219 |
| 220 - (void)windowWillClose:(NSNotification *)notification { | 220 - (void)windowWillClose:(NSNotification *)notification { |
| 221 [super windowWillClose:notification]; | 221 [super windowWillClose:notification]; |
| 222 gPopup = nil; | 222 gPopup = nil; |
| 223 if (host_->view()) | 223 if (host_->view()) |
| 224 host_->view()->set_container(NULL); | 224 host_->view()->set_container(NULL); |
| 225 host_.reset(); | 225 host_.reset(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 - (void)windowDidResignKey:(NSNotification*)notification { | 228 - (void)windowDidResignKey:(NSNotification*)notification { |
| 229 // |windowWillClose:| could have already been called. http://crbug.com/279505 | 229 // |windowWillClose:| could have already been called. http://crbug.com/279505 |
| 230 if (host_) { | 230 if (host_) { |
| 231 // When a modal dialog is opened on top of the popup and when it's closed, | 231 // When a modal dialog is opened on top of the popup and when it's closed, |
| 232 // it steals key-ness from the popup. Don't close the popup when this | 232 // it steals key-ness from the popup. Don't close the popup when this |
| 233 // happens. There's an extra windowDidResignKey: notification after the | 233 // happens. There's an extra windowDidResignKey: notification after the |
| 234 // modal dialog closes that should also be ignored. | 234 // modal dialog closes that should also be ignored. |
| 235 web_modal::WebContentsModalDialogManager* modalDialogManager = | 235 web_modal::WebContentsModalDialogManager* modalDialogManager = |
| 236 web_modal::WebContentsModalDialogManager::FromWebContents( | 236 web_modal::WebContentsModalDialogManager::FromWebContents( |
| 237 host_->host_contents()); | 237 host_->host_contents()); |
| 238 if (modalDialogManager && | 238 if (modalDialogManager && |
| 239 modalDialogManager->IsShowingDialog()) { | 239 modalDialogManager->IsDialogActive()) { |
| 240 ignoreWindowDidResignKey_ = YES; | 240 ignoreWindowDidResignKey_ = YES; |
| 241 return; | 241 return; |
| 242 } | 242 } |
| 243 if (ignoreWindowDidResignKey_) { | 243 if (ignoreWindowDidResignKey_) { |
| 244 ignoreWindowDidResignKey_ = NO; | 244 ignoreWindowDidResignKey_ = NO; |
| 245 return; | 245 return; |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 if (!beingInspected_) | 248 if (!beingInspected_) |
| 249 [super windowDidResignKey:notification]; | 249 [super windowDidResignKey:notification]; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return minSize; | 413 return minSize; |
| 414 } | 414 } |
| 415 | 415 |
| 416 // Private (TestingAPI) | 416 // Private (TestingAPI) |
| 417 + (NSSize)maxPopupSize { | 417 + (NSSize)maxPopupSize { |
| 418 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; | 418 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; |
| 419 return maxSize; | 419 return maxSize; |
| 420 } | 420 } |
| 421 | 421 |
| 422 @end | 422 @end |
| OLD | NEW |