Convert base::StringPiece to std::string_view in //content except for
content/browser The changes of this CL are made using the following script. ``` target_directory="content" replace_string_in_files() { old_string="$1" new_string="$2" find "$target_directory" -type d \( -path "$target_directory/browser" -prune \) -o \( -name "*.cc" -o -name "*.h" \) -exec sed -i '' "s/$old_string/$new_string/g" {} + } delete_include() { find "$target_directory" -type d \( -path "$target_directory/browser" -prune \) -o \( -name "*.h" -o -name "*.cc" \) -print0 | while IFS= read -r -d '' file; do grep -v '#include "base/strings/string_piece.h"' "$file" > "$file.tmp" && mv "$file.tmp" "$file" done } add_include() { find "$target_directory" -type d \( -path "$target_directory/browser" -prune \) -o \( -name "*.h" -o -name "*.cc" \) -print0 | while IFS= read -r -d '' file; do local include_added=false local tempfile=$(mktemp) if grep -qE 'std::(string|u16string)_view' "$file"; then while IFS= read -r line; do echo "$line" >> "$tempfile" if [[ $line =~ ^\s*#include ]]; then if ! $include_added; then echo "#include <string_view>" >> "$tempfile" include_added=true fi fi done < "$file" mv "$tempfile" "$file" if $include_added; then echo "Added #include <string_view> after the first include line in $file" else echo "No include line found in $file" fi else echo "std::string_view not found in $file" fi done } replace_string_in_files "base::StringPiece16" "std::u16string_view" replace_string_in_files "base::StringPiece" "std::string_view" delete_include add_include ``` Replaced base::StringPiece16 with std::u16string_view Replaced base::StringPiece with std::string_view Removed header "base/strings/string_piece.h" Added header "<string_view>" where applicable Bug: 40506050 Change-Id: Ia6d2fd65a16e1a3db59532c085652fbb45dc6abc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5401324 Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Rakina Zata Amni <rakina@chromium.org> Cr-Commit-Position: refs/heads/main@{#1285651}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b9e30b7251
commit
8d4451517d
content
app
child
common
public
browser
authenticator_request_client_delegate.ccauthenticator_request_client_delegate.hback_forward_cache.hbackground_tracing_manager.hchild_process_security_policy.hcontent_browser_client.cccontent_browser_client.hdocument_service.hgpu_utils.ccmojo_binder_policy_map.horigin_trials_controller_delegate.hservice_process_host.hweb_contents_media_capture_id.ccweb_ui.hweb_ui_data_source.hweb_ui_message_handler.hwebui_config.ccwebui_config.h
common
test
back_forward_cache_util.hbrowser_test_utils.ccbrowser_test_utils.hcontent_browser_test_content_browser_client.cccontent_browser_test_content_browser_client.hcontent_test_suite_base.ccscoped_page_focus_override.cctest_devtools_protocol_client.cctest_web_ui.cctest_web_ui.hurl_loader_interceptor.ccurl_loader_interceptor.hweb_ui_browsertest_util.ccweb_ui_browsertest_util.h
renderer
accessibility
gpu_benchmarking_extension.ccpepper
render_frame_impl.ccrender_frame_impl.hrender_thread_impl.ccsandbox_mac_v2_unittest.mmv8_value_converter_impl.ccservices
auction_worklet
shell
browser
fuchsia_view_presenter.ccshell.hshell_content_browser_client.ccshell_devtools_bindings.ccshell_platform_delegate_android.cc
common
test
web_test
@ -10,6 +10,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@ -521,7 +522,7 @@ bool ShouldAllowSystemTracingConsumer() {
|
||||
void CreateChildThreadPool(const std::string& process_type) {
|
||||
// Thread pool should only be initialized once.
|
||||
DCHECK(!base::ThreadPoolInstance::Get());
|
||||
base::StringPiece thread_pool_name;
|
||||
std::string_view thread_pool_name;
|
||||
if (process_type == switches::kGpuProcess)
|
||||
thread_pool_name = "GPU";
|
||||
else if (process_type == switches::kRendererProcess)
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/functional/overloaded.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/task/thread_pool/thread_pool_instance.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/app/content_main_delegate.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
@ -20,7 +21,6 @@
|
||||
#include "base/run_loop.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
@ -160,7 +160,7 @@ void BlinkPlatformImpl::RecordAction(const blink::UserMetricsAction& name) {
|
||||
WebData BlinkPlatformImpl::GetDataResource(
|
||||
int resource_id,
|
||||
ui::ResourceScaleFactor scale_factor) {
|
||||
base::StringPiece resource =
|
||||
std::string_view resource =
|
||||
GetContentClient()->GetDataResource(resource_id, scale_factor);
|
||||
return WebData(resource.data(), resource.size());
|
||||
}
|
||||
|
@ -4,10 +4,9 @@
|
||||
|
||||
#include "content/child/dwrite_font_proxy/dwrite_localized_strings_win.h"
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace content {
|
||||
|
||||
@ -19,7 +18,7 @@ HRESULT DWriteLocalizedStrings::FindLocaleName(const WCHAR* locale_name,
|
||||
UINT32* index,
|
||||
BOOL* exists) {
|
||||
static_assert(sizeof(WCHAR) == sizeof(char16_t), "WCHAR should be UTF-16.");
|
||||
const base::StringPiece16 locale_name_str(
|
||||
const std::u16string_view locale_name_str(
|
||||
reinterpret_cast<const char16_t*>(locale_name));
|
||||
for (size_t n = 0; n < strings_.size(); ++n) {
|
||||
if (strings_[n].first == locale_name_str) {
|
||||
|
@ -43,7 +43,7 @@ namespace {
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
|
||||
std::wstring ToNativeString(base::StringPiece string) {
|
||||
std::wstring ToNativeString(std::string_view string) {
|
||||
return base::ASCIIToWide(string);
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include "content/public/browser/authenticator_request_client_delegate.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "content/browser/webauth/authenticator_environment.h"
|
||||
@ -215,7 +215,7 @@ void AuthenticatorRequestClientDelegate::FidoAuthenticatorAdded(
|
||||
const device::FidoAuthenticator& authenticator) {}
|
||||
|
||||
void AuthenticatorRequestClientDelegate::FidoAuthenticatorRemoved(
|
||||
base::StringPiece device_id) {}
|
||||
std::string_view device_id) {}
|
||||
|
||||
bool AuthenticatorRequestClientDelegate::SupportsPIN() const {
|
||||
return false;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/span.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
@ -369,7 +370,7 @@ class CONTENT_EXPORT AuthenticatorRequestClientDelegate
|
||||
void BluetoothAdapterPowerChanged(bool is_powered_on) override;
|
||||
void FidoAuthenticatorAdded(
|
||||
const device::FidoAuthenticator& authenticator) override;
|
||||
void FidoAuthenticatorRemoved(base::StringPiece device_id) override;
|
||||
void FidoAuthenticatorRemoved(std::string_view device_id) override;
|
||||
bool SupportsPIN() const override;
|
||||
void CollectPIN(
|
||||
CollectPINOptions options,
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <optional>
|
||||
#include <set>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "content/public/browser/global_routing_id.h"
|
||||
#include "services/metrics/public/cpp/ukm_source_id.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/token.h"
|
||||
#include "base/trace_event/trace_event_impl.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "content/common/content_export.h"
|
||||
@ -340,7 +341,7 @@ class ChildProcessSecurityPolicy {
|
||||
// Note that wildcards can only be added using this version of
|
||||
// AddFutureIsolatedOrigins(); they cannot be specified in a url::Origin().
|
||||
virtual void AddFutureIsolatedOrigins(
|
||||
base::StringPiece origins_to_add,
|
||||
std::string_view origins_to_add,
|
||||
IsolatedOriginSource source,
|
||||
BrowserContext* browser_context = nullptr) = 0;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "content/public/browser/content_browser_client.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/check.h"
|
||||
@ -13,7 +14,6 @@
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/task/thread_pool/thread_pool_instance.h"
|
||||
#include "base/values.h"
|
||||
@ -186,13 +186,13 @@ bool ContentBrowserClient::DoesWebUIUrlRequireProcessLock(const GURL& url) {
|
||||
}
|
||||
|
||||
bool ContentBrowserClient::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
|
||||
base::StringPiece scheme,
|
||||
std::string_view scheme,
|
||||
bool is_embedded_origin_secure) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContentBrowserClient::ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
|
||||
base::StringPiece scheme,
|
||||
std::string_view scheme,
|
||||
bool is_embedded_origin_secure) {
|
||||
return false;
|
||||
}
|
||||
@ -1188,7 +1188,7 @@ bool ContentBrowserClient::ShowPaymentHandlerWindow(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContentBrowserClient::CreateThreadPool(base::StringPiece name) {
|
||||
bool ContentBrowserClient::CreateThreadPool(std::string_view name) {
|
||||
base::ThreadPoolInstance::Create(name);
|
||||
return true;
|
||||
}
|
||||
|
@ -12,13 +12,13 @@
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/flat_map.h"
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/types/strong_alias.h"
|
||||
#include "base/values.h"
|
||||
@ -461,7 +461,7 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
// matching_scheme_cookies_allowed_schemes, but maybe we should remove that
|
||||
// anyway.
|
||||
virtual bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
|
||||
base::StringPiece scheme,
|
||||
std::string_view scheme,
|
||||
bool is_embedded_origin_secure);
|
||||
|
||||
// Similar to the above. Returns whether SameSite cookie restrictions should
|
||||
@ -472,7 +472,7 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
// be different, as SameSite restrictions and third-party cookie blocking are
|
||||
// related but have different semantics.
|
||||
virtual bool ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
|
||||
base::StringPiece scheme,
|
||||
std::string_view scheme,
|
||||
bool is_embedded_origin_secure);
|
||||
|
||||
// Gets a user friendly display name for a given |site_url| to be used in the
|
||||
@ -2164,7 +2164,7 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
// ThreadPoolInstance was created.
|
||||
// Note: the embedder should *not* start the ThreadPoolInstance for
|
||||
// BrowserMainLoop, BrowserMainLoop itself is responsible for that.
|
||||
virtual bool CreateThreadPool(base::StringPiece name);
|
||||
virtual bool CreateThreadPool(std::string_view name);
|
||||
|
||||
// Returns true if the tab security level is acceptable to allow WebAuthn
|
||||
// requests, false otherwise. This is not attached to
|
||||
|
@ -6,12 +6,12 @@
|
||||
#define CONTENT_PUBLIC_BROWSER_DOCUMENT_SERVICE_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/threading/thread_checker.h"
|
||||
#include "content/public/browser/document_service_internal.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
@ -128,7 +128,7 @@ class DocumentService : public Interface, public internal::DocumentServiceBase {
|
||||
//
|
||||
// Prefer over `mojo::ReportBadMessage()`, since using this method avoids the
|
||||
// need to run any pending reply callbacks with placeholder arguments.
|
||||
NOT_TAIL_CALLED void ReportBadMessageAndDeleteThis(base::StringPiece error) {
|
||||
NOT_TAIL_CALLED void ReportBadMessageAndDeleteThis(std::string_view error) {
|
||||
receiver_.ReportBadMessage(error);
|
||||
delete this;
|
||||
}
|
||||
@ -136,7 +136,7 @@ class DocumentService : public Interface, public internal::DocumentServiceBase {
|
||||
// Resets the `mojo::Receiver` with a `reason` and `description` and deletes
|
||||
// `this`.
|
||||
void ResetWithReasonAndDeleteThis(uint32_t reason,
|
||||
base::StringPiece description) {
|
||||
std::string_view description) {
|
||||
receiver_.ResetWithReason(reason, description);
|
||||
delete this;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "content/public/browser/gpu_utils.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/functional/bind.h"
|
||||
@ -42,7 +43,7 @@ void KillGpuProcessImpl(content::GpuProcessHost* host) {
|
||||
}
|
||||
|
||||
bool GetUintFromSwitch(const base::CommandLine* command_line,
|
||||
const base::StringPiece& switch_string,
|
||||
const std::string_view& switch_string,
|
||||
uint32_t* value) {
|
||||
std::string switch_value(command_line->GetSwitchValueASCII(switch_string));
|
||||
return base::StringToUint(switch_value, value);
|
||||
|
@ -5,8 +5,9 @@
|
||||
#ifndef CONTENT_PUBLIC_BROWSER_MOJO_BINDER_POLICY_MAP_H_
|
||||
#define CONTENT_PUBLIC_BROWSER_MOJO_BINDER_POLICY_MAP_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/check_op.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "content/common/content_export.h"
|
||||
|
||||
namespace content {
|
||||
@ -67,10 +68,10 @@ class CONTENT_EXPORT MojoBinderPolicyMap {
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void SetPolicyByName(const base::StringPiece& name,
|
||||
virtual void SetPolicyByName(const std::string_view& name,
|
||||
MojoBinderAssociatedPolicy policy) = 0;
|
||||
|
||||
virtual void SetPolicyByName(const base::StringPiece& name,
|
||||
virtual void SetPolicyByName(const std::string_view& name,
|
||||
MojoBinderNonAssociatedPolicy policy) = 0;
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/observer_list_types.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/time/time.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "third_party/blink/public/mojom/origin_trial_feature/origin_trial_feature.mojom-shared.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/observer_list_types.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "content/public/browser/service_process_info.h"
|
||||
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include "content/public/browser/web_contents_media_capture_id.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
|
||||
namespace {
|
||||
@ -29,12 +29,12 @@ bool ExtractTabCaptureTarget(const std::string& device_id_param,
|
||||
if (sep_pos == std::string::npos)
|
||||
return false;
|
||||
|
||||
const base::StringPiece component1(device_id.data(), sep_pos);
|
||||
const std::string_view component1(device_id.data(), sep_pos);
|
||||
size_t end_pos = device_id.find('?');
|
||||
if (end_pos == std::string::npos)
|
||||
end_pos = device_id.length();
|
||||
const base::StringPiece component2(device_id.data() + sep_pos + 1,
|
||||
end_pos - sep_pos - 1);
|
||||
const std::string_view component2(device_id.data() + sep_pos + 1,
|
||||
end_pos - sep_pos - 1);
|
||||
|
||||
return (base::StringToInt(component1, render_process_id) &&
|
||||
base::StringToInt(component2, main_render_frame_id));
|
||||
@ -57,8 +57,8 @@ bool ExtractOptions(const std::string& device_id,
|
||||
option_pos_end = device_id.find(kOptionSeparator, option_pos + 1);
|
||||
if (option_pos_end == std::string::npos)
|
||||
option_pos_end = device_id.length();
|
||||
const base::StringPiece component(device_id.data() + option_pos + 1,
|
||||
option_pos_end - option_pos - 1);
|
||||
const std::string_view component(device_id.data() + option_pos + 1,
|
||||
option_pos_end - option_pos - 1);
|
||||
|
||||
if (component.compare(kDisableLocalEchoFlag) == 0)
|
||||
*disable_local_echo = true;
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "ui/base/page_transition_types.h"
|
||||
@ -41,9 +41,9 @@ class CONTENT_EXPORT WebUI {
|
||||
// Returns JavaScript code that, when executed, calls the function specified
|
||||
// by |function_name| with the arguments specified in |arg_list|.
|
||||
static std::u16string GetJavascriptCall(
|
||||
base::StringPiece function_name,
|
||||
std::string_view function_name,
|
||||
base::span<const base::ValueView> arg_list);
|
||||
static std::u16string GetJavascriptCall(base::StringPiece function_name,
|
||||
static std::u16string GetJavascriptCall(std::string_view function_name,
|
||||
const base::Value::List& arg_list);
|
||||
|
||||
virtual ~WebUI() {}
|
||||
@ -88,12 +88,12 @@ class CONTENT_EXPORT WebUI {
|
||||
// the call has no effect.
|
||||
using MessageCallback =
|
||||
base::RepeatingCallback<void(const base::Value::List&)>;
|
||||
virtual void RegisterMessageCallback(base::StringPiece message,
|
||||
virtual void RegisterMessageCallback(std::string_view message,
|
||||
MessageCallback callback) = 0;
|
||||
|
||||
template <typename... Args>
|
||||
void RegisterHandlerCallback(
|
||||
base::StringPiece message,
|
||||
std::string_view message,
|
||||
base::RepeatingCallback<void(Args...)> callback) {
|
||||
RegisterMessageCallback(
|
||||
message, base::BindRepeating(
|
||||
@ -121,15 +121,14 @@ class CONTENT_EXPORT WebUI {
|
||||
//
|
||||
// All function names in WebUI must consist of only ASCII characters.
|
||||
// There are variants for calls with more arguments.
|
||||
virtual void CallJavascriptFunctionUnsafe(
|
||||
base::StringPiece function_name) = 0;
|
||||
virtual void CallJavascriptFunctionUnsafe(std::string_view function_name) = 0;
|
||||
|
||||
virtual void CallJavascriptFunctionUnsafe(
|
||||
base::StringPiece function_name,
|
||||
std::string_view function_name,
|
||||
base::span<const base::ValueView> args) = 0;
|
||||
|
||||
template <typename... Args>
|
||||
void CallJavascriptFunctionUnsafe(base::StringPiece function_name,
|
||||
void CallJavascriptFunctionUnsafe(std::string_view function_name,
|
||||
const base::ValueView arg1,
|
||||
const Args&... arg) {
|
||||
base::ValueView args[] = {arg1, arg...};
|
||||
@ -155,7 +154,7 @@ class CONTENT_EXPORT WebUI {
|
||||
template <size_t... Is, typename... Args>
|
||||
struct Call<std::index_sequence<Is...>, Args...> {
|
||||
static void Impl(base::RepeatingCallback<void(Args...)> callback,
|
||||
base::StringPiece message,
|
||||
std::string_view message,
|
||||
const base::Value::List& list) {
|
||||
CHECK_EQ(list.size(), sizeof...(Args)) << message;
|
||||
callback.Run(GetValue<Args>(list[Is])...);
|
||||
|
@ -9,11 +9,11 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/span.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "services/network/public/mojom/content_security_policy.mojom-forward.h"
|
||||
@ -49,15 +49,15 @@ class WebUIDataSource {
|
||||
const base::Value::Dict& update);
|
||||
|
||||
// Adds a string keyed to its name to our dictionary.
|
||||
virtual void AddString(base::StringPiece name,
|
||||
virtual void AddString(std::string_view name,
|
||||
const std::u16string& value) = 0;
|
||||
|
||||
// Adds a string keyed to its name to our dictionary.
|
||||
virtual void AddString(base::StringPiece name, const std::string& value) = 0;
|
||||
virtual void AddString(std::string_view name, const std::string& value) = 0;
|
||||
|
||||
// Adds a localized string with resource |ids| keyed to its name to our
|
||||
// dictionary.
|
||||
virtual void AddLocalizedString(base::StringPiece name, int ids) = 0;
|
||||
virtual void AddLocalizedString(std::string_view name, int ids) = 0;
|
||||
|
||||
// Calls AddLocalizedString() in a for-loop for |strings|. Reduces code size
|
||||
// vs. reimplementing the same for-loop.
|
||||
@ -69,22 +69,22 @@ class WebUIDataSource {
|
||||
const base::Value::Dict& localized_strings) = 0;
|
||||
|
||||
// Adds a boolean keyed to its name to our dictionary.
|
||||
virtual void AddBoolean(base::StringPiece name, bool value) = 0;
|
||||
virtual void AddBoolean(std::string_view name, bool value) = 0;
|
||||
|
||||
// Adds a signed 32-bit integer keyed to its name to our dictionary. Larger
|
||||
// integers may not be exactly representable in JavaScript. See
|
||||
// MAX_SAFE_INTEGER in /v8/src/globals.h.
|
||||
virtual void AddInteger(base::StringPiece name, int32_t value) = 0;
|
||||
virtual void AddInteger(std::string_view name, int32_t value) = 0;
|
||||
|
||||
// Adds a double keyed to its name to our dictionary.
|
||||
virtual void AddDouble(base::StringPiece name, double value) = 0;
|
||||
virtual void AddDouble(std::string_view name, double value) = 0;
|
||||
|
||||
// Call this to enable a virtual "strings.js" (or "strings.m.js" for modules)
|
||||
// URL that provides translations and dynamic data when requested.
|
||||
virtual void UseStringsJs() = 0;
|
||||
|
||||
// Adds a mapping between a path name and a resource to return.
|
||||
virtual void AddResourcePath(base::StringPiece path, int resource_id) = 0;
|
||||
virtual void AddResourcePath(std::string_view path, int resource_id) = 0;
|
||||
|
||||
// Calls AddResourcePath() in a for-loop for |paths|. Reduces code size vs.
|
||||
// reimplementing the same for-loop.
|
||||
@ -148,7 +148,7 @@ class WebUIDataSource {
|
||||
virtual std::string GetSource() = 0;
|
||||
|
||||
// Set supported scheme if not one of the default supported schemes.
|
||||
virtual void SetSupportedScheme(base::StringPiece scheme) = 0;
|
||||
virtual void SetSupportedScheme(std::string_view scheme) = 0;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define CONTENT_PUBLIC_BROWSER_WEB_UI_MESSAGE_HANDLER_H_
|
||||
|
||||
#include <ostream>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/gtest_prod_util.h"
|
||||
@ -88,8 +89,7 @@ class CONTENT_EXPORT WebUIMessageHandler {
|
||||
// Helper method for notifying Javascript listeners added with
|
||||
// cr.addWebUIListener() (defined in cr.js).
|
||||
template <typename... Values>
|
||||
void FireWebUIListener(base::StringPiece event_name,
|
||||
const Values&... values) {
|
||||
void FireWebUIListener(std::string_view event_name, const Values&... values) {
|
||||
// cr.webUIListenerCallback is a global JS function exposed from cr.js.
|
||||
CallJavascriptFunction("cr.webUIListenerCallback", base::Value(event_name),
|
||||
values...);
|
||||
@ -102,7 +102,7 @@ class CONTENT_EXPORT WebUIMessageHandler {
|
||||
// All function names in WebUI must consist of only ASCII characters.
|
||||
// These functions will crash if JavaScript is not currently allowed.
|
||||
template <typename... Values>
|
||||
void CallJavascriptFunction(base::StringPiece function_name,
|
||||
void CallJavascriptFunction(std::string_view function_name,
|
||||
const Values&... values) {
|
||||
CHECK(IsJavascriptAllowed()) << "Cannot CallJavascriptFunction before "
|
||||
"explicitly allowing JavaScript.";
|
||||
|
@ -4,9 +4,11 @@
|
||||
|
||||
#include "content/public/browser/webui_config.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace content {
|
||||
|
||||
WebUIConfig::WebUIConfig(base::StringPiece scheme, base::StringPiece host)
|
||||
WebUIConfig::WebUIConfig(std::string_view scheme, std::string_view host)
|
||||
: scheme_(scheme), host_(host) {}
|
||||
|
||||
WebUIConfig::~WebUIConfig() = default;
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
@ -31,7 +31,7 @@ class WebUI;
|
||||
// all existing WebUI pages use this.
|
||||
class CONTENT_EXPORT WebUIConfig {
|
||||
public:
|
||||
explicit WebUIConfig(base::StringPiece scheme, base::StringPiece host);
|
||||
explicit WebUIConfig(std::string_view scheme, std::string_view host);
|
||||
virtual ~WebUIConfig();
|
||||
WebUIConfig(const WebUIConfig&) = delete;
|
||||
WebUIConfig& operator=(const WebUIConfig&) = delete;
|
||||
@ -76,7 +76,7 @@ class CONTENT_EXPORT WebUIConfig {
|
||||
template <typename T>
|
||||
class CONTENT_EXPORT DefaultWebUIConfig : public WebUIConfig {
|
||||
public:
|
||||
explicit DefaultWebUIConfig(base::StringPiece scheme, base::StringPiece host)
|
||||
explicit DefaultWebUIConfig(std::string_view scheme, std::string_view host)
|
||||
: WebUIConfig(scheme, host) {}
|
||||
~DefaultWebUIConfig() override = default;
|
||||
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
#include "content/public/common/content_client.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/values.h"
|
||||
@ -108,10 +109,10 @@ std::u16string ContentClient::GetLocalizedString(
|
||||
return std::u16string();
|
||||
}
|
||||
|
||||
base::StringPiece ContentClient::GetDataResource(
|
||||
std::string_view ContentClient::GetDataResource(
|
||||
int resource_id,
|
||||
ui::ResourceScaleFactor scale_factor) {
|
||||
return base::StringPiece();
|
||||
return std::string_view();
|
||||
}
|
||||
|
||||
base::RefCountedMemory* ContentClient::GetDataResourceBytes(int resource_id) {
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "mojo/public/cpp/system/message_pipe.h"
|
||||
@ -167,7 +167,7 @@ class CONTENT_EXPORT ContentClient {
|
||||
const std::u16string& replacement);
|
||||
|
||||
// Return the contents of a resource in a StringPiece given the resource id.
|
||||
virtual base::StringPiece GetDataResource(
|
||||
virtual std::string_view GetDataResource(
|
||||
int resource_id,
|
||||
ui::ResourceScaleFactor scale_factor);
|
||||
|
||||
|
@ -6,20 +6,21 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/hash/sha1.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "content/common/pseudonymization_salt.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
// static
|
||||
uint32_t PseudonymizationUtil::PseudonymizeStringForTesting(
|
||||
base::StringPiece string) {
|
||||
std::string_view string) {
|
||||
return PseudonymizeString(string);
|
||||
}
|
||||
|
||||
// static
|
||||
uint32_t PseudonymizationUtil::PseudonymizeString(base::StringPiece string) {
|
||||
uint32_t PseudonymizationUtil::PseudonymizeString(std::string_view string) {
|
||||
// Include `string` in the SHA1 hash.
|
||||
base::SHA1Context sha1_context;
|
||||
base::SHA1Init(sha1_context);
|
||||
@ -32,7 +33,7 @@ uint32_t PseudonymizationUtil::PseudonymizeString(base::StringPiece string) {
|
||||
// retained or sent anywhere).
|
||||
uint32_t salt = GetPseudonymizationSalt();
|
||||
base::SHA1Update(
|
||||
base::StringPiece(reinterpret_cast<const char*>(&salt), sizeof(salt)),
|
||||
std::string_view(reinterpret_cast<const char*>(&salt), sizeof(salt)),
|
||||
sha1_context);
|
||||
|
||||
// Compute the SHA1 hash.
|
||||
|
@ -5,10 +5,10 @@
|
||||
#ifndef CONTENT_PUBLIC_COMMON_PSEUDONYMIZATION_UTIL_H_
|
||||
#define CONTENT_PUBLIC_COMMON_PSEUDONYMIZATION_UTIL_H_
|
||||
|
||||
#include "stdint.h"
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "stdint.h"
|
||||
|
||||
// Forward-declarations of classes approved for using the PseudonymizationUtil.
|
||||
//
|
||||
@ -31,7 +31,7 @@ class CONTENT_EXPORT PseudonymizationUtil {
|
||||
public:
|
||||
// This is a test only interface that is identical to the public interface,
|
||||
// but does not require friending.
|
||||
static uint32_t PseudonymizeStringForTesting(base::StringPiece string);
|
||||
static uint32_t PseudonymizeStringForTesting(std::string_view string);
|
||||
|
||||
private:
|
||||
// Pseudonymizes the input `string` by passing it through a one-way hash
|
||||
@ -46,7 +46,7 @@ class CONTENT_EXPORT PseudonymizationUtil {
|
||||
// and Renderer processes).
|
||||
//
|
||||
// This method is thread-safe - it can be called on any thread.
|
||||
static uint32_t PseudonymizeString(base::StringPiece string);
|
||||
static uint32_t PseudonymizeString(std::string_view string);
|
||||
|
||||
// NOTE: All usages of the PseudonymizationUtil class should be reviewed by
|
||||
// chrome-privacy-core@google.com (and when approved added to the friend list
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/common/content_export.h"
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <memory>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "content/public/browser/back_forward_cache.h"
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
@ -27,7 +28,6 @@
|
||||
#include "base/strings/pattern.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
@ -351,7 +351,7 @@ CrossSiteRedirectResponseHandler(const net::EmbeddedTestServer* test_server,
|
||||
|
||||
// Replace the host of the URL with the one passed in the URL.
|
||||
GURL::Replacements replace_host;
|
||||
replace_host.SetHostStr(base::StringPiece(params).substr(0, slash));
|
||||
replace_host.SetHostStr(std::string_view(params).substr(0, slash));
|
||||
GURL redirect_server =
|
||||
test_server->base_url().ReplaceComponents(replace_host);
|
||||
|
||||
@ -653,7 +653,7 @@ bool BeginNavigateToURLFromRenderer(const ToRenderFrameHost& adapter,
|
||||
}
|
||||
|
||||
bool NavigateIframeToURL(WebContents* web_contents,
|
||||
base::StringPiece iframe_id,
|
||||
std::string_view iframe_id,
|
||||
const GURL& url) {
|
||||
TestNavigationObserver load_observer(web_contents);
|
||||
bool result = BeginNavigateIframeToURL(web_contents, iframe_id, url);
|
||||
@ -662,7 +662,7 @@ bool NavigateIframeToURL(WebContents* web_contents,
|
||||
}
|
||||
|
||||
bool BeginNavigateIframeToURL(WebContents* web_contents,
|
||||
base::StringPiece iframe_id,
|
||||
std::string_view iframe_id,
|
||||
const GURL& url) {
|
||||
std::string script =
|
||||
base::StrCat({"setTimeout(\"var iframes = document.getElementById('",
|
||||
@ -707,7 +707,7 @@ void NavigateToURLBlockUntilNavigationsComplete(
|
||||
}
|
||||
|
||||
GURL GetFileUrlWithQuery(const base::FilePath& path,
|
||||
base::StringPiece query_string) {
|
||||
std::string_view query_string) {
|
||||
GURL url = net::FilePathToFileURL(path);
|
||||
if (!query_string.empty()) {
|
||||
GURL::Replacements replacements;
|
||||
@ -970,7 +970,7 @@ void SimulateMouseClickAt(WebContents* web_contents,
|
||||
|
||||
gfx::PointF GetCenterCoordinatesOfElementWithId(
|
||||
const ToRenderFrameHost& adapter,
|
||||
base::StringPiece id) {
|
||||
std::string_view id) {
|
||||
float x =
|
||||
EvalJs(adapter, JsReplace("const bounds = "
|
||||
"document.getElementById($1)."
|
||||
@ -989,7 +989,7 @@ gfx::PointF GetCenterCoordinatesOfElementWithId(
|
||||
}
|
||||
|
||||
void SimulateMouseClickOrTapElementWithId(content::WebContents* web_contents,
|
||||
base::StringPiece id) {
|
||||
std::string_view id) {
|
||||
gfx::Point point = gfx::ToFlooredPoint(
|
||||
GetCenterCoordinatesOfElementWithId(web_contents, id));
|
||||
|
||||
@ -1427,7 +1427,7 @@ RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_frame_host) {
|
||||
}
|
||||
|
||||
void ExecuteScriptAsync(const ToRenderFrameHost& adapter,
|
||||
base::StringPiece script) {
|
||||
std::string_view script) {
|
||||
// Prerendering pages will never have user gesture.
|
||||
if (adapter.render_frame_host()->GetLifecycleState() ==
|
||||
RenderFrameHost::LifecycleState::kPrerendering) {
|
||||
@ -1439,13 +1439,13 @@ void ExecuteScriptAsync(const ToRenderFrameHost& adapter,
|
||||
}
|
||||
|
||||
void ExecuteScriptAsyncWithoutUserGesture(const ToRenderFrameHost& adapter,
|
||||
base::StringPiece script) {
|
||||
std::string_view script) {
|
||||
adapter.render_frame_host()->ExecuteJavaScriptForTests(
|
||||
base::UTF8ToUTF16(script), base::NullCallback());
|
||||
}
|
||||
|
||||
// EvalJsResult methods.
|
||||
EvalJsResult::EvalJsResult(base::Value value, base::StringPiece error)
|
||||
EvalJsResult::EvalJsResult(base::Value value, std::string_view error)
|
||||
: value(error.empty() ? std::move(value) : base::Value()), error(error) {}
|
||||
|
||||
EvalJsResult::EvalJsResult(const EvalJsResult& other)
|
||||
@ -1519,9 +1519,9 @@ namespace {
|
||||
//
|
||||
// TODO(nick): Elide snippets to 80 chars, since it is common for sources to not
|
||||
// include newlines.
|
||||
std::string AnnotateAndAdjustJsStackTraces(base::StringPiece js_error,
|
||||
std::string AnnotateAndAdjustJsStackTraces(std::string_view js_error,
|
||||
std::string source_name,
|
||||
base::StringPiece source,
|
||||
std::string_view source,
|
||||
int column_adjustment_for_line_one) {
|
||||
// Escape wildcards in |source_name| for use in MatchPattern.
|
||||
base::ReplaceChars(source_name, "\\", "\\\\", &source_name);
|
||||
@ -1529,7 +1529,7 @@ std::string AnnotateAndAdjustJsStackTraces(base::StringPiece js_error,
|
||||
base::ReplaceChars(source_name, "?", "\\?", &source_name);
|
||||
|
||||
// This vector maps line numbers to the corresponding text in |source|.
|
||||
const std::vector<base::StringPiece> source_lines = base::SplitStringPiece(
|
||||
const std::vector<std::string_view> source_lines = base::SplitStringPiece(
|
||||
source, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
|
||||
// |source_frame_pattern| should match any line that looks like a stack frame
|
||||
@ -1540,19 +1540,19 @@ std::string AnnotateAndAdjustJsStackTraces(base::StringPiece js_error,
|
||||
// This is the amount of indentation that is applied to the lines of inserted
|
||||
// annotations.
|
||||
const std::string indent(8, ' ');
|
||||
const base::StringPiece elision_mark = "";
|
||||
const std::string_view elision_mark = "";
|
||||
|
||||
// Loop over each line of |js_error|, and append each to |annotated_error| --
|
||||
// possibly rewriting to include extra context.
|
||||
std::ostringstream annotated_error;
|
||||
for (const base::StringPiece& error_line : base::SplitStringPiece(
|
||||
for (const std::string_view& error_line : base::SplitStringPiece(
|
||||
js_error, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL)) {
|
||||
// Does this look like a stack frame whose URL source matches |source_name|?
|
||||
if (base::MatchPattern(error_line, source_frame_pattern)) {
|
||||
// When a match occurs, annotate the stack trace with the corresponding
|
||||
// line from |source|, along with a ^^^ underneath, indicating the column
|
||||
// position.
|
||||
std::vector<base::StringPiece> error_line_parts = base::SplitStringPiece(
|
||||
std::vector<std::string_view> error_line_parts = base::SplitStringPiece(
|
||||
error_line, ":", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
CHECK_GE(error_line_parts.size(), 2u);
|
||||
|
||||
@ -1680,8 +1680,8 @@ class ExecuteJavaScriptForTestsWaiter : public WebContentsObserver {
|
||||
|
||||
EvalJsResult EvalJsRunner(
|
||||
const ToRenderFrameHost& execution_target,
|
||||
base::StringPiece script,
|
||||
base::StringPiece source_url,
|
||||
std::string_view script,
|
||||
std::string_view source_url,
|
||||
int options,
|
||||
int32_t world_id,
|
||||
base::OnceClosure after_script_invoke = base::DoNothing()) {
|
||||
@ -1732,7 +1732,7 @@ EvalJsResult EvalJsRunner(
|
||||
} // namespace
|
||||
|
||||
::testing::AssertionResult ExecJs(const ToRenderFrameHost& execution_target,
|
||||
base::StringPiece script,
|
||||
std::string_view script,
|
||||
int options,
|
||||
int32_t world_id) {
|
||||
// TODO(nick): Do we care enough about folks shooting themselves in the foot
|
||||
@ -1748,7 +1748,7 @@ EvalJsResult EvalJsRunner(
|
||||
}
|
||||
|
||||
EvalJsResult EvalJs(const ToRenderFrameHost& execution_target,
|
||||
base::StringPiece script,
|
||||
std::string_view script,
|
||||
int options,
|
||||
int32_t world_id,
|
||||
base::OnceClosure after_script_invoke) {
|
||||
@ -1771,8 +1771,8 @@ EvalJsResult EvalJs(const ToRenderFrameHost& execution_target,
|
||||
|
||||
EvalJsResult EvalJsAfterLifecycleUpdate(
|
||||
const ToRenderFrameHost& execution_target,
|
||||
base::StringPiece raf_script,
|
||||
base::StringPiece script,
|
||||
std::string_view raf_script,
|
||||
std::string_view script,
|
||||
int options,
|
||||
int32_t world_id) {
|
||||
TRACE_EVENT2("test", "EvalJsAfterLifecycleUpdate", "raf_script", raf_script,
|
||||
@ -1840,7 +1840,7 @@ RenderFrameHost* FrameMatchingPredicate(
|
||||
return rfh;
|
||||
}
|
||||
|
||||
bool FrameMatchesName(base::StringPiece name, RenderFrameHost* frame) {
|
||||
bool FrameMatchesName(std::string_view name, RenderFrameHost* frame) {
|
||||
return frame->GetFrameName() == name;
|
||||
}
|
||||
|
||||
@ -2102,7 +2102,7 @@ ui::AXNodeData GetFocusedAccessibilityNodeInfo(WebContents* web_contents) {
|
||||
}
|
||||
|
||||
bool AccessibilityTreeContainsNodeWithName(BrowserAccessibility* node,
|
||||
base::StringPiece name) {
|
||||
std::string_view name) {
|
||||
// If an image annotation is set, it plays the same role as a name, so it
|
||||
// makes sense to check both in the same test helper.
|
||||
if (node->GetStringAttribute(ax::mojom::StringAttribute::kName) == name ||
|
||||
@ -2123,7 +2123,7 @@ void WaitForAccessibilityTreeToChange(WebContents* web_contents) {
|
||||
}
|
||||
|
||||
void WaitForAccessibilityTreeToContainNodeWithName(WebContents* web_contents,
|
||||
base::StringPiece name) {
|
||||
std::string_view name) {
|
||||
WebContentsImpl* web_contents_impl =
|
||||
static_cast<WebContentsImpl*>(web_contents);
|
||||
RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>(
|
||||
@ -2424,7 +2424,7 @@ void RenderProcessHostWatcher::RenderProcessHostDestroyed(
|
||||
|
||||
RenderProcessHostKillWaiter::RenderProcessHostKillWaiter(
|
||||
RenderProcessHost* render_process_host,
|
||||
base::StringPiece uma_name)
|
||||
std::string_view uma_name)
|
||||
: exit_watcher_(render_process_host,
|
||||
RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT),
|
||||
uma_name_(uma_name) {}
|
||||
@ -3567,7 +3567,7 @@ DevToolsInspectorLogWatcher::~DevToolsInspectorLogWatcher() {
|
||||
void DevToolsInspectorLogWatcher::DispatchProtocolMessage(
|
||||
DevToolsAgentHost* host,
|
||||
base::span<const uint8_t> message) {
|
||||
base::StringPiece message_str(reinterpret_cast<const char*>(message.data()),
|
||||
std::string_view message_str(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
auto parsed_message =
|
||||
std::move(base::JSONReader::Read(message_str)->GetDict());
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -23,7 +24,6 @@
|
||||
#include "base/process/process.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/template_util.h"
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
#include "base/types/strong_alias.h"
|
||||
@ -256,18 +256,18 @@ void NavigateToURLBlockUntilNavigationsComplete(
|
||||
// necessary, a user activation can be triggered right before calling this
|
||||
// method, e.g. by calling |ExecJs(frame_tree_node, "")|.
|
||||
bool NavigateIframeToURL(WebContents* web_contents,
|
||||
base::StringPiece iframe_id,
|
||||
std::string_view iframe_id,
|
||||
const GURL& url);
|
||||
|
||||
// Similar to |NavigateIframeToURL()| but returns as soon as the navigation is
|
||||
// initiated.
|
||||
bool BeginNavigateIframeToURL(WebContents* web_contents,
|
||||
base::StringPiece iframe_id,
|
||||
std::string_view iframe_id,
|
||||
const GURL& url);
|
||||
|
||||
// Generate a URL for a file path including a query string.
|
||||
GURL GetFileUrlWithQuery(const base::FilePath& path,
|
||||
base::StringPiece query_string);
|
||||
std::string_view query_string);
|
||||
|
||||
// Checks whether the page type of the last committed navigation entry matches
|
||||
// |page_type|.
|
||||
@ -359,12 +359,12 @@ void SimulateMouseClickAt(WebContents* web_contents,
|
||||
// friendly by taking zooming into account.
|
||||
gfx::PointF GetCenterCoordinatesOfElementWithId(
|
||||
const ToRenderFrameHost& adapter,
|
||||
base::StringPiece id);
|
||||
std::string_view id);
|
||||
|
||||
// Retrieves the center coordinates of the element with id |id| and simulates a
|
||||
// mouse click there using SimulateMouseClickAt().
|
||||
void SimulateMouseClickOrTapElementWithId(content::WebContents* web_contents,
|
||||
base::StringPiece id);
|
||||
std::string_view id);
|
||||
|
||||
// Simulates asynchronously a mouse enter/move/leave event. The mouse event is
|
||||
// routed through RenderWidgetHostInputEventRouter and thus can target OOPIFs.
|
||||
@ -622,12 +622,12 @@ RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents);
|
||||
// - EvalJs (if you want to retrieve a value)
|
||||
// - DOMMessageQueue (to manually wait for domAutomationController.send(...))
|
||||
void ExecuteScriptAsync(const ToRenderFrameHost& adapter,
|
||||
base::StringPiece script);
|
||||
std::string_view script);
|
||||
|
||||
// Same as `content::ExecuteScriptAsync()`, but doesn't send a user gesture to
|
||||
// the renderer.
|
||||
void ExecuteScriptAsyncWithoutUserGesture(const ToRenderFrameHost& adapter,
|
||||
base::StringPiece script);
|
||||
std::string_view script);
|
||||
|
||||
// JsLiteralHelper is a helper class that determines what types are legal to
|
||||
// pass to StringifyJsLiteral. Legal types include int, string, StringPiece,
|
||||
@ -705,7 +705,7 @@ base::Value ListValueOf(Args&&... args) {
|
||||
// This becomes "window.location.reload(true);" -- because bool values are
|
||||
// supported by base::Value. Numbers, lists, and dicts also work.
|
||||
template <typename... Args>
|
||||
std::string JsReplace(base::StringPiece script_template, Args&&... args) {
|
||||
std::string JsReplace(std::string_view script_template, Args&&... args) {
|
||||
base::Value::List values =
|
||||
ListValueOf(std::forward<Args>(args)...).TakeList();
|
||||
std::vector<std::string> replacements(values.size());
|
||||
@ -744,7 +744,7 @@ struct EvalJsResult {
|
||||
|
||||
// Creates an EvalJs result. If |error| is non-empty, |value| will be
|
||||
// ignored.
|
||||
EvalJsResult(base::Value value, base::StringPiece error);
|
||||
EvalJsResult(base::Value value, std::string_view error);
|
||||
|
||||
// Copy ctor.
|
||||
EvalJsResult(const EvalJsResult& value);
|
||||
@ -906,7 +906,7 @@ enum EvalJsOptions {
|
||||
// It is guaranteed that EvalJs works even when the target frame is frozen.
|
||||
[[nodiscard]] EvalJsResult EvalJs(
|
||||
const ToRenderFrameHost& execution_target,
|
||||
base::StringPiece script,
|
||||
std::string_view script,
|
||||
int options = EXECUTE_SCRIPT_DEFAULT_OPTIONS,
|
||||
int32_t world_id = ISOLATED_WORLD_ID_GLOBAL,
|
||||
base::OnceClosure after_script_invoke = base::DoNothing());
|
||||
@ -918,8 +918,8 @@ enum EvalJsOptions {
|
||||
// processed by the browser.
|
||||
[[nodiscard]] EvalJsResult EvalJsAfterLifecycleUpdate(
|
||||
const ToRenderFrameHost& execution_target,
|
||||
base::StringPiece raf_script,
|
||||
base::StringPiece script,
|
||||
std::string_view raf_script,
|
||||
std::string_view script,
|
||||
int options = EXECUTE_SCRIPT_DEFAULT_OPTIONS,
|
||||
int32_t world_id = ISOLATED_WORLD_ID_GLOBAL);
|
||||
|
||||
@ -933,7 +933,7 @@ enum EvalJsOptions {
|
||||
// until it resolves (by default).
|
||||
[[nodiscard]] ::testing::AssertionResult ExecJs(
|
||||
const ToRenderFrameHost& execution_target,
|
||||
base::StringPiece script,
|
||||
std::string_view script,
|
||||
int options = EXECUTE_SCRIPT_DEFAULT_OPTIONS,
|
||||
int32_t world_id = ISOLATED_WORLD_ID_GLOBAL);
|
||||
|
||||
@ -952,7 +952,7 @@ RenderFrameHost* FrameMatchingPredicate(
|
||||
base::RepeatingCallback<bool(RenderFrameHost*)> predicate);
|
||||
|
||||
// Predicates for use with FrameMatchingPredicate[OrNullPtr]().
|
||||
bool FrameMatchesName(base::StringPiece name, RenderFrameHost* frame);
|
||||
bool FrameMatchesName(std::string_view name, RenderFrameHost* frame);
|
||||
bool FrameIsChildOfMainFrame(RenderFrameHost* frame);
|
||||
bool FrameHasSourceUrl(const GURL& url, RenderFrameHost* frame);
|
||||
|
||||
@ -1077,7 +1077,7 @@ void WaitForAccessibilityTreeToChange(WebContents* web_contents);
|
||||
// WaitForAccessibilityTreeToChange, above, and then checks again.
|
||||
// Keeps looping until the text is found (or the test times out).
|
||||
void WaitForAccessibilityTreeToContainNodeWithName(WebContents* web_contents,
|
||||
base::StringPiece name);
|
||||
std::string_view name);
|
||||
|
||||
// Get a snapshot of a web page's accessibility tree.
|
||||
ui::AXTreeUpdate GetAccessibilityTreeSnapshot(WebContents* web_contents);
|
||||
@ -1249,7 +1249,7 @@ class RenderProcessHostKillWaiter {
|
||||
// |uma_name| is the name of the histogram from which the |bad_message_reason|
|
||||
// can be extracted.
|
||||
RenderProcessHostKillWaiter(RenderProcessHost* render_process_host,
|
||||
base::StringPiece uma_name);
|
||||
std::string_view uma_name);
|
||||
|
||||
RenderProcessHostKillWaiter(const RenderProcessHostKillWaiter&) = delete;
|
||||
RenderProcessHostKillWaiter& operator=(const RenderProcessHostKillWaiter&) =
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "content/public/test/content_browser_test_content_browser_client.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/test/task_environment.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
|
||||
@ -32,7 +34,7 @@ ContentBrowserTestContentBrowserClient::
|
||||
}
|
||||
|
||||
bool ContentBrowserTestContentBrowserClient::CreateThreadPool(
|
||||
base::StringPiece name) {
|
||||
std::string_view name) {
|
||||
// Injects a test TaskTracker to watch for long-running tasks and produce a
|
||||
// useful timeout message in order to find the cause of flaky timeout tests.
|
||||
base::test::TaskEnvironment::CreateThreadPool();
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_CONTENT_BROWSER_CLIENT_H_
|
||||
#define CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_CONTENT_BROWSER_CLIENT_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "content/shell/browser/shell_content_browser_client.h"
|
||||
|
||||
namespace content {
|
||||
@ -19,7 +21,7 @@ class ContentBrowserTestContentBrowserClient
|
||||
ContentBrowserTestContentBrowserClient();
|
||||
~ContentBrowserTestContentBrowserClient() override;
|
||||
|
||||
bool CreateThreadPool(base::StringPiece name) override;
|
||||
bool CreateThreadPool(std::string_view name) override;
|
||||
void OnNetworkServiceCreated(
|
||||
network::mojom::NetworkService* network_service) override;
|
||||
};
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/test/test_suite.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/browser/gpu/gpu_main_thread_factory.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/span.h"
|
||||
#include "base/functional/callback.h"
|
||||
@ -33,8 +34,8 @@ ScopedPageFocusOverride::~ScopedPageFocusOverride() {
|
||||
void ScopedPageFocusOverride::DispatchProtocolMessage(
|
||||
DevToolsAgentHost* agent_host,
|
||||
base::span<const uint8_t> message) {
|
||||
base::StringPiece message_str(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
std::string_view message_str(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
std::optional<base::Value> parsed_message =
|
||||
base::JSONReader::Read(message_str);
|
||||
ASSERT_TRUE(parsed_message.has_value());
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "content/public/test/test_devtools_protocol_client.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/auto_reset.h"
|
||||
#include "base/json/json_reader.h"
|
||||
@ -152,8 +153,8 @@ void TestDevToolsProtocolClient::RunLoopUpdatingQuitClosure() {
|
||||
void TestDevToolsProtocolClient::DispatchProtocolMessage(
|
||||
DevToolsAgentHost* agent_host,
|
||||
base::span<const uint8_t> message) {
|
||||
base::StringPiece message_str(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
std::string_view message_str(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
base::Value parsed = *base::JSONReader::Read(message_str);
|
||||
if (std::optional<int> id = parsed.GetDict().FindInt("id")) {
|
||||
received_responses_count_++;
|
||||
|
@ -4,13 +4,13 @@
|
||||
|
||||
#include "content/public/test/test_web_ui.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "content/public/browser/web_ui_controller.h"
|
||||
#include "content/public/browser/web_ui_message_handler.h"
|
||||
|
||||
@ -90,7 +90,7 @@ void TestWebUI::AddMessageHandler(
|
||||
handlers_.push_back(std::move(handler));
|
||||
}
|
||||
|
||||
void TestWebUI::RegisterMessageCallback(base::StringPiece message,
|
||||
void TestWebUI::RegisterMessageCallback(std::string_view message,
|
||||
MessageCallback callback) {
|
||||
message_callbacks_[static_cast<std::string>(message)].push_back(
|
||||
std::move(callback));
|
||||
@ -113,13 +113,13 @@ bool TestWebUI::CanCallJavascript() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TestWebUI::CallJavascriptFunctionUnsafe(base::StringPiece function_name) {
|
||||
void TestWebUI::CallJavascriptFunctionUnsafe(std::string_view function_name) {
|
||||
call_data_.push_back(base::WrapUnique(new CallData(function_name)));
|
||||
OnJavascriptCall(*call_data_.back());
|
||||
}
|
||||
|
||||
void TestWebUI::CallJavascriptFunctionUnsafe(
|
||||
base::StringPiece function_name,
|
||||
std::string_view function_name,
|
||||
base::span<const base::ValueView> args) {
|
||||
call_data_.push_back(base::WrapUnique(new CallData(function_name)));
|
||||
for (const auto& arg : args) {
|
||||
@ -138,7 +138,7 @@ TestWebUI::GetHandlersForTesting() {
|
||||
return &handlers_;
|
||||
}
|
||||
|
||||
TestWebUI::CallData::CallData(base::StringPiece function_name)
|
||||
TestWebUI::CallData::CallData(std::string_view function_name)
|
||||
: function_name_(function_name.data(), function_name.size()) {}
|
||||
|
||||
TestWebUI::CallData::~CallData() {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/flat_map.h"
|
||||
@ -53,22 +54,22 @@ class TestWebUI : public WebUI {
|
||||
const std::vector<std::string>& GetRequestableSchemes() override;
|
||||
void AddRequestableScheme(const char* scheme) override;
|
||||
void AddMessageHandler(std::unique_ptr<WebUIMessageHandler> handler) override;
|
||||
void RegisterMessageCallback(base::StringPiece message,
|
||||
void RegisterMessageCallback(std::string_view message,
|
||||
MessageCallback callback) override;
|
||||
void ProcessWebUIMessage(const GURL& source_url,
|
||||
const std::string& message,
|
||||
base::Value::List args) override;
|
||||
bool CanCallJavascript() override;
|
||||
void CallJavascriptFunctionUnsafe(base::StringPiece function_name) override;
|
||||
void CallJavascriptFunctionUnsafe(std::string_view function_name) override;
|
||||
void CallJavascriptFunctionUnsafe(
|
||||
base::StringPiece function_name,
|
||||
std::string_view function_name,
|
||||
base::span<const base::ValueView> args) override;
|
||||
std::vector<std::unique_ptr<WebUIMessageHandler>>* GetHandlersForTesting()
|
||||
override;
|
||||
|
||||
class CallData {
|
||||
public:
|
||||
explicit CallData(base::StringPiece function_name);
|
||||
explicit CallData(std::string_view function_name);
|
||||
~CallData();
|
||||
|
||||
void AppendArgument(base::Value arg);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "content/public/test/url_loader_interceptor.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/containers/unique_ptr_adapters.h"
|
||||
@ -467,8 +468,8 @@ URLLoaderInterceptor::ServeFilesFromDirectoryAtOrigin(
|
||||
}
|
||||
|
||||
void URLLoaderInterceptor::WriteResponse(
|
||||
base::StringPiece headers,
|
||||
base::StringPiece body,
|
||||
std::string_view headers,
|
||||
std::string_view body,
|
||||
network::mojom::URLLoaderClient* client,
|
||||
std::optional<net::SSLInfo> ssl_info,
|
||||
std::optional<GURL> url) {
|
||||
|
@ -9,11 +9,11 @@
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
@ -120,8 +120,8 @@ class URLLoaderInterceptor {
|
||||
// Helper methods for use when intercepting.
|
||||
// Writes the given response body, header, and SSL Info to `client`.
|
||||
// If `url` is present, also computes the ParsedHeaders for the response.
|
||||
static void WriteResponse(base::StringPiece headers,
|
||||
base::StringPiece body,
|
||||
static void WriteResponse(std::string_view headers,
|
||||
std::string_view body,
|
||||
network::mojom::URLLoaderClient* client,
|
||||
std::optional<net::SSLInfo> ssl_info = std::nullopt,
|
||||
std::optional<GURL> url = std::nullopt);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
@ -233,7 +234,7 @@ GURL GetChromeUntrustedUIURL(const std::string& host_and_path) {
|
||||
url::kStandardSchemeSeparator + host_and_path);
|
||||
}
|
||||
|
||||
TestWebUIConfig::TestWebUIConfig(base::StringPiece host)
|
||||
TestWebUIConfig::TestWebUIConfig(std::string_view host)
|
||||
: WebUIConfig(content::kChromeUIScheme, host) {}
|
||||
|
||||
std::unique_ptr<WebUIController> TestWebUIConfig::CreateWebUIController(
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "content/public/browser/web_ui_controller.h"
|
||||
@ -46,7 +47,7 @@ GURL GetChromeUntrustedUIURL(const std::string& host_and_path);
|
||||
|
||||
class TestWebUIConfig : public content::WebUIConfig {
|
||||
public:
|
||||
explicit TestWebUIConfig(base::StringPiece host);
|
||||
explicit TestWebUIConfig(std::string_view host);
|
||||
|
||||
~TestWebUIConfig() override = default;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "content/renderer/accessibility/annotations/ax_image_annotator.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -58,7 +59,7 @@ namespace {
|
||||
|
||||
int GetMessageIdForIconEnum(const std::string& icon_type) {
|
||||
static constexpr auto kIconTypeToMessageIdMap =
|
||||
base::MakeFixedFlatMap<base::StringPiece, int>({
|
||||
base::MakeFixedFlatMap<std::string_view, int>({
|
||||
{"ICON_PLUS", IDS_AX_IMAGE_ANNOTATION_ICON_PLUS},
|
||||
{"ICON_ARROW_BACKWARD", IDS_AX_IMAGE_ANNOTATION_ICON_ARROW_BACKWARD},
|
||||
{"ICON_ARROW_FORWARD", IDS_AX_IMAGE_ANNOTATION_ICON_ARROW_FORWARD},
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "content/renderer/accessibility/annotations/ax_image_stopwords.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
@ -12,7 +13,6 @@
|
||||
#include "base/i18n/case_conversion.h"
|
||||
#include "base/i18n/char_iterator.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "third_party/icu/source/common/unicode/uchar.h"
|
||||
@ -507,7 +507,7 @@ AXImageStopwords::AXImageStopwords() {
|
||||
// because it avoids ever needing to copy any of the strings; each StringPiece
|
||||
// is just a pointer into kImageStopwordsUtf8 and flat_set acts like a set but
|
||||
// basically just does a binary search.
|
||||
std::vector<base::StringPiece> stopwords =
|
||||
std::vector<std::string_view> stopwords =
|
||||
base::SplitStringPiece(kImageStopwordsUtf8, "\n", base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
|
||||
|
@ -5,9 +5,10 @@
|
||||
#ifndef CONTENT_RENDERER_ACCESSIBILITY_ANNOTATIONS_AX_IMAGE_STOPWORDS_H_
|
||||
#define CONTENT_RENDERER_ACCESSIBILITY_ANNOTATIONS_AX_IMAGE_STOPWORDS_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "content/common/content_export.h"
|
||||
|
||||
namespace content {
|
||||
@ -62,7 +63,7 @@ class CONTENT_EXPORT AXImageStopwords {
|
||||
AXImageStopwords();
|
||||
~AXImageStopwords();
|
||||
|
||||
base::flat_set<base::StringPiece> stopword_set_;
|
||||
base::flat_set<std::string_view> stopword_set_;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@ -351,7 +352,7 @@ std::optional<gfx::Vector2dF> ToVector(const std::string& direction,
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
int ToKeyModifiers(const base::StringPiece& key) {
|
||||
int ToKeyModifiers(const std::string_view& key) {
|
||||
if (key == "Alt")
|
||||
return blink::WebInputEvent::kAltKey;
|
||||
if (key == "Control")
|
||||
@ -370,7 +371,7 @@ int ToKeyModifiers(const base::StringPiece& key) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ToButtonModifiers(const base::StringPiece& button) {
|
||||
int ToButtonModifiers(const std::string_view& button) {
|
||||
if (button == "Left")
|
||||
return blink::WebMouseEvent::kLeftButtonDown;
|
||||
if (button == "Middle")
|
||||
@ -850,9 +851,9 @@ bool GpuBenchmarking::SmoothScrollBy(gin::Arguments* args) {
|
||||
return false;
|
||||
gfx::Vector2dF fling_velocity(0, 0);
|
||||
int modifiers = 0;
|
||||
std::vector<base::StringPiece> key_list = base::SplitStringPiece(
|
||||
std::vector<std::string_view> key_list = base::SplitStringPiece(
|
||||
keys_value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
for (const base::StringPiece& key : key_list) {
|
||||
for (const std::string_view& key : key_list) {
|
||||
int key_modifier = ToKeyModifiers(key);
|
||||
if (key_modifier == 0) {
|
||||
return false;
|
||||
@ -938,9 +939,9 @@ bool GpuBenchmarking::SmoothScrollByXY(gin::Arguments* args) {
|
||||
gfx::Vector2dF distances(pixels_to_scroll_x, pixels_to_scroll_y);
|
||||
gfx::Vector2dF fling_velocity(0, 0);
|
||||
int modifiers = 0;
|
||||
std::vector<base::StringPiece> key_list = base::SplitStringPiece(
|
||||
std::vector<std::string_view> key_list = base::SplitStringPiece(
|
||||
keys_value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
for (const base::StringPiece& key : key_list) {
|
||||
for (const std::string_view& key : key_list) {
|
||||
int key_modifier = ToKeyModifiers(key);
|
||||
if (key_modifier == 0) {
|
||||
return false;
|
||||
@ -948,9 +949,9 @@ bool GpuBenchmarking::SmoothScrollByXY(gin::Arguments* args) {
|
||||
modifiers |= key_modifier;
|
||||
}
|
||||
|
||||
std::vector<base::StringPiece> button_list = base::SplitStringPiece(
|
||||
std::vector<std::string_view> button_list = base::SplitStringPiece(
|
||||
buttons_value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
for (const base::StringPiece& button : button_list) {
|
||||
for (const std::string_view& button : button_list) {
|
||||
int button_modifier = ToButtonModifiers(button);
|
||||
if (button_modifier == 0) {
|
||||
return false;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/check_op.h"
|
||||
#include "base/feature_list.h"
|
||||
@ -192,7 +193,7 @@ void AppendCharEvent(const WebInputEvent& event,
|
||||
|
||||
// Make a separate InputEventData for each Unicode character in the input.
|
||||
for (base::i18n::UTF16CharIterator iter(
|
||||
base::StringPiece16(key_event.text, utf16_char_count));
|
||||
std::u16string_view(key_event.text, utf16_char_count));
|
||||
!iter.end(); iter.Advance()) {
|
||||
InputEventData result = GetEventWithCommonFieldsAndType(event);
|
||||
result.event_modifiers = ConvertEventModifiers(key_event.GetModifiers());
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@ -1448,7 +1447,7 @@ bool RenderFrameImpl::UniqueNameFrameAdapter::IsMainFrame() const {
|
||||
}
|
||||
|
||||
bool RenderFrameImpl::UniqueNameFrameAdapter::IsCandidateUnique(
|
||||
base::StringPiece name) const {
|
||||
std::string_view name) const {
|
||||
// This method is currently O(N), where N = number of frames in the tree.
|
||||
DCHECK(!name.empty());
|
||||
|
||||
@ -1484,7 +1483,7 @@ int RenderFrameImpl::UniqueNameFrameAdapter::GetChildCount() const {
|
||||
std::vector<std::string>
|
||||
RenderFrameImpl::UniqueNameFrameAdapter::CollectAncestorNames(
|
||||
BeginPoint begin_point,
|
||||
bool (*should_stop)(base::StringPiece)) const {
|
||||
bool (*should_stop)(std::string_view)) const {
|
||||
std::vector<std::string> result;
|
||||
for (blink::WebFrame* frame = begin_point == BeginPoint::kParentFrame
|
||||
? GetWebFrame()->Parent()
|
||||
|
@ -1234,12 +1234,12 @@ class CONTENT_EXPORT RenderFrameImpl
|
||||
|
||||
// FrameAdapter overrides:
|
||||
bool IsMainFrame() const override;
|
||||
bool IsCandidateUnique(base::StringPiece name) const override;
|
||||
bool IsCandidateUnique(std::string_view name) const override;
|
||||
int GetSiblingCount() const override;
|
||||
int GetChildCount() const override;
|
||||
std::vector<std::string> CollectAncestorNames(
|
||||
BeginPoint begin_point,
|
||||
bool (*should_stop)(base::StringPiece)) const override;
|
||||
bool (*should_stop)(std::string_view)) const override;
|
||||
std::vector<int> GetFramePosition(BeginPoint begin_point) const override;
|
||||
|
||||
private:
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -411,7 +412,7 @@ bool RenderThreadImpl::HistogramCustomizer::IsAlexaTop10NonGoogleSite(
|
||||
return true;
|
||||
|
||||
if (!sanitized_host.empty()) {
|
||||
std::vector<base::StringPiece> host_tokens = base::SplitStringPiece(
|
||||
std::vector<std::string_view> host_tokens = base::SplitStringPiece(
|
||||
sanitized_host, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
|
||||
if (host_tokens.size() >= 2) {
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/apple/bundle_locations.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
@ -114,8 +116,8 @@ MULTIPROCESS_TEST_MAIN(SandboxProfileProcess) {
|
||||
CHECK(result) << error;
|
||||
|
||||
// Test the properties of the sandbox profile.
|
||||
constexpr base::StringPiece log_msg = "logged";
|
||||
CHECK(base::WriteFile(log_file, base::StringPiece(log_msg)));
|
||||
constexpr std::string_view log_msg = "logged";
|
||||
CHECK(base::WriteFile(log_file, std::string_view(log_msg)));
|
||||
// Log file is write only.
|
||||
char read_buf[log_msg.size()];
|
||||
CHECK_EQ(-1, base::ReadFile(log_file, read_buf, sizeof(read_buf)));
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -261,7 +262,7 @@ v8::Local<v8::Value> V8ValueConverterImpl::ToV8ValueImpl(
|
||||
return v8::Number::New(isolate, value);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> operator()(base::StringPiece value) {
|
||||
v8::Local<v8::Value> operator()(std::string_view value) {
|
||||
return v8::String::NewFromUtf8(isolate, value.data(),
|
||||
v8::NewStringType::kNormal, value.length())
|
||||
.ToLocalChecked();
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/check.h"
|
||||
@ -401,7 +402,7 @@ v8::Local<v8::String> AuctionV8Helper::CreateStringFromLiteral(
|
||||
}
|
||||
|
||||
v8::MaybeLocal<v8::String> AuctionV8Helper::CreateUtf8String(
|
||||
base::StringPiece utf8_string) {
|
||||
std::string_view utf8_string) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
if (!base::IsStringUTF8(utf8_string))
|
||||
return v8::MaybeLocal<v8::String>();
|
||||
@ -412,7 +413,7 @@ v8::MaybeLocal<v8::String> AuctionV8Helper::CreateUtf8String(
|
||||
|
||||
v8::MaybeLocal<v8::Value> AuctionV8Helper::CreateValueFromJson(
|
||||
v8::Local<v8::Context> context,
|
||||
base::StringPiece utf8_json) {
|
||||
std::string_view utf8_json) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
v8::Local<v8::String> v8_string;
|
||||
if (!CreateUtf8String(utf8_json).ToLocal(&v8_string))
|
||||
@ -420,7 +421,7 @@ v8::MaybeLocal<v8::Value> AuctionV8Helper::CreateValueFromJson(
|
||||
return v8::JSON::Parse(context, v8_string);
|
||||
}
|
||||
|
||||
bool AuctionV8Helper::AppendUtf8StringValue(base::StringPiece utf8_string,
|
||||
bool AuctionV8Helper::AppendUtf8StringValue(std::string_view utf8_string,
|
||||
v8::LocalVector<v8::Value>* args) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
v8::Local<v8::String> value;
|
||||
@ -431,7 +432,7 @@ bool AuctionV8Helper::AppendUtf8StringValue(base::StringPiece utf8_string,
|
||||
}
|
||||
|
||||
bool AuctionV8Helper::AppendJsonValue(v8::Local<v8::Context> context,
|
||||
base::StringPiece utf8_json,
|
||||
std::string_view utf8_json,
|
||||
v8::LocalVector<v8::Value>* args) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
v8::Local<v8::Value> value;
|
||||
@ -441,7 +442,7 @@ bool AuctionV8Helper::AppendJsonValue(v8::Local<v8::Context> context,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AuctionV8Helper::InsertValue(base::StringPiece key,
|
||||
bool AuctionV8Helper::InsertValue(std::string_view key,
|
||||
v8::Local<v8::Value> value,
|
||||
v8::Local<v8::Object> object) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
@ -454,8 +455,8 @@ bool AuctionV8Helper::InsertValue(base::StringPiece key,
|
||||
}
|
||||
|
||||
bool AuctionV8Helper::InsertJsonValue(v8::Local<v8::Context> context,
|
||||
base::StringPiece key,
|
||||
base::StringPiece utf8_json,
|
||||
std::string_view key,
|
||||
std::string_view utf8_json,
|
||||
v8::Local<v8::Object> object) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
v8::Local<v8::Value> v8_value;
|
||||
@ -653,7 +654,7 @@ v8::MaybeLocal<v8::Value> AuctionV8Helper::CallFunction(
|
||||
v8::Local<v8::Context> context,
|
||||
const DebugId* debug_id,
|
||||
const std::string& script_name,
|
||||
base::StringPiece function_name,
|
||||
std::string_view function_name,
|
||||
base::span<v8::Local<v8::Value>> args,
|
||||
TimeLimit* script_timeout,
|
||||
std::vector<std::string>& error_out) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/span.h"
|
||||
@ -18,7 +19,6 @@
|
||||
#include "base/memory/ref_counted_delete_on_sequence.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
@ -227,32 +227,32 @@ class CONTENT_EXPORT AuctionV8Helper
|
||||
|
||||
// Attempts to create a v8::String from a UTF-8 string. Returns empty string
|
||||
// if input is not UTF-8.
|
||||
v8::MaybeLocal<v8::String> CreateUtf8String(base::StringPiece utf8_string);
|
||||
v8::MaybeLocal<v8::String> CreateUtf8String(std::string_view utf8_string);
|
||||
|
||||
// The passed in JSON must be a valid UTF-8 JSON string.
|
||||
v8::MaybeLocal<v8::Value> CreateValueFromJson(v8::Local<v8::Context> context,
|
||||
base::StringPiece utf8_json);
|
||||
std::string_view utf8_json);
|
||||
|
||||
// Convenience wrappers around the above Create* methods. Attempt to create
|
||||
// the corresponding value type and append it to the passed in argument
|
||||
// vector. Useful for assembling arguments to a Javascript function. Return
|
||||
// false on failure.
|
||||
[[nodiscard]] bool AppendUtf8StringValue(base::StringPiece utf8_string,
|
||||
[[nodiscard]] bool AppendUtf8StringValue(std::string_view utf8_string,
|
||||
v8::LocalVector<v8::Value>* args);
|
||||
[[nodiscard]] bool AppendJsonValue(v8::Local<v8::Context> context,
|
||||
base::StringPiece utf8_json,
|
||||
std::string_view utf8_json,
|
||||
v8::LocalVector<v8::Value>* args);
|
||||
|
||||
// Convenience wrapper that adds the specified value into the provided Object.
|
||||
[[nodiscard]] bool InsertValue(base::StringPiece key,
|
||||
[[nodiscard]] bool InsertValue(std::string_view key,
|
||||
v8::Local<v8::Value> value,
|
||||
v8::Local<v8::Object> object);
|
||||
|
||||
// Convenience wrapper that creates an Object by parsing `utf8_json` as JSON
|
||||
// and then inserts it into the provided Object.
|
||||
[[nodiscard]] bool InsertJsonValue(v8::Local<v8::Context> context,
|
||||
base::StringPiece key,
|
||||
base::StringPiece utf8_json,
|
||||
std::string_view key,
|
||||
std::string_view utf8_json,
|
||||
v8::Local<v8::Object> object);
|
||||
|
||||
enum class ExtractJsonResult { kSuccess, kFailure, kTimeout };
|
||||
@ -361,7 +361,7 @@ class CONTENT_EXPORT AuctionV8Helper
|
||||
v8::MaybeLocal<v8::Value> CallFunction(v8::Local<v8::Context> context,
|
||||
const DebugId* debug_id,
|
||||
const std::string& script_name,
|
||||
base::StringPiece function_name,
|
||||
std::string_view function_name,
|
||||
base::span<v8::Local<v8::Value>> args,
|
||||
TimeLimit* script_timeout,
|
||||
std::vector<std::string>& error_out);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@ -17,7 +18,7 @@ std::vector<uint8_t> GetStringBytes(const v8_inspector::StringView& s) {
|
||||
if (s.is8Bit()) {
|
||||
return std::vector<uint8_t>(s.characters8(), s.characters8() + s.length());
|
||||
} else {
|
||||
std::string converted = base::UTF16ToUTF8(base::StringPiece16(
|
||||
std::string converted = base::UTF16ToUTF8(std::u16string_view(
|
||||
reinterpret_cast<const char16_t*>(s.characters16()), s.length()));
|
||||
const uint8_t* data = reinterpret_cast<const uint8_t*>(converted.data());
|
||||
return std::vector<uint8_t>(data, data + converted.size());
|
||||
|
@ -28,7 +28,7 @@ void LazyFiller::SetResult(const v8::PropertyCallbackInfo<v8::Value>& info,
|
||||
}
|
||||
|
||||
bool LazyFiller::DefineLazyAttribute(v8::Local<v8::Object> object,
|
||||
base::StringPiece name,
|
||||
std::string_view name,
|
||||
v8::AccessorNameGetterCallback getter) {
|
||||
v8::Isolate* isolate = v8_helper_->isolate();
|
||||
|
||||
@ -44,7 +44,7 @@ bool LazyFiller::DefineLazyAttribute(v8::Local<v8::Object> object,
|
||||
bool LazyFiller::DefineLazyAttributeWithMetadata(
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::Value> metadata,
|
||||
base::StringPiece name,
|
||||
std::string_view name,
|
||||
v8::AccessorNameGetterCallback getter,
|
||||
v8::Local<v8::ObjectTemplate>& lazy_filler_template) {
|
||||
v8::Isolate* isolate = v8_helper_->isolate();
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <string_view>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "v8/include/v8-external.h"
|
||||
#include "v8/include/v8-forward.h"
|
||||
#include "v8/include/v8-function-callback.h"
|
||||
@ -68,7 +67,7 @@ class LazyFiller {
|
||||
v8::Local<v8::Value> result);
|
||||
|
||||
bool DefineLazyAttribute(v8::Local<v8::Object> object,
|
||||
base::StringPiece name,
|
||||
std::string_view name,
|
||||
v8::AccessorNameGetterCallback getter);
|
||||
|
||||
// `lazy_filler_template` is used to construct an internal v8 object with a
|
||||
@ -78,7 +77,7 @@ class LazyFiller {
|
||||
bool DefineLazyAttributeWithMetadata(
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::Value> metadata,
|
||||
base::StringPiece name,
|
||||
std::string_view name,
|
||||
v8::AccessorNameGetterCallback getter,
|
||||
v8::Local<v8::ObjectTemplate>& lazy_filler_template);
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
@ -68,14 +69,14 @@ const char kWebAssemblyMime[] = "application/wasm";
|
||||
// Returns the MIME type string to send for the Accept header for `mime_type`.
|
||||
// These are the official IANA MIME type strings, though other MIME type strings
|
||||
// are allows in the response.
|
||||
base::StringPiece MimeTypeToString(AuctionDownloader::MimeType mime_type) {
|
||||
std::string_view MimeTypeToString(AuctionDownloader::MimeType mime_type) {
|
||||
switch (mime_type) {
|
||||
case AuctionDownloader::MimeType::kJavascript:
|
||||
return base::StringPiece("application/javascript");
|
||||
return std::string_view("application/javascript");
|
||||
case AuctionDownloader::MimeType::kJson:
|
||||
return base::StringPiece("application/json");
|
||||
return std::string_view("application/json");
|
||||
case AuctionDownloader::MimeType::kWebAssembly:
|
||||
return base::StringPiece(kWebAssemblyMime);
|
||||
return std::string_view(kWebAssemblyMime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +108,7 @@ bool MimeTypeIsConsistent(
|
||||
|
||||
// Checks if `charset` is a valid charset, in lowercase ASCII. Takes `body` as
|
||||
// well, to ensure it uses the specified charset.
|
||||
bool IsAllowedCharset(base::StringPiece charset, const std::string& body) {
|
||||
bool IsAllowedCharset(std::string_view charset, const std::string& body) {
|
||||
if (charset == "utf-8" || charset.empty()) {
|
||||
return base::IsStringUTF8(body);
|
||||
} else if (charset == "us-ascii") {
|
||||
|
@ -110,7 +110,7 @@ bool CreatePerBuyerCurrenciesObject(
|
||||
|
||||
bool InsertPrioritySignals(
|
||||
AuctionV8Helper* v8_helper,
|
||||
base::StringPiece key,
|
||||
std::string_view key,
|
||||
const base::flat_map<std::string, double>& priority_signals,
|
||||
v8::Local<v8::Object> object) {
|
||||
v8::Isolate* isolate = v8_helper->isolate();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -310,7 +311,7 @@ bool VerifySellerCurrency(
|
||||
std::optional<blink::AdCurrency> expected_seller_currency,
|
||||
std::optional<blink::AdCurrency> component_expect_bid_currency,
|
||||
const GURL& script_url,
|
||||
base::StringPiece bid_label,
|
||||
std::string_view bid_label,
|
||||
std::vector<std::string>& errors_out) {
|
||||
if (!blink::VerifyAdCurrencyCode(expected_seller_currency,
|
||||
provided_currency)) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <cmath>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/strings/strcat.h"
|
||||
@ -100,7 +101,7 @@ class WebIDLCompatTest : public testing::Test {
|
||||
}
|
||||
|
||||
bool GetSequence(DictConverter* converter,
|
||||
base::StringPiece field,
|
||||
std::string_view field,
|
||||
v8::LocalVector<v8::Value>& out) {
|
||||
out.clear(); // For tests that re-use `out`.
|
||||
bool got_it = false;
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/location.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "ui/platform_window/fuchsia/initialize_presenter_api_view.h"
|
||||
|
||||
namespace content {
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/browser/session_storage_namespace.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -23,7 +24,6 @@
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/sequence_local_storage_slot.h"
|
||||
@ -239,11 +239,11 @@ base::flat_set<url::Origin> GetIsolatedContextOriginSetFromFlag() {
|
||||
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
||||
switches::kIsolatedContextOrigins));
|
||||
|
||||
std::vector<base::StringPiece> origin_strings = base::SplitStringPiece(
|
||||
std::vector<std::string_view> origin_strings = base::SplitStringPiece(
|
||||
cmdline_origins, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
|
||||
base::flat_set<url::Origin> origin_set;
|
||||
for (const base::StringPiece& origin_string : origin_strings) {
|
||||
for (const std::string_view& origin_string : origin_strings) {
|
||||
url::Origin allowed_origin = url::Origin::Create(GURL(origin_string));
|
||||
if (!allowed_origin.opaque()) {
|
||||
origin_set.insert(allowed_origin);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -20,7 +21,6 @@
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/uuid.h"
|
||||
@ -117,7 +117,7 @@ class ShellDevToolsBindings::NetworkResourceLoader
|
||||
response_headers_ = response_head.headers;
|
||||
}
|
||||
|
||||
void OnDataReceived(base::StringPiece chunk,
|
||||
void OnDataReceived(std::string_view chunk,
|
||||
base::OnceClosure resume) override {
|
||||
base::Value chunkValue;
|
||||
|
||||
@ -401,8 +401,8 @@ void ShellDevToolsBindings::HandleMessageFromDevToolsFrontend(
|
||||
void ShellDevToolsBindings::DispatchProtocolMessage(
|
||||
DevToolsAgentHost* agent_host,
|
||||
base::span<const uint8_t> message) {
|
||||
base::StringPiece str_message(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
std::string_view str_message(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
if (str_message.length() < kShellMaxMessageChunkSize) {
|
||||
CallClientFunction("DevToolsAPI", "dispatchMessage",
|
||||
base::Value(std::string(str_message)));
|
||||
@ -410,7 +410,7 @@ void ShellDevToolsBindings::DispatchProtocolMessage(
|
||||
size_t total_size = str_message.length();
|
||||
for (size_t pos = 0; pos < str_message.length();
|
||||
pos += kShellMaxMessageChunkSize) {
|
||||
base::StringPiece str_message_chunk =
|
||||
std::string_view str_message_chunk =
|
||||
str_message.substr(pos, kShellMaxMessageChunkSize);
|
||||
|
||||
CallClientFunction(
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
|
@ -4,8 +4,9 @@
|
||||
|
||||
#include "content/shell/common/shell_content_client.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "build/build_config.h"
|
||||
@ -44,7 +45,7 @@ std::u16string ShellContentClient::GetLocalizedString(int message_id) {
|
||||
return l10n_util::GetStringUTF16(message_id);
|
||||
}
|
||||
|
||||
base::StringPiece ShellContentClient::GetDataResource(
|
||||
std::string_view ShellContentClient::GetDataResource(
|
||||
int resource_id,
|
||||
ui::ResourceScaleFactor scale_factor) {
|
||||
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define CONTENT_SHELL_COMMON_SHELL_CONTENT_CLIENT_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "content/public/common/content_client.h"
|
||||
@ -19,7 +20,7 @@ class ShellContentClient : public ContentClient {
|
||||
~ShellContentClient() override;
|
||||
|
||||
std::u16string GetLocalizedString(int message_id) override;
|
||||
base::StringPiece GetDataResource(
|
||||
std::string_view GetDataResource(
|
||||
int resource_id,
|
||||
ui::ResourceScaleFactor scale_factor) override;
|
||||
base::RefCountedMemory* GetDataResourceBytes(int resource_id) override;
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "third_party/blink/public/common/origin_trials/origin_trial_policy.h"
|
||||
|
||||
namespace content {
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "content/test/mock_reduce_accept_language_controller_delegate.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/string_split.h"
|
||||
#include "content/public/common/origin_util.h"
|
||||
#include "net/http/http_util.h"
|
||||
@ -13,7 +15,7 @@ namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string GetFirstLanguage(base::StringPiece language_list) {
|
||||
std::string GetFirstLanguage(std::string_view language_list) {
|
||||
auto end = language_list.find(",");
|
||||
return std::string(language_list.substr(0, end));
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "content/test/test_content_client.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
|
||||
namespace content {
|
||||
@ -12,7 +14,7 @@ TestContentClient::TestContentClient() = default;
|
||||
|
||||
TestContentClient::~TestContentClient() = default;
|
||||
|
||||
base::StringPiece TestContentClient::GetDataResource(
|
||||
std::string_view TestContentClient::GetDataResource(
|
||||
int resource_id,
|
||||
ui::ResourceScaleFactor scale_factor) {
|
||||
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef CONTENT_TEST_TEST_CONTENT_CLIENT_H_
|
||||
#define CONTENT_TEST_TEST_CONTENT_CLIENT_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "content/public/common/content_client.h"
|
||||
|
||||
namespace content {
|
||||
@ -19,7 +21,7 @@ class TestContentClient : public ContentClient {
|
||||
~TestContentClient() override;
|
||||
|
||||
// ContentClient:
|
||||
base::StringPiece GetDataResource(
|
||||
std::string_view GetDataResource(
|
||||
int resource_id,
|
||||
ui::ResourceScaleFactor scale_factor) override;
|
||||
base::RefCountedMemory* GetDataResourceBytes(int resource_id) override;
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "content/web_test/browser/devtools_protocol_test_bindings.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback_helpers.h"
|
||||
@ -175,7 +177,7 @@ void DevToolsProtocolTestBindings::DispatchProtocolMessage(
|
||||
if (log_enabled_) {
|
||||
NOTREACHED_NORETURN() << "Unexpected messages dispatched by the browser";
|
||||
}
|
||||
base::StringPiece str_message(reinterpret_cast<const char*>(message.data()),
|
||||
std::string_view str_message(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
WebTestControlHost::Get()->PrintMessageToStderr(
|
||||
"Protocol message: " + std::string(str_message) + "\n");
|
||||
|
@ -34,7 +34,6 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using ::base::StringPiece;
|
||||
using ::base::test::RunOnceCallback;
|
||||
using ::device::BluetoothAdapter;
|
||||
using ::device::BluetoothDevice;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -448,7 +449,7 @@ void WebTestResultPrinter::PrintEncodedBinaryData(
|
||||
*output_ << "Content-Transfer-Encoding: base64\n";
|
||||
|
||||
std::string data_base64 = base::Base64Encode(
|
||||
base::StringPiece(reinterpret_cast<const char*>(&data[0]), data.size()));
|
||||
std::string_view(reinterpret_cast<const char*>(&data[0]), data.size()));
|
||||
|
||||
*output_ << "Content-Length: " << data_base64.length() << "\n";
|
||||
output_->write(data_base64.c_str(), data_base64.length());
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/heap_array.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/rand_util.h"
|
||||
@ -17,8 +19,8 @@ namespace web_test_string_util {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr base::StringPiece kWebTestsPattern = "/web_tests/";
|
||||
constexpr base::StringPiece kFileURLPattern = "file://";
|
||||
constexpr std::string_view kWebTestsPattern = "/web_tests/";
|
||||
constexpr std::string_view kFileURLPattern = "file://";
|
||||
const char* kFileTestPrefix = "(file test):";
|
||||
const char* kPolicyDownload = "download";
|
||||
const char* kPolicyCurrentTab = "current tab";
|
||||
@ -37,7 +39,7 @@ std::string NormalizeWebTestURLForTextOutput(const std::string& url) {
|
||||
if (base::StartsWith(url, kFileURLPattern)) {
|
||||
// Adjust the file URL by removing the part depending on the testing
|
||||
// environment.
|
||||
size_t pos = base::StringPiece(url).find(kWebTestsPattern);
|
||||
size_t pos = std::string_view(url).find(kWebTestsPattern);
|
||||
if (pos != std::string::npos)
|
||||
result.replace(0, pos + kWebTestsPattern.size(), kFileTestPrefix);
|
||||
}
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
#include "content/web_test/renderer/blink_test_helpers.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "build/build_config.h"
|
||||
@ -27,7 +28,7 @@ using blink::WebURL;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr base::StringPiece kFileScheme = "file:///";
|
||||
constexpr std::string_view kFileScheme = "file:///";
|
||||
|
||||
base::FilePath GetWebTestsFilePath() {
|
||||
static base::FilePath path;
|
||||
@ -63,7 +64,7 @@ base::FilePath GetExternalWPTFilePath() {
|
||||
// the WPT test directory.
|
||||
//
|
||||
// Note that this doesn't apply when the WPT tests are run by the python script.
|
||||
WebURL RewriteWPTAbsolutePath(base::StringPiece utf8_url) {
|
||||
WebURL RewriteWPTAbsolutePath(std::string_view utf8_url) {
|
||||
if (!base::StartsWith(utf8_url, kFileScheme, base::CompareCase::SENSITIVE) ||
|
||||
utf8_url.find("/web_tests/") != std::string::npos) {
|
||||
return WebURL(GURL(utf8_url));
|
||||
@ -74,9 +75,9 @@ WebURL RewriteWPTAbsolutePath(base::StringPiece utf8_url) {
|
||||
static constexpr size_t kFileSchemeAndDriveLen = kFileScheme.size() + 3;
|
||||
if (utf8_url.size() <= kFileSchemeAndDriveLen)
|
||||
return WebURL();
|
||||
base::StringPiece path = utf8_url.substr(kFileSchemeAndDriveLen);
|
||||
std::string_view path = utf8_url.substr(kFileSchemeAndDriveLen);
|
||||
#else
|
||||
base::StringPiece path = utf8_url.substr(kFileScheme.size());
|
||||
std::string_view path = utf8_url.substr(kFileScheme.size());
|
||||
#endif
|
||||
base::FilePath new_path = GetExternalWPTFilePath().AppendASCII(path);
|
||||
return WebURL(net::FilePathToFileURL(new_path));
|
||||
@ -126,11 +127,11 @@ static base::FilePath GetBuildDirectory() {
|
||||
return result;
|
||||
}
|
||||
|
||||
WebURL RewriteWebTestsURL(base::StringPiece utf8_url, bool is_wpt_mode) {
|
||||
WebURL RewriteWebTestsURL(std::string_view utf8_url, bool is_wpt_mode) {
|
||||
if (is_wpt_mode)
|
||||
return RewriteWPTAbsolutePath(utf8_url);
|
||||
|
||||
static constexpr base::StringPiece kGenPrefix = "file:///gen/";
|
||||
static constexpr std::string_view kGenPrefix = "file:///gen/";
|
||||
|
||||
// Map "file:///gen/" to "file://<build directory>/gen/".
|
||||
if (base::StartsWith(utf8_url, kGenPrefix, base::CompareCase::SENSITIVE)) {
|
||||
@ -142,7 +143,7 @@ WebURL RewriteWebTestsURL(base::StringPiece utf8_url, bool is_wpt_mode) {
|
||||
return WebURL(GURL(new_url));
|
||||
}
|
||||
|
||||
static constexpr base::StringPiece kPrefix = "file:///tmp/web_tests/";
|
||||
static constexpr std::string_view kPrefix = "file:///tmp/web_tests/";
|
||||
|
||||
if (!base::StartsWith(utf8_url, kPrefix, base::CompareCase::SENSITIVE))
|
||||
return WebURL(GURL(utf8_url));
|
||||
@ -153,11 +154,11 @@ WebURL RewriteWebTestsURL(base::StringPiece utf8_url, bool is_wpt_mode) {
|
||||
return WebURL(GURL(new_url));
|
||||
}
|
||||
|
||||
WebURL RewriteFileURLToLocalResource(base::StringPiece resource) {
|
||||
WebURL RewriteFileURLToLocalResource(std::string_view resource) {
|
||||
return RewriteWebTestsURL(resource, /*is_wpt_mode=*/false);
|
||||
}
|
||||
|
||||
bool IsWebPlatformTest(base::StringPiece test_url) {
|
||||
bool IsWebPlatformTest(std::string_view test_url) {
|
||||
// ://web-platform.test is a part of the http/https URL of a wpt test run by
|
||||
// the python script.
|
||||
return test_url.find("://web-platform.test") != std::string::npos ||
|
||||
|
@ -5,7 +5,8 @@
|
||||
#ifndef CONTENT_WEB_TEST_RENDERER_BLINK_TEST_HELPERS_H_
|
||||
#define CONTENT_WEB_TEST_RENDERER_BLINK_TEST_HELPERS_H_
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include <string_view>
|
||||
|
||||
#include "third_party/blink/public/platform/web_url.h"
|
||||
|
||||
namespace blink {
|
||||
@ -32,13 +33,13 @@ void ExportWebTestSpecificPreferences(const TestPreferences& from,
|
||||
// to a temporary file under the web_tests directory.
|
||||
// 3. If the URL starts with file:///gen/, then return a file URL to the file
|
||||
// under the gen/ directory of the build out.
|
||||
blink::WebURL RewriteWebTestsURL(base::StringPiece utf8_url, bool is_wpt_mode);
|
||||
blink::WebURL RewriteWebTestsURL(std::string_view utf8_url, bool is_wpt_mode);
|
||||
|
||||
// Applies the rewrite rules except 1 of RewriteWebTestsURL().
|
||||
blink::WebURL RewriteFileURLToLocalResource(base::StringPiece resource);
|
||||
blink::WebURL RewriteFileURLToLocalResource(std::string_view resource);
|
||||
|
||||
// Returns true if |test_url| points to a web platform test (WPT).
|
||||
bool IsWebPlatformTest(base::StringPiece test_url);
|
||||
bool IsWebPlatformTest(std::string_view test_url);
|
||||
|
||||
} // namespace content
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "content/web_test/renderer/fake_subresource_filter.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "third_party/blink/public/platform/web_url.h"
|
||||
@ -40,7 +42,7 @@ FakeSubresourceFilter::GetLoadPolicyForWebTransportConnect(
|
||||
blink::WebDocumentSubresourceFilter::LoadPolicy
|
||||
FakeSubresourceFilter::GetLoadPolicyImpl(const blink::WebURL& url) {
|
||||
GURL gurl(url);
|
||||
base::StringPiece path(gurl.path_piece());
|
||||
std::string_view path(gurl.path_piece());
|
||||
|
||||
// Allows things not listed in |disallowed_path_suffixes_|.
|
||||
if (base::ranges::none_of(
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <algorithm>
|
||||
#include <clocale>
|
||||
#include <limits>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -19,7 +20,6 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/test/bind.h"
|
||||
@ -2781,15 +2781,15 @@ static std::string GetPageRangesStringFromMetadata(
|
||||
printing::PageRanges TestRunner::GetPrintingPageRanges(
|
||||
blink::WebLocalFrame* frame) const {
|
||||
const std::string page_ranges_string = GetPageRangesStringFromMetadata(frame);
|
||||
const std::vector<base::StringPiece> range_strings =
|
||||
const std::vector<std::string_view> range_strings =
|
||||
base::SplitStringPiece(page_ranges_string, ",", base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
printing::PageRanges result;
|
||||
|
||||
for (const base::StringPiece& range_string : range_strings) {
|
||||
for (const std::string_view& range_string : range_strings) {
|
||||
// The format for each range is "<int> | <int>? - <int>?" where the page
|
||||
// numbers are 1-indexed.
|
||||
const std::vector<base::StringPiece> page_strings = base::SplitStringPiece(
|
||||
const std::vector<std::string_view> page_strings = base::SplitStringPiece(
|
||||
range_string, "-", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
bool invalid = false;
|
||||
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
#include "content/web_test/renderer/test_websocket_handshake_throttle_provider.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/timer/timer.h"
|
||||
@ -29,13 +30,13 @@ base::TimeDelta ExtractDelayFromUrl(const GURL& url) {
|
||||
url::Component query = url.parsed_for_possibly_invalid_spec().query;
|
||||
url::Component key;
|
||||
url::Component value;
|
||||
base::StringPiece spec = url.possibly_invalid_spec();
|
||||
std::string_view spec = url.possibly_invalid_spec();
|
||||
while (url::ExtractQueryKeyValue(spec, &query, &key, &value)) {
|
||||
base::StringPiece key_piece = spec.substr(key.begin, key.len);
|
||||
std::string_view key_piece = spec.substr(key.begin, key.len);
|
||||
if (key_piece != "content-shell-websocket-delay-ms")
|
||||
continue;
|
||||
|
||||
base::StringPiece value_piece = spec.substr(value.begin, value.len);
|
||||
std::string_view value_piece = spec.substr(value.begin, value.len);
|
||||
int value_int;
|
||||
if (!base::StringToInt(value_piece, &value_int) || value_int < 0)
|
||||
return base::TimeDelta();
|
||||
|
Reference in New Issue
Block a user