Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: chrome/browser/android/offline_pages/background_loader_offliner.cc

Issue 2835193005: Offline Pages - Policy cleanup (Closed)
Patch Set: Fix typo Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/prerendering_offliner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return data->offliner(); 112 return data->offliner();
113 return nullptr; 113 return nullptr;
114 } 114 }
115 115
116 bool BackgroundLoaderOffliner::LoadAndSave( 116 bool BackgroundLoaderOffliner::LoadAndSave(
117 const SavePageRequest& request, 117 const SavePageRequest& request,
118 const CompletionCallback& completion_callback, 118 const CompletionCallback& completion_callback,
119 const ProgressCallback& progress_callback) { 119 const ProgressCallback& progress_callback) {
120 DCHECK(completion_callback); 120 DCHECK(completion_callback);
121 DCHECK(progress_callback); 121 DCHECK(progress_callback);
122 DCHECK(offline_page_model_);
122 123
123 if (pending_request_) { 124 if (pending_request_) {
124 DVLOG(1) << "Already have pending request"; 125 DVLOG(1) << "Already have pending request";
125 return false; 126 return false;
126 } 127 }
127 128
128 // Do not allow loading for custom tabs clients if 3rd party cookies blocked. 129 ClientPolicyController* policy_controller =
129 // TODO(dewittj): Revise api to specify policy rather than hard code to 130 offline_page_model_->GetPolicyController();
130 // name_space. 131 if (policy_controller->IsDisabledWhenPrefetchDisabled(
131 if (request.client_id().name_space == kCCTNamespace && 132 request.client_id().name_space) &&
132 (AreThirdPartyCookiesBlocked(browser_context_) || 133 (AreThirdPartyCookiesBlocked(browser_context_) ||
133 IsNetworkPredictionDisabled(browser_context_))) { 134 IsNetworkPredictionDisabled(browser_context_))) {
134 DVLOG(1) << "WARNING: Unable to load when 3rd party cookies blocked or " 135 DVLOG(1) << "WARNING: Unable to load when 3rd party cookies blocked or "
135 << "prediction disabled"; 136 << "prediction disabled";
136 // Record user metrics for third party cookies being disabled or network 137 // Record user metrics for third party cookies being disabled or network
137 // prediction being disabled. 138 // prediction being disabled.
138 if (AreThirdPartyCookiesBlocked(browser_context_)) { 139 if (AreThirdPartyCookiesBlocked(browser_context_)) {
139 UMA_HISTOGRAM_ENUMERATION( 140 UMA_HISTOGRAM_ENUMERATION(
140 "OfflinePages.Background.CctApiDisableStatus", 141 "OfflinePages.Background.CctApiDisableStatus",
141 static_cast<int>(OfflinePagesCctApiPrerenderAllowedStatus:: 142 static_cast<int>(OfflinePagesCctApiPrerenderAllowedStatus::
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // Given the choice between int and double, we choose to implicitly convert to 474 // Given the choice between int and double, we choose to implicitly convert to
474 // a double since it maintains more precision (we can get a longer time in 475 // a double since it maintains more precision (we can get a longer time in
475 // milliseconds than we can with a 2 bit int, 53 bits vs 32). 476 // milliseconds than we can with a 2 bit int, 53 bits vs 32).
476 double delay = delay_so_far.InMilliseconds(); 477 double delay = delay_so_far.InMilliseconds();
477 signal_data_.SetDouble(signal_name, delay); 478 signal_data_.SetDouble(signal_name, delay);
478 } 479 }
479 480
480 } // namespace offline_pages 481 } // namespace offline_pages
481 482
482 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData); 483 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/prerendering_offliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698