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

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

Issue 2401743003: Recommit and fix of "Added a ForceYouTubeRestrict policy and deprecated the old ForceYouTubeSafetyM… (Closed)
Patch Set: Rebase Created 4 years, 2 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
« no previous file with comments | « chrome/browser/net/safe_search_util.h ('k') | chrome/browser/net/safe_search_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/safe_search_util.cc
diff --git a/chrome/browser/net/safe_search_util.cc b/chrome/browser/net/safe_search_util.cc
index 17bda6605a805c9583e7d8aeaf551940cfb5e296..ad11eb26da7bb27d2d0974b98705b646529102a5 100644
--- a/chrome/browser/net/safe_search_util.cc
+++ b/chrome/browser/net/safe_search_util.cc
@@ -25,10 +25,11 @@
namespace {
int g_force_google_safe_search_count_for_test = 0;
-int g_force_youtube_safety_mode_count_for_test = 0;
+int g_force_youtube_restrict_count_for_test = 0;
-const char kYouTubeSafetyModeHeaderName[] = "YouTube-Safety-Mode";
-const char kYouTubeSafetyModeHeaderValue[] = "Active";
+const char kYouTubeRestrictHeaderName[] = "YouTube-Restrict";
+const char kYouTubeRestrictHeaderValueModerate[] = "Moderate";
+const char kYouTubeRestrictHeaderValueStrict[] = "Strict";
// Returns whether a URL parameter, |first_parameter| (e.g. foo=bar), has the
// same key as the the |second_parameter| (e.g. foo=baz). Both parameters
@@ -88,11 +89,10 @@ void ForceGoogleSafeSearch(const net::URLRequest* request, GURL* new_url) {
*new_url = request->url().ReplaceComponents(replacements);
}
-// If |request| is a request to YouTube, enforces YouTube's Safety Mode by
-// setting YouTube's Safety Mode header.
-void ForceYouTubeSafetyMode(const net::URLRequest* request,
- net::HttpRequestHeaders* headers) {
- ++g_force_youtube_safety_mode_count_for_test;
+void ForceYouTubeRestrict(const net::URLRequest* request,
+ net::HttpRequestHeaders* headers,
+ YouTubeRestrictMode mode) {
+ ++g_force_youtube_restrict_count_for_test;
if (!google_util::IsYoutubeDomainUrl(
request->url(),
@@ -100,24 +100,38 @@ void ForceYouTubeSafetyMode(const net::URLRequest* request,
google_util::DISALLOW_NON_STANDARD_PORTS))
return;
- headers->SetHeader(kYouTubeSafetyModeHeaderName,
- kYouTubeSafetyModeHeaderValue);
+ switch (mode) {
+ case YOUTUBE_RESTRICT_OFF:
+ case YOUTUBE_RESTRICT_COUNT:
+ NOTREACHED();
+ break;
+
+ case YOUTUBE_RESTRICT_MODERATE:
+ headers->SetHeader(kYouTubeRestrictHeaderName,
+ kYouTubeRestrictHeaderValueModerate);
+ break;
+
+ case YOUTUBE_RESTRICT_STRICT:
+ headers->SetHeader(kYouTubeRestrictHeaderName,
+ kYouTubeRestrictHeaderValueStrict);
+ break;
+ }
}
int GetForceGoogleSafeSearchCountForTesting() {
return g_force_google_safe_search_count_for_test;
}
-int GetForceYouTubeSafetyModeCountForTesting() {
- return g_force_youtube_safety_mode_count_for_test;
+int GetForceYouTubeRestrictCountForTesting() {
+ return g_force_youtube_restrict_count_for_test;
}
void ClearForceGoogleSafeSearchCountForTesting() {
g_force_google_safe_search_count_for_test = 0;
}
-void ClearForceYouTubeSafetyModeCountForTesting() {
- g_force_youtube_safety_mode_count_for_test = 0;
+void ClearForceYouTubeRestrictCountForTesting() {
+ g_force_youtube_restrict_count_for_test = 0;
}
} // namespace safe_search_util
« no previous file with comments | « chrome/browser/net/safe_search_util.h ('k') | chrome/browser/net/safe_search_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698