fix: modernize-avoid-c-arrays (#44834)
use string_view for constants used in methods that take string_view args Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
d8a7c57506
commit
5a0e1ccf73
11 changed files with 69 additions and 62 deletions
|
@ -79,7 +79,7 @@ namespace electron {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char kRelauncherProcess[] = "relauncher";
|
constexpr std::string_view kRelauncherProcess = "relauncher";
|
||||||
|
|
||||||
constexpr std::string_view kElectronDisableSandbox{"ELECTRON_DISABLE_SANDBOX"};
|
constexpr std::string_view kElectronDisableSandbox{"ELECTRON_DISABLE_SANDBOX"};
|
||||||
constexpr std::string_view kElectronEnableStackDumping{
|
constexpr std::string_view kElectronEnableStackDumping{
|
||||||
|
|
|
@ -49,10 +49,10 @@ namespace extensions {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr char kCouldNotLoadFileError[] = "Could not load file: '*'.";
|
constexpr std::string_view kCouldNotLoadFileError = "Could not load file: '*'.";
|
||||||
constexpr char kDuplicateFileSpecifiedError[] =
|
constexpr std::string_view kDuplicateFileSpecifiedError =
|
||||||
"Duplicate file specified: '*'.";
|
"Duplicate file specified: '*'.";
|
||||||
constexpr char kEmptyMatchesError[] =
|
constexpr std::string_view kEmptyMatchesError =
|
||||||
"Script with ID '*' must specify 'matches'.";
|
"Script with ID '*' must specify 'matches'.";
|
||||||
constexpr char kExactlyOneOfCssAndFilesError[] =
|
constexpr char kExactlyOneOfCssAndFilesError[] =
|
||||||
"Exactly one of 'css' and 'files' must be specified.";
|
"Exactly one of 'css' and 'files' must be specified.";
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ namespace extensions {
|
||||||
|
|
||||||
namespace tabs = api::tabs;
|
namespace tabs = api::tabs;
|
||||||
|
|
||||||
const char kFrameNotFoundError[] = "No frame with id * in tab *.";
|
constexpr std::string_view kFrameNotFoundError = "No frame with id * in tab *.";
|
||||||
const char kPerOriginOnlyInAutomaticError[] =
|
const char kPerOriginOnlyInAutomaticError[] =
|
||||||
"Can only set scope to "
|
"Can only set scope to "
|
||||||
"\"per-origin\" in \"automatic\" mode.";
|
"\"per-origin\" in \"automatic\" mode.";
|
||||||
|
|
|
@ -90,10 +90,10 @@ using blink::mojom::PermissionStatus;
|
||||||
// }
|
// }
|
||||||
const char kDefaultLastPickedDirectoryKey[] = "default-id";
|
const char kDefaultLastPickedDirectoryKey[] = "default-id";
|
||||||
const char kCustomLastPickedDirectoryKey[] = "custom-id";
|
const char kCustomLastPickedDirectoryKey[] = "custom-id";
|
||||||
const char kPathKey[] = "path";
|
constexpr std::string_view kPathKey = "path";
|
||||||
const char kPathTypeKey[] = "path-type";
|
constexpr std::string_view kPathTypeKey = "path-type";
|
||||||
const char kDisplayNameKey[] = "display-name";
|
constexpr std::string_view kDisplayNameKey = "display-name";
|
||||||
const char kTimestampKey[] = "timestamp";
|
constexpr std::string_view kTimestampKey = "timestamp";
|
||||||
|
|
||||||
constexpr base::TimeDelta kPermissionRevocationTimeout = base::Seconds(5);
|
constexpr base::TimeDelta kPermissionRevocationTimeout = base::Seconds(5);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/memory/ref_counted_memory.h"
|
#include "base/memory/ref_counted_memory.h"
|
||||||
|
@ -97,7 +98,7 @@ void ThemeDataSource::StartDataRequest(
|
||||||
|
|
||||||
// kColorsCssPath should stay consistent with COLORS_CSS_SELECTOR in
|
// kColorsCssPath should stay consistent with COLORS_CSS_SELECTOR in
|
||||||
// colors_css_updater.js.
|
// colors_css_updater.js.
|
||||||
constexpr char kColorsCssPath[] = "colors.css";
|
constexpr std::string_view kColorsCssPath = "colors.css";
|
||||||
if (parsed_path == kColorsCssPath) {
|
if (parsed_path == kColorsCssPath) {
|
||||||
SendColorsCss(url, wc_getter, std::move(callback));
|
SendColorsCss(url, wc_getter, std::move(callback));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -70,25 +70,26 @@ namespace electron {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char kChromeUIDevToolsURL[] =
|
constexpr std::string_view kChromeUIDevToolsURL =
|
||||||
"devtools://devtools/bundled/devtools_app.html?"
|
"devtools://devtools/bundled/devtools_app.html?"
|
||||||
"remoteBase=%s&"
|
"remoteBase=%s&"
|
||||||
"can_dock=%s&"
|
"can_dock=%s&"
|
||||||
"toolbarColor=rgba(223,223,223,1)&"
|
"toolbarColor=rgba(223,223,223,1)&"
|
||||||
"textColor=rgba(0,0,0,1)&"
|
"textColor=rgba(0,0,0,1)&"
|
||||||
"experiments=true";
|
"experiments=true";
|
||||||
const char kChromeUIDevToolsRemoteFrontendBase[] =
|
constexpr std::string_view kChromeUIDevToolsRemoteFrontendBase =
|
||||||
"https://chrome-devtools-frontend.appspot.com/";
|
"https://chrome-devtools-frontend.appspot.com/";
|
||||||
const char kChromeUIDevToolsRemoteFrontendPath[] = "serve_file";
|
constexpr std::string_view kChromeUIDevToolsRemoteFrontendPath = "serve_file";
|
||||||
|
|
||||||
const char kDevToolsBoundsPref[] = "electron.devtools.bounds";
|
constexpr std::string_view kDevToolsBoundsPref = "electron.devtools.bounds";
|
||||||
const char kDevToolsZoomPref[] = "electron.devtools.zoom";
|
constexpr std::string_view kDevToolsZoomPref = "electron.devtools.zoom";
|
||||||
const char kDevToolsPreferences[] = "electron.devtools.preferences";
|
constexpr std::string_view kDevToolsPreferences =
|
||||||
|
"electron.devtools.preferences";
|
||||||
|
|
||||||
const char kFrontendHostId[] = "id";
|
constexpr std::string_view kFrontendHostId = "id";
|
||||||
const char kFrontendHostMethod[] = "method";
|
constexpr std::string_view kFrontendHostMethod = "method";
|
||||||
const char kFrontendHostParams[] = "params";
|
constexpr std::string_view kFrontendHostParams = "params";
|
||||||
const char kTitleFormat[] = "Developer Tools - %s";
|
constexpr std::string_view kTitleFormat = "Developer Tools - %s";
|
||||||
|
|
||||||
const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
|
const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -50,49 +51,49 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static const char kTargetsDataFile[] = "targets-data.json";
|
constexpr std::string_view kTargetsDataFile = "targets-data.json";
|
||||||
|
|
||||||
static const char kAccessibilityModeField[] = "a11yMode";
|
constexpr std::string_view kAccessibilityModeField = "a11yMode";
|
||||||
static const char kBrowsersField[] = "browsers";
|
constexpr std::string_view kBrowsersField = "browsers";
|
||||||
static const char kErrorField[] = "error";
|
constexpr std::string_view kErrorField = "error";
|
||||||
static const char kFaviconUrlField[] = "faviconUrl";
|
constexpr std::string_view kFaviconUrlField = "faviconUrl";
|
||||||
static const char kNameField[] = "name";
|
constexpr std::string_view kNameField = "name";
|
||||||
static const char kPagesField[] = "pages";
|
constexpr std::string_view kPagesField = "pages";
|
||||||
static const char kPidField[] = "pid";
|
constexpr std::string_view kPidField = "pid";
|
||||||
static const char kProcessIdField[] = "processId";
|
constexpr std::string_view kProcessIdField = "processId";
|
||||||
static const char kRequestTypeField[] = "requestType";
|
constexpr std::string_view kRequestTypeField = "requestType";
|
||||||
static const char kRoutingIdField[] = "routingId";
|
constexpr std::string_view kRoutingIdField = "routingId";
|
||||||
static const char kSessionIdField[] = "sessionId";
|
constexpr std::string_view kSessionIdField = "sessionId";
|
||||||
static const char kSupportedApiTypesField[] = "supportedApiTypes";
|
constexpr std::string_view kSupportedApiTypesField = "supportedApiTypes";
|
||||||
static const char kTreeField[] = "tree";
|
constexpr std::string_view kTreeField = "tree";
|
||||||
static const char kTypeField[] = "type";
|
constexpr std::string_view kTypeField = "type";
|
||||||
static const char kUrlField[] = "url";
|
constexpr std::string_view kUrlField = "url";
|
||||||
static const char kWidgetsField[] = "widgets";
|
constexpr std::string_view kWidgetsField = "widgets";
|
||||||
static const char kApiTypeField[] = "apiType";
|
constexpr std::string_view kApiTypeField = "apiType";
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
#if defined(USE_AURA)
|
||||||
static const char kWidgetIdField[] = "widgetId";
|
constexpr std::string_view kWidgetIdField = "widgetId";
|
||||||
static const char kWidget[] = "widget";
|
constexpr std::string_view kWidget = "widget";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Global flags
|
// Global flags
|
||||||
static const char kBrowser[] = "browser";
|
constexpr std::string_view kBrowser = "browser";
|
||||||
static const char kCopyTree[] = "copyTree";
|
constexpr std::string_view kCopyTree = "copyTree";
|
||||||
static const char kHTML[] = "html";
|
constexpr std::string_view kHTML = "html";
|
||||||
static const char kLocked[] = "locked";
|
constexpr std::string_view kLocked = "locked";
|
||||||
static const char kNative[] = "native";
|
constexpr std::string_view kNative = "native";
|
||||||
static const char kPage[] = "page";
|
constexpr std::string_view kPage = "page";
|
||||||
static const char kPDFPrinting[] = "pdfPrinting";
|
constexpr std::string_view kPDFPrinting = "pdfPrinting";
|
||||||
static const char kScreenReader[] = "screenreader";
|
constexpr std::string_view kScreenReader = "screenreader";
|
||||||
static const char kShowOrRefreshTree[] = "showOrRefreshTree";
|
constexpr std::string_view kShowOrRefreshTree = "showOrRefreshTree";
|
||||||
static const char kText[] = "text";
|
constexpr std::string_view kText = "text";
|
||||||
static const char kViewsAccessibility[] = "viewsAccessibility";
|
constexpr std::string_view kViewsAccessibility = "viewsAccessibility";
|
||||||
static const char kWeb[] = "web";
|
constexpr std::string_view kWeb = "web";
|
||||||
|
|
||||||
// Possible global flag values
|
// Possible global flag values
|
||||||
static const char kDisabled[] = "disabled";
|
constexpr std::string_view kDisabled = "disabled";
|
||||||
static const char kOff[] = "off";
|
constexpr std::string_view kOff = "off";
|
||||||
static const char kOn[] = "on";
|
constexpr std::string_view kOn = "on";
|
||||||
|
|
||||||
base::Value::Dict BuildTargetDescriptor(
|
base::Value::Dict BuildTargetDescriptor(
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr char kDeviceNameKey[] = "productName";
|
constexpr std::string_view kDeviceNameKey = "productName";
|
||||||
constexpr char kDeviceIdKey[] = "deviceId";
|
constexpr std::string_view kDeviceIdKey = "deviceId";
|
||||||
constexpr int kUsbClassMassStorage = 0x08;
|
constexpr int kUsbClassMassStorage = 0x08;
|
||||||
|
|
||||||
bool CanStorePersistentEntry(const device::mojom::UsbDeviceInfo& device_info) {
|
bool CanStorePersistentEntry(const device::mojom::UsbDeviceInfo& device_info) {
|
||||||
|
|
|
@ -22,11 +22,13 @@ namespace electron {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Double that indicates the default zoom level.
|
// Double that indicates the default zoom level.
|
||||||
const char kPartitionDefaultZoomLevel[] = "partition.default_zoom_level";
|
constexpr std::string_view kPartitionDefaultZoomLevel =
|
||||||
|
"partition.default_zoom_level";
|
||||||
|
|
||||||
// Dictionary that maps hostnames to zoom levels. Hosts not in this pref will
|
// Dictionary that maps hostnames to zoom levels. Hosts not in this pref will
|
||||||
// be displayed at the default zoom level.
|
// be displayed at the default zoom level.
|
||||||
const char kPartitionPerHostZoomLevels[] = "partition.per_host_zoom_levels";
|
constexpr std::string_view kPartitionPerHostZoomLevels =
|
||||||
|
"partition.per_host_zoom_levels";
|
||||||
|
|
||||||
std::string GetHash(const base::FilePath& partition_path) {
|
std::string GetHash(const base::FilePath& partition_path) {
|
||||||
size_t int_key = std::hash<base::FilePath>()(partition_path);
|
size_t int_key = std::hash<base::FilePath>()(partition_path);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "electron/shell/renderer/electron_api_service_impl.h"
|
#include "electron/shell/renderer/electron_api_service_impl.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string_view>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -32,7 +33,7 @@ namespace electron {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char kIpcKey[] = "ipcNative";
|
constexpr std::string_view kIpcKey = "ipcNative";
|
||||||
|
|
||||||
// Gets the private object under kIpcKey
|
// Gets the private object under kIpcKey
|
||||||
v8::Local<v8::Object> GetIpcObject(v8::Local<v8::Context> context) {
|
v8::Local<v8::Object> GetIpcObject(v8::Local<v8::Context> context) {
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace electron {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char kEmitProcessEventKey[] = "emit-process-event";
|
constexpr std::string_view kEmitProcessEventKey = "emit-process-event";
|
||||||
const char kBindingCacheKey[] = "native-binding-cache";
|
constexpr std::string_view kBindingCacheKey = "native-binding-cache";
|
||||||
|
|
||||||
v8::Local<v8::Object> GetBindingCache(v8::Isolate* isolate) {
|
v8::Local<v8::Object> GetBindingCache(v8::Isolate* isolate) {
|
||||||
auto context = isolate->GetCurrentContext();
|
auto context = isolate->GetCurrentContext();
|
||||||
|
|
Loading…
Reference in a new issue