| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/recent_tab_helper.h" | 5 #include "chrome/browser/android/offline_pages/recent_tab_helper.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 download_info_.reset(); | 157 download_info_.reset(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 is_page_ready_for_snapshot_ = false; | 160 is_page_ready_for_snapshot_ = false; |
| 161 | 161 |
| 162 // New navigation, new snapshot session. | 162 // New navigation, new snapshot session. |
| 163 snapshot_url_ = web_contents()->GetLastCommittedURL(); | 163 snapshot_url_ = web_contents()->GetLastCommittedURL(); |
| 164 | 164 |
| 165 // Check for conditions that would cause us not to snapshot. | 165 // Check for conditions that would cause us not to snapshot. |
| 166 bool can_save = !navigation_handle->IsErrorPage() && | 166 bool can_save = !navigation_handle->IsErrorPage() && |
| 167 OfflinePageModel::CanSaveURL(snapshot_url_); | 167 OfflinePageModel::CanSaveURL(snapshot_url_) && |
| 168 OfflinePageUtils::GetOfflinePageFromWebContents( |
| 169 web_contents()) == nullptr; |
| 168 | 170 |
| 169 UMA_HISTOGRAM_BOOLEAN("OfflinePages.CanSaveRecentPage", can_save); | 171 UMA_HISTOGRAM_BOOLEAN("OfflinePages.CanSaveRecentPage", can_save); |
| 170 | 172 |
| 171 // Always reset so that posted tasks get canceled. | 173 // Always reset so that posted tasks get canceled. |
| 172 snapshot_controller_->Reset(); | 174 snapshot_controller_->Reset(); |
| 173 | 175 |
| 174 if (!can_save) | 176 if (!can_save) |
| 175 snapshot_controller_->Stop(); | 177 snapshot_controller_->Stop(); |
| 176 } | 178 } |
| 177 | 179 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 bool RecentTabHelper::IsSamePage() const { | 289 bool RecentTabHelper::IsSamePage() const { |
| 288 return web_contents() && | 290 return web_contents() && |
| 289 (web_contents()->GetLastCommittedURL() == snapshot_url_); | 291 (web_contents()->GetLastCommittedURL() == snapshot_url_); |
| 290 } | 292 } |
| 291 | 293 |
| 292 ClientId RecentTabHelper::GetRecentPagesClientId() const { | 294 ClientId RecentTabHelper::GetRecentPagesClientId() const { |
| 293 return ClientId(kLastNNamespace, tab_id_); | 295 return ClientId(kLastNNamespace, tab_id_); |
| 294 } | 296 } |
| 295 | 297 |
| 296 } // namespace offline_pages | 298 } // namespace offline_pages |
| OLD | NEW |