| 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/prerendering_offliner.h" | 5 #include "chrome/browser/android/offline_pages/prerendering_offliner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 177 } |
| 178 saved_on_last_retry_ = false; | 178 saved_on_last_retry_ = false; |
| 179 completion_callback_.Run(request, save_status); | 179 completion_callback_.Run(request, save_status); |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool PrerenderingOffliner::LoadAndSave( | 182 bool PrerenderingOffliner::LoadAndSave( |
| 183 const SavePageRequest& request, | 183 const SavePageRequest& request, |
| 184 const CompletionCallback& completion_callback, | 184 const CompletionCallback& completion_callback, |
| 185 const ProgressCallback& progress_callback) { | 185 const ProgressCallback& progress_callback) { |
| 186 DCHECK(!pending_request_.get()); | 186 DCHECK(!pending_request_.get()); |
| 187 DCHECK(offline_page_model_); |
| 187 | 188 |
| 188 if (pending_request_) { | 189 if (pending_request_) { |
| 189 DVLOG(1) << "Already have pending request"; | 190 DVLOG(1) << "Already have pending request"; |
| 190 return false; | 191 return false; |
| 191 } | 192 } |
| 192 | 193 |
| 193 // Do not allow loading for custom tabs clients if 3rd party cookies blocked. | 194 ClientPolicyController* policy_controller = |
| 194 // TODO(dewittj): Revise api to specify policy rather than hard code to | 195 offline_page_model_->GetPolicyController(); |
| 195 // name_space. | 196 if (policy_controller->IsDisabledWhenPrefetchDisabled( |
| 196 if (request.client_id().name_space == kCCTNamespace && | 197 request.client_id().name_space) && |
| 197 (AreThirdPartyCookiesBlocked(browser_context_) || | 198 (AreThirdPartyCookiesBlocked(browser_context_) || |
| 198 IsNetworkPredictionDisabled(browser_context_))) { | 199 IsNetworkPredictionDisabled(browser_context_))) { |
| 199 DVLOG(1) << "WARNING: Unable to load when 3rd party cookies blocked or " | 200 DVLOG(1) << "WARNING: Unable to load when 3rd party cookies blocked or " |
| 200 << "prediction disabled"; | 201 << "prediction disabled"; |
| 201 // Record user metrics for third party cookies being disabled or network | 202 // Record user metrics for third party cookies being disabled or network |
| 202 // prediction being disabled. | 203 // prediction being disabled. |
| 203 if (AreThirdPartyCookiesBlocked(browser_context_)) { | 204 if (AreThirdPartyCookiesBlocked(browser_context_)) { |
| 204 UMA_HISTOGRAM_ENUMERATION( | 205 UMA_HISTOGRAM_ENUMERATION( |
| 205 "OfflinePages.Background.CctApiDisableStatus", | 206 "OfflinePages.Background.CctApiDisableStatus", |
| 206 static_cast<int>(OfflinePagesCctApiPrerenderAllowedStatus:: | 207 static_cast<int>(OfflinePagesCctApiPrerenderAllowedStatus:: |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { | 330 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { |
| 330 DVLOG(1) << "App became active, canceling current offlining request"; | 331 DVLOG(1) << "App became active, canceling current offlining request"; |
| 331 // No need to check the return value or complete early, as false would | 332 // No need to check the return value or complete early, as false would |
| 332 // indicate that there was no request, in which case the state change is | 333 // indicate that there was no request, in which case the state change is |
| 333 // ignored. | 334 // ignored. |
| 334 Cancel( | 335 Cancel( |
| 335 base::Bind(HandleApplicationStateChangeCancel, completion_callback_)); | 336 base::Bind(HandleApplicationStateChangeCancel, completion_callback_)); |
| 336 } | 337 } |
| 337 } | 338 } |
| 338 } // namespace offline_pages | 339 } // namespace offline_pages |
| OLD | NEW |