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" |
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 [super dealloc]; | 202 [super dealloc]; |
202 } | 203 } |
203 | 204 |
204 - (void)showDevTools { | 205 - (void)showDevTools { |
205 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); | 206 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); |
206 } | 207 } |
207 | 208 |
208 - (void)close { | 209 - (void)close { |
209 // |windowWillClose:| could have already been called. http://crbug.com/279505 | 210 // |windowWillClose:| could have already been called. http://crbug.com/279505 |
210 if (host_) { | 211 if (host_) { |
211 web_modal::WebContentsModalDialogManager* modalDialogManager = | 212 // TODO(gbillock): Change this API to say directly if the current popup |
212 web_modal::WebContentsModalDialogManager::FromWebContents( | 213 // should block tab close? This is a bit over-reaching. |
213 host_->host_contents()); | 214 web_modal::PopupManager* popup_manager = |
214 if (modalDialogManager && | 215 web_modal::PopupManager::FromWebContents(host_->host_contents()); |
215 modalDialogManager->IsDialogActive()) { | 216 if (popup_manager && popup_manager->IsWebModalDialogActive( |
| 217 host_->host_contents())) { |
216 return; | 218 return; |
217 } | 219 } |
218 } | 220 } |
219 [super close]; | 221 [super close]; |
220 } | 222 } |
221 | 223 |
222 - (void)windowWillClose:(NSNotification *)notification { | 224 - (void)windowWillClose:(NSNotification *)notification { |
223 [super windowWillClose:notification]; | 225 [super windowWillClose:notification]; |
224 if (gPopup == self) | 226 if (gPopup == self) |
225 gPopup = nil; | 227 gPopup = nil; |
226 if (host_->view()) | 228 if (host_->view()) |
227 host_->view()->set_container(NULL); | 229 host_->view()->set_container(NULL); |
228 host_.reset(); | 230 host_.reset(); |
229 } | 231 } |
230 | 232 |
231 - (void)windowDidResignKey:(NSNotification*)notification { | 233 - (void)windowDidResignKey:(NSNotification*)notification { |
232 // |windowWillClose:| could have already been called. http://crbug.com/279505 | 234 // |windowWillClose:| could have already been called. http://crbug.com/279505 |
233 if (host_) { | 235 if (host_) { |
234 // When a modal dialog is opened on top of the popup and when it's closed, | 236 // When a modal dialog is opened on top of the popup and when it's closed, |
235 // it steals key-ness from the popup. Don't close the popup when this | 237 // it steals key-ness from the popup. Don't close the popup when this |
236 // happens. There's an extra windowDidResignKey: notification after the | 238 // happens. There's an extra windowDidResignKey: notification after the |
237 // modal dialog closes that should also be ignored. | 239 // modal dialog closes that should also be ignored. |
238 web_modal::WebContentsModalDialogManager* modalDialogManager = | 240 web_modal::PopupManager* popupManager = |
239 web_modal::WebContentsModalDialogManager::FromWebContents( | 241 web_modal::PopupManager::FromWebContents( |
240 host_->host_contents()); | 242 host_->host_contents()); |
241 if (modalDialogManager && | 243 if (popupManager && |
242 modalDialogManager->IsDialogActive()) { | 244 popupManager->IsWebModalDialogActive(host_->host_contents())) { |
243 ignoreWindowDidResignKey_ = YES; | 245 ignoreWindowDidResignKey_ = YES; |
244 return; | 246 return; |
245 } | 247 } |
246 if (ignoreWindowDidResignKey_) { | 248 if (ignoreWindowDidResignKey_) { |
247 ignoreWindowDidResignKey_ = NO; | 249 ignoreWindowDidResignKey_ = NO; |
248 return; | 250 return; |
249 } | 251 } |
250 } | 252 } |
251 if (!beingInspected_) | 253 if (!beingInspected_) |
252 [super windowDidResignKey:notification]; | 254 [super windowDidResignKey:notification]; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 return minSize; | 422 return minSize; |
421 } | 423 } |
422 | 424 |
423 // Private (TestingAPI) | 425 // Private (TestingAPI) |
424 + (NSSize)maxPopupSize { | 426 + (NSSize)maxPopupSize { |
425 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; | 427 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; |
426 return maxSize; | 428 return maxSize; |
427 } | 429 } |
428 | 430 |
429 @end | 431 @end |
OLD | NEW |