Convert base::StringPiece to std::string_view in //components 3/5
The changes of this CL are made using the following script. Script: https://issues.chromium.org/issues/40506050#comment343 Bug: 40506050 Change-Id: I7b21541a0723d312206c786d3af570f552ceef4e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5498922 Auto-Submit: Helmut Januschka <helmut@januschka.com> Commit-Queue: Helmut Januschka <helmut@januschka.com> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1295637}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
68ba09c5a4
commit
3ae90009a0
components
prefs
default_pref_store.ccdefault_pref_store.hin_memory_pref_store.ccin_memory_pref_store.hjson_pref_store.ccjson_pref_store.hoverlay_user_pref_store.ccoverlay_user_pref_store.hpref_name_set.hpref_service.ccpref_service.hpref_store.hpref_value_map.ccpref_value_map.hpref_value_store.ccpref_value_store.hsegregated_pref_store.ccsegregated_pref_store.htesting_pref_store.cctesting_pref_store.hvalue_map_pref_store.ccvalue_map_pref_store.h
printing
safe_browsing
content
browser
renderer
core
safe_search_api
search_engines
android
keyword_table.ccsearch_engine_choice
search_host_to_urls_map.ccsearch_host_to_urls_map.htemplate_url.cctemplate_url.htemplate_url_data.cctemplate_url_data.htemplate_url_data_unittest.cctemplate_url_data_util.ccsearch_provider_logos
segmentation_platform
embedder
default_model
internal
data_collection
database
execution
processing
metrics
segmentation_platform_service_test_base.ccsegmentation_ukm_helper_unittest.ccselection
stats.ccpublic
sessions
shared_highlighting
signin
core
browser
internal
identity_manager
public
speech
@ -5,13 +5,13 @@
|
||||
#include "components/safe_search_api/safe_search_util.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "components/google/core/common/google_util.h"
|
||||
@ -24,11 +24,11 @@ namespace {
|
||||
// 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
|
||||
// must be in key=value form.
|
||||
bool HasSameParameterKey(base::StringPiece first_parameter,
|
||||
base::StringPiece second_parameter) {
|
||||
bool HasSameParameterKey(std::string_view first_parameter,
|
||||
std::string_view second_parameter) {
|
||||
DCHECK(second_parameter.find("=") != std::string::npos);
|
||||
// Prefix for "foo=bar" is "foo=".
|
||||
base::StringPiece parameter_prefix =
|
||||
std::string_view parameter_prefix =
|
||||
second_parameter.substr(0, second_parameter.find("=") + 1);
|
||||
return base::StartsWith(first_parameter, parameter_prefix,
|
||||
base::CompareCase::INSENSITIVE_ASCII);
|
||||
@ -38,11 +38,11 @@ bool HasSameParameterKey(base::StringPiece first_parameter,
|
||||
// so that SafeSearch is active. |query| is the string to examine and the
|
||||
// return value is the |query| string modified such that SafeSearch is active.
|
||||
std::string AddSafeSearchParameters(const std::string& query) {
|
||||
std::vector<base::StringPiece> new_parameters;
|
||||
std::vector<std::string_view> new_parameters;
|
||||
std::string safe_parameter = safe_search_api::kSafeSearchSafeParameter;
|
||||
std::string ssui_parameter = safe_search_api::kSafeSearchSsuiParameter;
|
||||
|
||||
for (const base::StringPiece& param : base::SplitStringPiece(
|
||||
for (std::string_view param : base::SplitStringPiece(
|
||||
query, "&", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
|
||||
if (!HasSameParameterKey(param, safe_parameter) &&
|
||||
!HasSameParameterKey(param, ssui_parameter)) {
|
||||
|
Reference in New Issue
Block a user