| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/net/safe_search_util.h" | 5 #include "chrome/browser/net/safe_search_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // Returns whether a URL parameter, |first_parameter| (e.g. foo=bar), has the | 32 // Returns whether a URL parameter, |first_parameter| (e.g. foo=bar), has the |
| 33 // same key as the the |second_parameter| (e.g. foo=baz). Both parameters | 33 // same key as the the |second_parameter| (e.g. foo=baz). Both parameters |
| 34 // must be in key=value form. | 34 // must be in key=value form. |
| 35 bool HasSameParameterKey(const std::string& first_parameter, | 35 bool HasSameParameterKey(const std::string& first_parameter, |
| 36 const std::string& second_parameter) { | 36 const std::string& second_parameter) { |
| 37 DCHECK(second_parameter.find("=") != std::string::npos); | 37 DCHECK(second_parameter.find("=") != std::string::npos); |
| 38 // Prefix for "foo=bar" is "foo=". | 38 // Prefix for "foo=bar" is "foo=". |
| 39 std::string parameter_prefix = second_parameter.substr( | 39 std::string parameter_prefix = second_parameter.substr( |
| 40 0, second_parameter.find("=") + 1); | 40 0, second_parameter.find("=") + 1); |
| 41 return base::StartsWithASCII(first_parameter, parameter_prefix, false); | 41 return base::StartsWith(first_parameter, parameter_prefix, |
| 42 base::CompareCase::INSENSITIVE_ASCII); |
| 42 } | 43 } |
| 43 | 44 |
| 44 // Examines the query string containing parameters and adds the necessary ones | 45 // Examines the query string containing parameters and adds the necessary ones |
| 45 // so that SafeSearch is active. |query| is the string to examine and the | 46 // so that SafeSearch is active. |query| is the string to examine and the |
| 46 // return value is the |query| string modified such that SafeSearch is active. | 47 // return value is the |query| string modified such that SafeSearch is active. |
| 47 std::string AddSafeSearchParameters(const std::string& query) { | 48 std::string AddSafeSearchParameters(const std::string& query) { |
| 48 std::vector<std::string> new_parameters; | 49 std::vector<std::string> new_parameters; |
| 49 std::string safe_parameter = chrome::kSafeSearchSafeParameter; | 50 std::string safe_parameter = chrome::kSafeSearchSafeParameter; |
| 50 std::string ssui_parameter = chrome::kSafeSearchSsuiParameter; | 51 std::string ssui_parameter = chrome::kSafeSearchSsuiParameter; |
| 51 | 52 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 116 |
| 116 void ClearForceGoogleSafeSearchCountForTesting() { | 117 void ClearForceGoogleSafeSearchCountForTesting() { |
| 117 g_force_google_safe_search_count_for_test = 0; | 118 g_force_google_safe_search_count_for_test = 0; |
| 118 } | 119 } |
| 119 | 120 |
| 120 void ClearForceYouTubeSafetyModeCountForTesting() { | 121 void ClearForceYouTubeSafetyModeCountForTesting() { |
| 121 g_force_youtube_safety_mode_count_for_test = 0; | 122 g_force_youtube_safety_mode_count_for_test = 0; |
| 122 } | 123 } |
| 123 | 124 |
| 124 } // namespace safe_search_util | 125 } // namespace safe_search_util |
| OLD | NEW |