| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 // When there is no valid tab android there is nowhere to show the offline | 125 // When there is no valid tab android there is nowhere to show the offline |
| 126 // page, so we can leave. | 126 // page, so we can leave. |
| 127 int tab_id; | 127 int tab_id; |
| 128 if (!OfflinePageUtils::GetTabId(web_contents(), &tab_id)) { | 128 if (!OfflinePageUtils::GetTabId(web_contents(), &tab_id)) { |
| 129 // No need to report NO_TAB_ID since it should have already been detected | 129 // No need to report NO_TAB_ID since it should have already been detected |
| 130 // and reported in offline page request handler. | 130 // and reported in offline page request handler. |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 | 133 |
| 134 OfflinePageUtils::SelectPageForOnlineURL( | 134 OfflinePageUtils::SelectPageForURL( |
| 135 web_contents()->GetBrowserContext(), | 135 web_contents()->GetBrowserContext(), |
| 136 navigated_url, | 136 navigated_url, |
| 137 OfflinePageModel::URLSearchMode::SEARCH_BY_ALL_URLS, |
| 137 tab_id, | 138 tab_id, |
| 138 base::Bind(&OfflinePageTabHelper::SelectPageForOnlineURLDone, | 139 base::Bind(&OfflinePageTabHelper::SelectPageForURLDone, |
| 139 weak_ptr_factory_.GetWeakPtr())); | 140 weak_ptr_factory_.GetWeakPtr())); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void OfflinePageTabHelper::SelectPageForOnlineURLDone( | 143 void OfflinePageTabHelper::SelectPageForURLDone( |
| 143 const OfflinePageItem* offline_page) { | 144 const OfflinePageItem* offline_page) { |
| 144 // Bails out if no offline page is found. | 145 // Bails out if no offline page is found. |
| 145 if (!offline_page) { | 146 if (!offline_page) { |
| 146 OfflinePageRequestJob::ReportAggregatedRequestResult( | 147 OfflinePageRequestJob::ReportAggregatedRequestResult( |
| 147 OfflinePageRequestJob::AggregatedRequestResult:: | 148 OfflinePageRequestJob::AggregatedRequestResult:: |
| 148 PAGE_NOT_FOUND_ON_FLAKY_NETWORK); | 149 PAGE_NOT_FOUND_ON_FLAKY_NETWORK); |
| 149 return; | 150 return; |
| 150 } | 151 } |
| 151 | 152 |
| 152 reloading_url_on_net_error_ = true; | 153 reloading_url_on_net_error_ = true; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 177 } | 178 } |
| 178 | 179 |
| 179 bool OfflinePageTabHelper::IsShowingOfflinePreview() const { | 180 bool OfflinePageTabHelper::IsShowingOfflinePreview() const { |
| 180 // TODO(ryansturm): Change this once offline pages infrastructure uses | 181 // TODO(ryansturm): Change this once offline pages infrastructure uses |
| 181 // NavigationHandle instead of a back channel. crbug.com/658899 | 182 // NavigationHandle instead of a back channel. crbug.com/658899 |
| 182 return provisional_offline_info_.is_showing_offline_preview || | 183 return provisional_offline_info_.is_showing_offline_preview || |
| 183 offline_info_.is_showing_offline_preview; | 184 offline_info_.is_showing_offline_preview; |
| 184 } | 185 } |
| 185 | 186 |
| 186 } // namespace offline_pages | 187 } // namespace offline_pages |
| OLD | NEW |