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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 delegate_->OnConstrainedWindowClosed(this); | 74 delegate_->OnConstrainedWindowClosed(this); |
75 } | 75 } |
76 | 76 |
77 bool ConstrainedWindowMac::DialogWasShown() { | 77 bool ConstrainedWindowMac::DialogWasShown() { |
78 // If the dialog was shown, |native_manager_| would have been released. | 78 // If the dialog was shown, |native_manager_| would have been released. |
79 return !native_manager_; | 79 return !native_manager_; |
80 } | 80 } |
81 | 81 |
82 WebContentsModalDialogManager* ConstrainedWindowMac::GetDialogManager() { | 82 WebContentsModalDialogManager* ConstrainedWindowMac::GetDialogManager() { |
83 DCHECK(web_contents_); | 83 DCHECK(web_contents_); |
84 return WebContentsModalDialogManager::FromWebContents(web_contents_); | 84 WebContentsModalDialogManager* dialog_manager = |
| 85 WebContentsModalDialogManager::FromWebContents(web_contents_); |
| 86 // If WebContentsModalDialogManager::CreateForWebContents(web_contents_) was |
| 87 // never called, then the manager will be null. E.g., for browser tabs, |
| 88 // TabHelpers::AttachTabHelpers() calls CreateForWebContents(). It is invalid |
| 89 // to show a dialog on some kinds of WebContents. Crash cleanly in that case. |
| 90 CHECK(dialog_manager); |
| 91 return dialog_manager; |
85 } | 92 } |
OLD | NEW |