| 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 "components/web_modal/web_contents_modal_dialog_manager.h" | 5 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 9 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 10 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 void WebContentsModalDialogManager::WillClose(gfx::NativeWindow dialog) { | 66 void WebContentsModalDialogManager::WillClose(gfx::NativeWindow dialog) { |
| 67 WebContentsModalDialogList::iterator dlg = FindDialogState(dialog); | 67 WebContentsModalDialogList::iterator dlg = FindDialogState(dialog); |
| 68 | 68 |
| 69 // The Views tab contents modal dialog calls WillClose twice. Ignore the | 69 // The Views tab contents modal dialog calls WillClose twice. Ignore the |
| 70 // second invocation. | 70 // second invocation. |
| 71 if (dlg == child_dialogs_.end()) | 71 if (dlg == child_dialogs_.end()) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 nonclipped_child_dialogs_.erase(dialog); |
| 74 bool removed_topmost_dialog = dlg == child_dialogs_.begin(); | 75 bool removed_topmost_dialog = dlg == child_dialogs_.begin(); |
| 75 std::unique_ptr<DialogState> deleter(*dlg); | 76 std::unique_ptr<DialogState> deleter(*dlg); |
| 76 child_dialogs_.erase(dlg); | 77 child_dialogs_.erase(dlg); |
| 77 if (!child_dialogs_.empty() && removed_topmost_dialog && | 78 if (!child_dialogs_.empty() && removed_topmost_dialog && |
| 78 !closing_all_dialogs_) { | 79 !closing_all_dialogs_) { |
| 79 child_dialogs_.front()->manager->Show(); | 80 child_dialogs_.front()->manager->Show(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 BlockWebContentsInteraction(!child_dialogs_.empty()); | 83 BlockWebContentsInteraction(!child_dialogs_.empty()); |
| 83 } | 84 } |
| 84 | 85 |
| 86 void WebContentsModalDialogManager::AddNonClippedDialog( |
| 87 gfx::NativeWindow dialog) { |
| 88 nonclipped_child_dialogs_.insert(dialog); |
| 89 } |
| 90 |
| 91 bool WebContentsModalDialogManager::IsNonClipped( |
| 92 gfx::NativeWindow dialog) const { |
| 93 return base::ContainsKey(nonclipped_child_dialogs_, dialog); |
| 94 } |
| 95 |
| 85 WebContentsModalDialogManager::WebContentsModalDialogManager( | 96 WebContentsModalDialogManager::WebContentsModalDialogManager( |
| 86 content::WebContents* web_contents) | 97 content::WebContents* web_contents) |
| 87 : content::WebContentsObserver(web_contents), | 98 : content::WebContentsObserver(web_contents), |
| 88 delegate_(NULL), | 99 delegate_(NULL), |
| 89 closing_all_dialogs_(false) { | 100 closing_all_dialogs_(false) { |
| 90 } | 101 } |
| 91 | 102 |
| 92 WebContentsModalDialogManager::DialogState::DialogState( | 103 WebContentsModalDialogManager::DialogState::DialogState( |
| 93 gfx::NativeWindow dialog, | 104 gfx::NativeWindow dialog, |
| 94 std::unique_ptr<SingleWebContentsDialogManager> mgr) | 105 std::unique_ptr<SingleWebContentsDialogManager> mgr) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // some of these to close. CloseAllDialogs is async, so it might get called | 180 // some of these to close. CloseAllDialogs is async, so it might get called |
| 170 // twice before it runs. | 181 // twice before it runs. |
| 171 CloseAllDialogs(); | 182 CloseAllDialogs(); |
| 172 } | 183 } |
| 173 | 184 |
| 174 void WebContentsModalDialogManager::DidAttachInterstitialPage() { | 185 void WebContentsModalDialogManager::DidAttachInterstitialPage() { |
| 175 CloseAllDialogs(); | 186 CloseAllDialogs(); |
| 176 } | 187 } |
| 177 | 188 |
| 178 } // namespace web_modal | 189 } // namespace web_modal |
| OLD | NEW |