| 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 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | 5 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" | 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 void ConstrainedWindowMac::FocusWebContentsModalDialog() { | 71 void ConstrainedWindowMac::FocusWebContentsModalDialog() { |
| 72 } | 72 } |
| 73 | 73 |
| 74 void ConstrainedWindowMac::PulseWebContentsModalDialog() { | 74 void ConstrainedWindowMac::PulseWebContentsModalDialog() { |
| 75 [[ConstrainedWindowSheetController controllerForSheet:sheet_] | 75 [[ConstrainedWindowSheetController controllerForSheet:sheet_] |
| 76 pulseSheet:sheet_]; | 76 pulseSheet:sheet_]; |
| 77 } | 77 } |
| 78 | 78 |
| 79 gfx::NativeWindow ConstrainedWindowMac::GetNativeWindow() { | 79 NativeWebContentsModalDialog ConstrainedWindowMac::GetNativeDialog() { |
| 80 NOTREACHED(); | 80 return sheet_.get(); |
| 81 return nil; | |
| 82 } | 81 } |
| 83 | 82 |
| 84 void ConstrainedWindowMac::Observe( | 83 void ConstrainedWindowMac::Observe( |
| 85 int type, | 84 int type, |
| 86 const content::NotificationSource& source, | 85 const content::NotificationSource& source, |
| 87 const content::NotificationDetails& details) { | 86 const content::NotificationDetails& details) { |
| 88 if (type != content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { | 87 if (type != content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { |
| 89 NOTREACHED(); | 88 NOTREACHED(); |
| 90 return; | 89 return; |
| 91 } | 90 } |
| 92 | 91 |
| 93 if (pending_show_) { | 92 if (pending_show_) { |
| 94 pending_show_ = false; | 93 pending_show_ = false; |
| 95 ShowWebContentsModalDialog(); | 94 ShowWebContentsModalDialog(); |
| 96 } | 95 } |
| 97 } | 96 } |
| 98 | 97 |
| 99 NSWindow* ConstrainedWindowMac::GetParentWindow() const { | 98 NSWindow* ConstrainedWindowMac::GetParentWindow() const { |
| 100 // Tab contents in a tabbed browser may not be inside a window. For this | 99 // Tab contents in a tabbed browser may not be inside a window. For this |
| 101 // reason use a browser window if possible. | 100 // reason use a browser window if possible. |
| 102 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 101 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
| 103 if (browser) | 102 if (browser) |
| 104 return browser->window()->GetNativeWindow(); | 103 return browser->window()->GetNativeWindow(); |
| 105 | 104 |
| 106 return web_contents_->GetView()->GetTopLevelNativeWindow(); | 105 return web_contents_->GetView()->GetTopLevelNativeWindow(); |
| 107 } | 106 } |
| OLD | NEW |