| 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_handle.h" |
| 11 #include "content/public/browser/navigation_entry.h" | |
| 12 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/public/browser/render_widget_host.h" | 12 #include "content/public/browser/render_widget_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 15 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 14 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 16 | 15 |
| 17 using content::WebContents; | 16 using content::WebContents; |
| 18 | 17 |
| 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(web_modal::WebContentsModalDialogManager); | 18 DEFINE_WEB_CONTENTS_USER_DATA_KEY(web_modal::WebContentsModalDialogManager); |
| 20 | 19 |
| 21 namespace web_modal { | 20 namespace web_modal { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 closing_all_dialogs_ = true; | 129 closing_all_dialogs_ = true; |
| 131 | 130 |
| 132 // Clear out any dialogs since we are leaving this page entirely. | 131 // Clear out any dialogs since we are leaving this page entirely. |
| 133 while (!child_dialogs_.empty()) { | 132 while (!child_dialogs_.empty()) { |
| 134 child_dialogs_.front()->manager->Close(); | 133 child_dialogs_.front()->manager->Close(); |
| 135 } | 134 } |
| 136 | 135 |
| 137 closing_all_dialogs_ = false; | 136 closing_all_dialogs_ = false; |
| 138 } | 137 } |
| 139 | 138 |
| 140 void WebContentsModalDialogManager::DidNavigateMainFrame( | 139 void WebContentsModalDialogManager::DidFinishNavigation( |
| 141 const content::LoadCommittedDetails& details, | 140 content::NavigationHandle* navigation_handle) { |
| 142 const content::FrameNavigateParams& params) { | 141 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
| 142 return; |
| 143 |
| 143 // Close constrained windows if necessary. | 144 // Close constrained windows if necessary. |
| 144 if (!net::registry_controlled_domains::SameDomainOrHost( | 145 if (!net::registry_controlled_domains::SameDomainOrHost( |
| 145 details.previous_url, details.entry->GetURL(), | 146 navigation_handle->GetPreviousURL(), navigation_handle->GetURL(), |
| 146 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) | 147 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) |
| 147 CloseAllDialogs(); | 148 CloseAllDialogs(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void WebContentsModalDialogManager::DidGetIgnoredUIEvent() { | 151 void WebContentsModalDialogManager::DidGetIgnoredUIEvent() { |
| 151 if (!child_dialogs_.empty()) { | 152 if (!child_dialogs_.empty()) { |
| 152 child_dialogs_.front()->manager->Focus(); | 153 child_dialogs_.front()->manager->Focus(); |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 | 156 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 169 // some of these to close. CloseAllDialogs is async, so it might get called | 170 // some of these to close. CloseAllDialogs is async, so it might get called |
| 170 // twice before it runs. | 171 // twice before it runs. |
| 171 CloseAllDialogs(); | 172 CloseAllDialogs(); |
| 172 } | 173 } |
| 173 | 174 |
| 174 void WebContentsModalDialogManager::DidAttachInterstitialPage() { | 175 void WebContentsModalDialogManager::DidAttachInterstitialPage() { |
| 175 CloseAllDialogs(); | 176 CloseAllDialogs(); |
| 176 } | 177 } |
| 177 | 178 |
| 178 } // namespace web_modal | 179 } // namespace web_modal |
| OLD | NEW |