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/captive_portal/captive_portal_tab_helper.h" | 5 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/dump_without_crashing.h" | 8 #include "base/debug/dump_without_crashing.h" |
9 #include "chrome/browser/captive_portal/captive_portal_login_detector.h" | 9 #include "chrome/browser/captive_portal/captive_portal_login_detector.h" |
10 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 10 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 void CaptivePortalTabHelper::DidStartNavigation( | 58 void CaptivePortalTabHelper::DidStartNavigation( |
59 content::NavigationHandle* navigation_handle) { | 59 content::NavigationHandle* navigation_handle) { |
60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
61 if (!navigation_handle->IsInMainFrame() || | 61 if (!navigation_handle->IsInMainFrame() || |
62 navigation_handle->IsSameDocument()) { | 62 navigation_handle->IsSameDocument()) { |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 // TODO(clamy): The root cause behind crbug.com/704892 is known. | 66 // TODO(clamy): Remove this when we understand the root cause behind |
67 // Remove this code if it is never reached until ~ 2017-July-20. | 67 // crbug.com/704892. |
68 if (navigation_handle == navigation_handle_) | 68 if (navigation_handle == navigation_handle_) |
69 base::debug::DumpWithoutCrashing(); | 69 base::debug::DumpWithoutCrashing(); |
70 | 70 |
71 bool was_tracking_navigation = !!navigation_handle_; | 71 bool was_tracking_navigation = !!navigation_handle_; |
72 navigation_handle_ = navigation_handle; | 72 navigation_handle_ = navigation_handle; |
73 | 73 |
74 // Always track the latest navigation. If a navigation was already tracked, | 74 // Always track the latest navigation. If a navigation was already tracked, |
75 // and it committed (either the navigation proper or an error page), it is | 75 // and it committed (either the navigation proper or an error page), it is |
76 // safe to start tracking the new navigation. Otherwise simulate an abort | 76 // safe to start tracking the new navigation. Otherwise simulate an abort |
77 // before reporting the start of the new navigation. | 77 // before reporting the start of the new navigation. |
(...skipping 11 matching lines...) Expand all Loading... |
89 return; | 89 return; |
90 DCHECK(navigation_handle->IsInMainFrame()); | 90 DCHECK(navigation_handle->IsInMainFrame()); |
91 tab_reloader_->OnRedirect( | 91 tab_reloader_->OnRedirect( |
92 navigation_handle->GetURL().SchemeIsCryptographic()); | 92 navigation_handle->GetURL().SchemeIsCryptographic()); |
93 } | 93 } |
94 | 94 |
95 void CaptivePortalTabHelper::DidFinishNavigation( | 95 void CaptivePortalTabHelper::DidFinishNavigation( |
96 content::NavigationHandle* navigation_handle) { | 96 content::NavigationHandle* navigation_handle) { |
97 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 97 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
98 | 98 |
| 99 // TODO(clamy): Remove this when we understand the root cause behind |
| 100 // crbug.com/704892. |
| 101 if (navigation_handle_ && !navigation_handle_->IsInMainFrame()) |
| 102 base::debug::DumpWithoutCrashing(); |
| 103 |
99 // Exclude subframe navigations. | 104 // Exclude subframe navigations. |
100 if (!navigation_handle->IsInMainFrame()) | 105 if (!navigation_handle->IsInMainFrame()) |
101 return; | 106 return; |
102 | 107 |
103 // Exclude same-document navigations and aborted navigations that were not | 108 // Exclude same-document navigations and aborted navigations that were not |
104 // being tracked. | 109 // being tracked. |
105 if (navigation_handle_ != navigation_handle && | 110 if (navigation_handle_ != navigation_handle && |
106 (!navigation_handle->HasCommitted() || | 111 (!navigation_handle->HasCommitted() || |
107 navigation_handle->IsSameDocument())) { | 112 navigation_handle->IsSameDocument())) { |
108 return; | 113 return; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 209 } |
205 | 210 |
206 void CaptivePortalTabHelper::SetTabReloaderForTest( | 211 void CaptivePortalTabHelper::SetTabReloaderForTest( |
207 CaptivePortalTabReloader* tab_reloader) { | 212 CaptivePortalTabReloader* tab_reloader) { |
208 tab_reloader_.reset(tab_reloader); | 213 tab_reloader_.reset(tab_reloader); |
209 } | 214 } |
210 | 215 |
211 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() { | 216 CaptivePortalTabReloader* CaptivePortalTabHelper::GetTabReloaderForTest() { |
212 return tab_reloader_.get(); | 217 return tab_reloader_.get(); |
213 } | 218 } |
OLD | NEW |