| 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/background_loader_offliner.h" | 5 #include "chrome/browser/android/offline_pages/background_loader_offliner.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 9 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
| 10 #include "chrome/browser/android/offline_pages/offliner_helper.h" | 10 #include "chrome/browser/android/offline_pages/offliner_helper.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 new OfflinePageMHTMLArchiver(web_contents)); | 155 new OfflinePageMHTMLArchiver(web_contents)); |
| 156 | 156 |
| 157 OfflinePageModel::SavePageParams params; | 157 OfflinePageModel::SavePageParams params; |
| 158 params.url = web_contents->GetLastCommittedURL(); | 158 params.url = web_contents->GetLastCommittedURL(); |
| 159 params.client_id = request.client_id(); | 159 params.client_id = request.client_id(); |
| 160 params.proposed_offline_id = request.request_id(); | 160 params.proposed_offline_id = request.request_id(); |
| 161 params.is_background = true; | 161 params.is_background = true; |
| 162 | 162 |
| 163 // Pass in the original URL if it's different from last committed | 163 // Pass in the original URL if it's different from last committed |
| 164 // when redirects occur. | 164 // when redirects occur. |
| 165 if (params.url != request.url()) | 165 if (!request.original_url().is_empty()) |
| 166 params.original_url = request.original_url(); |
| 167 else if (params.url != request.url()) |
| 166 params.original_url = request.url(); | 168 params.original_url = request.url(); |
| 167 | 169 |
| 168 offline_page_model_->SavePage( | 170 offline_page_model_->SavePage( |
| 169 params, std::move(archiver), | 171 params, std::move(archiver), |
| 170 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, | 172 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, |
| 171 weak_ptr_factory_.GetWeakPtr())); | 173 weak_ptr_factory_.GetWeakPtr())); |
| 172 } | 174 } |
| 173 | 175 |
| 174 void BackgroundLoaderOffliner::RenderProcessGone( | 176 void BackgroundLoaderOffliner::RenderProcessGone( |
| 175 base::TerminationStatus status) { | 177 base::TerminationStatus status) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 application_state == | 283 application_state == |
| 282 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { | 284 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { |
| 283 DVLOG(1) << "App became active, canceling current offlining request"; | 285 DVLOG(1) << "App became active, canceling current offlining request"; |
| 284 SavePageRequest* request = pending_request_.get(); | 286 SavePageRequest* request = pending_request_.get(); |
| 285 Cancel(); | 287 Cancel(); |
| 286 completion_callback_.Run(*request, RequestStatus::FOREGROUND_CANCELED); | 288 completion_callback_.Run(*request, RequestStatus::FOREGROUND_CANCELED); |
| 287 } | 289 } |
| 288 } | 290 } |
| 289 | 291 |
| 290 } // namespace offline_pages | 292 } // namespace offline_pages |
| OLD | NEW |