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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 content::WebContentsObserver::web_contents()); | 146 content::WebContentsObserver::web_contents()); |
147 | 147 |
148 std::unique_ptr<OfflinePageArchiver> archiver( | 148 std::unique_ptr<OfflinePageArchiver> archiver( |
149 new OfflinePageMHTMLArchiver(web_contents)); | 149 new OfflinePageMHTMLArchiver(web_contents)); |
150 | 150 |
151 OfflinePageModel::SavePageParams params; | 151 OfflinePageModel::SavePageParams params; |
152 params.url = web_contents->GetLastCommittedURL(); | 152 params.url = web_contents->GetLastCommittedURL(); |
153 params.client_id = request.client_id(); | 153 params.client_id = request.client_id(); |
154 params.proposed_offline_id = request.request_id(); | 154 params.proposed_offline_id = request.request_id(); |
155 params.is_background = true; | 155 params.is_background = true; |
156 | |
157 // Pass in the original URL if it is different from the last committed URL | |
158 // when redirects occur. | |
fgorski
2017/02/27 17:34:35
please sync. I think Cathy was making a similar ch
jianli
2017/02/27 23:20:06
Synced. Cathy ported my previous original URL chan
| |
159 if (!request.original_url().is_empty()) | |
160 params.original_url = request.original_url(); | |
161 else if (params.url != request.url()) | |
162 params.original_url = request.url(); | |
163 | |
156 offline_page_model_->SavePage( | 164 offline_page_model_->SavePage( |
157 params, std::move(archiver), | 165 params, std::move(archiver), |
158 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, | 166 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, |
159 weak_ptr_factory_.GetWeakPtr())); | 167 weak_ptr_factory_.GetWeakPtr())); |
160 } | 168 } |
161 | 169 |
162 void BackgroundLoaderOffliner::RenderProcessGone( | 170 void BackgroundLoaderOffliner::RenderProcessGone( |
163 base::TerminationStatus status) { | 171 base::TerminationStatus status) { |
164 if (pending_request_) { | 172 if (pending_request_) { |
165 SavePageRequest request(*pending_request_.get()); | 173 SavePageRequest request(*pending_request_.get()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 application_state == | 277 application_state == |
270 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { | 278 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { |
271 DVLOG(1) << "App became active, canceling current offlining request"; | 279 DVLOG(1) << "App became active, canceling current offlining request"; |
272 SavePageRequest* request = pending_request_.get(); | 280 SavePageRequest* request = pending_request_.get(); |
273 Cancel(); | 281 Cancel(); |
274 completion_callback_.Run(*request, RequestStatus::FOREGROUND_CANCELED); | 282 completion_callback_.Run(*request, RequestStatus::FOREGROUND_CANCELED); |
275 } | 283 } |
276 } | 284 } |
277 | 285 |
278 } // namespace offline_pages | 286 } // namespace offline_pages |
OLD | NEW |