OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/android/offline_pages/offline_page_tab_helper.h" | 5 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "chrome/browser/android/offline_pages/offline_page_request_job.h" | 10 #include "chrome/browser/android/offline_pages/offline_page_request_job.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 // This is a new navigation so we can invalidate any previously scheduled | 50 // This is a new navigation so we can invalidate any previously scheduled |
51 // operations. | 51 // operations. |
52 weak_ptr_factory_.InvalidateWeakPtrs(); | 52 weak_ptr_factory_.InvalidateWeakPtrs(); |
53 reloading_url_on_net_error_ = false; | 53 reloading_url_on_net_error_ = false; |
54 | 54 |
55 // The provisional offline info can be cleared no matter how. | 55 // The provisional offline info can be cleared no matter how. |
56 provisional_offline_info_.Clear(); | 56 provisional_offline_info_.Clear(); |
57 | 57 |
58 // If not a fragment navigation, clear the cached offline info. | 58 // If not a fragment navigation, clear the cached offline info. |
59 if (offline_info_.offline_page.get() && !navigation_handle->IsSamePage()) { | 59 if (offline_info_.offline_page.get() && |
| 60 !navigation_handle->IsSameDocument()) { |
60 offline_info_.Clear(); | 61 offline_info_.Clear(); |
61 } | 62 } |
62 } | 63 } |
63 | 64 |
64 void OfflinePageTabHelper::DidFinishNavigation( | 65 void OfflinePageTabHelper::DidFinishNavigation( |
65 content::NavigationHandle* navigation_handle) { | 66 content::NavigationHandle* navigation_handle) { |
66 // Skips non-main frame. | 67 // Skips non-main frame. |
67 if (!navigation_handle->IsInMainFrame()) | 68 if (!navigation_handle->IsInMainFrame()) |
68 return; | 69 return; |
69 | 70 |
70 if (!navigation_handle->HasCommitted()) | 71 if (!navigation_handle->HasCommitted()) |
71 return; | 72 return; |
72 | 73 |
73 if (navigation_handle->IsSamePage()) | 74 if (navigation_handle->IsSameDocument()) |
74 return; | 75 return; |
75 | 76 |
76 GURL navigated_url = navigation_handle->GetURL(); | 77 GURL navigated_url = navigation_handle->GetURL(); |
77 if (navigation_handle->IsErrorPage()) { | 78 if (navigation_handle->IsErrorPage()) { |
78 offline_info_.Clear(); | 79 offline_info_.Clear(); |
79 } else { | 80 } else { |
80 // The provisional offline info can now be committed if the navigation is | 81 // The provisional offline info can now be committed if the navigation is |
81 // done without error. | 82 // done without error. |
82 DCHECK(!provisional_offline_info_.offline_page || | 83 DCHECK(!provisional_offline_info_.offline_page || |
83 OfflinePageUtils::EqualsIgnoringFragment( | 84 OfflinePageUtils::EqualsIgnoringFragment( |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 179 } |
179 | 180 |
180 bool OfflinePageTabHelper::IsShowingOfflinePreview() const { | 181 bool OfflinePageTabHelper::IsShowingOfflinePreview() const { |
181 // TODO(ryansturm): Change this once offline pages infrastructure uses | 182 // TODO(ryansturm): Change this once offline pages infrastructure uses |
182 // NavigationHandle instead of a back channel. crbug.com/658899 | 183 // NavigationHandle instead of a back channel. crbug.com/658899 |
183 return provisional_offline_info_.is_showing_offline_preview || | 184 return provisional_offline_info_.is_showing_offline_preview || |
184 offline_info_.is_showing_offline_preview; | 185 offline_info_.is_showing_offline_preview; |
185 } | 186 } |
186 | 187 |
187 } // namespace offline_pages | 188 } // namespace offline_pages |
OLD | NEW |