| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 ReportSnapshotCompleted(); | 160 ReportSnapshotCompleted(); |
| 161 return; | 161 return; |
| 162 } | 162 } |
| 163 | 163 |
| 164 if (!IsSamePage()) { | 164 if (!IsSamePage()) { |
| 165 ReportSnapshotCompleted(); | 165 ReportSnapshotCompleted(); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 | 168 |
| 169 page_model_->SavePage( | 169 page_model_->SavePage( |
| 170 snapshot_url_, client_id(), | 170 snapshot_url_, client_id(), 0ul, |
| 171 delegate_->CreatePageArchiver(web_contents()), | 171 delegate_->CreatePageArchiver(web_contents()), |
| 172 base::Bind(&RecentTabHelper::SavePageCallback, | 172 base::Bind(&RecentTabHelper::SavePageCallback, |
| 173 weak_ptr_factory_.GetWeakPtr())); | 173 weak_ptr_factory_.GetWeakPtr())); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void RecentTabHelper::SavePageCallback(OfflinePageModel::SavePageResult result, | 176 void RecentTabHelper::SavePageCallback(OfflinePageModel::SavePageResult result, |
| 177 int64_t offline_id) { | 177 int64_t offline_id) { |
| 178 ReportSnapshotCompleted(); | 178 ReportSnapshotCompleted(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void RecentTabHelper::ReportSnapshotCompleted() { | 181 void RecentTabHelper::ReportSnapshotCompleted() { |
| 182 snapshot_controller_->PendingSnapshotCompleted(); | 182 snapshot_controller_->PendingSnapshotCompleted(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 bool RecentTabHelper::IsSamePage() const { | 185 bool RecentTabHelper::IsSamePage() const { |
| 186 return web_contents() && | 186 return web_contents() && |
| 187 (web_contents()->GetLastCommittedURL() == snapshot_url_); | 187 (web_contents()->GetLastCommittedURL() == snapshot_url_); |
| 188 } | 188 } |
| 189 | 189 |
| 190 ClientId RecentTabHelper::client_id() const { | 190 ClientId RecentTabHelper::client_id() const { |
| 191 return ClientId(kLastNNamespace, tab_id_); | 191 return ClientId(kLastNNamespace, tab_id_); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace offline_pages | 194 } // namespace offline_pages |
| OLD | NEW |