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

Unified Diff: chrome/browser/net/chrome_network_delegate.cc

Issue 2239753002: Added a ForceYouTubeRestrict policy and deprecated the old ForceYouTubeSafetyMode policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Upped id to 347 and chrome version to 55 Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/chrome_network_delegate.cc
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 6dd36c0cb099a74903ac99bd6ab1c0025f028a76..0d654f7a6d8cb9392626393ef76bbc82730ee692 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -32,7 +32,6 @@
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/net/chrome_extensions_network_delegate.h"
#include "chrome/browser/net/request_source_bandwidth_histograms.h"
-#include "chrome/browser/net/safe_search_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/task_manager/task_manager_interface.h"
#include "chrome/common/chrome_constants.h"
@@ -146,14 +145,14 @@ ChromeNetworkDelegate::ChromeNetworkDelegate(
extensions::EventRouterForwarder* event_router,
BooleanPrefMember* enable_referrers,
const metrics::UpdateUsagePrefCallbackType& metrics_data_use_forwarder)
- : profile_(NULL),
+ : profile_(nullptr),
enable_referrers_(enable_referrers),
- enable_do_not_track_(NULL),
- force_google_safe_search_(NULL),
- force_youtube_safety_mode_(NULL),
+ enable_do_not_track_(nullptr),
+ force_google_safe_search_(nullptr),
+ force_youtube_restrict_(nullptr),
allowed_domains_for_apps_(nullptr),
- url_blacklist_manager_(NULL),
- domain_reliability_monitor_(NULL),
+ url_blacklist_manager_(nullptr),
+ domain_reliability_monitor_(nullptr),
data_use_measurement_(metrics_data_use_forwarder),
experimental_web_platform_features_enabled_(
base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -194,7 +193,7 @@ void ChromeNetworkDelegate::InitializePrefsOnUIThread(
BooleanPrefMember* enable_referrers,
BooleanPrefMember* enable_do_not_track,
BooleanPrefMember* force_google_safe_search,
- BooleanPrefMember* force_youtube_safety_mode,
+ IntegerPrefMember* force_youtube_restrict,
StringPrefMember* allowed_domains_for_apps,
PrefService* pref_service) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -211,10 +210,9 @@ void ChromeNetworkDelegate::InitializePrefsOnUIThread(
force_google_safe_search->MoveToThread(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
}
- if (force_youtube_safety_mode) {
- force_youtube_safety_mode->Init(prefs::kForceYouTubeSafetyMode,
- pref_service);
- force_youtube_safety_mode->MoveToThread(
+ if (force_youtube_restrict) {
+ force_youtube_restrict->Init(prefs::kForceYouTubeRestrict, pref_service);
+ force_youtube_restrict->MoveToThread(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
}
if (allowed_domains_for_apps) {
@@ -315,8 +313,13 @@ int ChromeNetworkDelegate::OnBeforeStartTransaction(
net::URLRequest* request,
const net::CompletionCallback& callback,
net::HttpRequestHeaders* headers) {
- if (force_youtube_safety_mode_ && force_youtube_safety_mode_->GetValue())
- safe_search_util::ForceYouTubeSafetyMode(request, headers);
+ if (force_youtube_restrict_ &&
+ force_youtube_restrict_->GetValue() !=
Thiemo Nagel 2016/10/05 17:38:14 In my understanding, the static cast can blow up (
ljusten (tachyonic) 2016/10/06 10:14:45 I believe you're right. If the compiler decides to
Thiemo Nagel 2016/10/06 14:05:57 Afaiu, it's UB whenever the int is outside the enu
+ static_cast<int>(safe_search_util::YouTubeRestrictMode::kOff)) {
+ safe_search_util::ForceYouTubeRestrict(
+ request, headers, static_cast<safe_search_util::YouTubeRestrictMode>(
+ force_youtube_restrict_->GetValue()));
+ }
return extensions_delegate_->OnBeforeStartTransaction(request, callback,
headers);
@@ -416,7 +419,7 @@ ChromeNetworkDelegate::OnAuthRequired(
bool ChromeNetworkDelegate::OnCanGetCookies(
const net::URLRequest& request,
const net::CookieList& cookie_list) {
- // NULL during tests, or when we're running in the system context.
+ // nullptr during tests, or when we're running in the system context.
if (!cookie_settings_.get())
return true;
@@ -441,7 +444,7 @@ bool ChromeNetworkDelegate::OnCanGetCookies(
bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
const std::string& cookie_line,
net::CookieOptions* options) {
- // NULL during tests, or when we're running in the system context.
+ // nullptr during tests, or when we're running in the system context.
if (!cookie_settings_.get())
return true;
@@ -547,7 +550,7 @@ bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
bool ChromeNetworkDelegate::OnCanEnablePrivacyMode(
const GURL& url,
const GURL& first_party_for_cookies) const {
- // NULL during tests, or when we're running in the system context.
+ // nullptr during tests, or when we're running in the system context.
if (!cookie_settings_.get())
return false;

Powered by Google App Engine
This is Rietveld 408576698