refactor: replace base::EndsWith() with std::ends_with() (#41937)

This commit is contained in:
Charles Kerr 2024-04-23 21:13:59 -05:00 committed by GitHub
parent 7621e7cff7
commit b684a98267
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 20 deletions

View file

@ -33,14 +33,12 @@ base::FilePath GetHelperAppPath(const base::FilePath& frameworks_path,
base::PathService::Get(base::FILE_EXE, &path); base::PathService::Get(base::FILE_EXE, &path);
std::string helper_name = "Helper"; std::string helper_name = "Helper";
if (base::EndsWith(path.value(), content::kMacHelperSuffix_renderer, if (const auto& val = path.value();
base::CompareCase::SENSITIVE)) { val.ends_with(content::kMacHelperSuffix_renderer)) {
helper_name += content::kMacHelperSuffix_renderer; helper_name += content::kMacHelperSuffix_renderer;
} else if (base::EndsWith(path.value(), content::kMacHelperSuffix_gpu, } else if (val.ends_with(content::kMacHelperSuffix_gpu)) {
base::CompareCase::SENSITIVE)) {
helper_name += content::kMacHelperSuffix_gpu; helper_name += content::kMacHelperSuffix_gpu;
} else if (base::EndsWith(path.value(), content::kMacHelperSuffix_plugin, } else if (val.ends_with(content::kMacHelperSuffix_plugin)) {
base::CompareCase::SENSITIVE)) {
helper_name += content::kMacHelperSuffix_plugin; helper_name += content::kMacHelperSuffix_plugin;
} }

View file

@ -1545,8 +1545,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
if (partition.empty()) { if (partition.empty()) {
browser_context = browser_context =
ElectronBrowserContext::From("", false, std::move(options)); ElectronBrowserContext::From("", false, std::move(options));
} else if (base::StartsWith(partition, kPersistPrefix, } else if (partition.starts_with(kPersistPrefix)) {
base::CompareCase::SENSITIVE)) {
std::string name = partition.substr(8); std::string name = partition.substr(8);
browser_context = browser_context =
ElectronBrowserContext::From(name, false, std::move(options)); ElectronBrowserContext::From(name, false, std::move(options));

View file

@ -106,12 +106,9 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
const std::vector<std::string> argv = {kXdgSettings, "check", const std::vector<std::string> argv = {kXdgSettings, "check",
kXdgSettingsDefaultSchemeHandler, kXdgSettingsDefaultSchemeHandler,
protocol, desktop_name}; protocol, desktop_name};
const auto output = GetXdgAppOutput(argv);
if (!output)
return false;
// Allow any reply that starts with "yes". // Allow any reply that starts with "yes".
return base::StartsWith(output.value(), "yes", base::CompareCase::SENSITIVE); const std::optional<std::string> output = GetXdgAppOutput(argv);
return output && output->starts_with("yes");
} }
// Todo implement // Todo implement

View file

@ -31,13 +31,10 @@ base::FilePath MainApplicationBundlePath() {
// Up to Contents. // Up to Contents.
if (!HasMainProcessKey() && if (!HasMainProcessKey() &&
(base::EndsWith(path.value(), " Helper", base::CompareCase::SENSITIVE) || (path.value().ends_with(" Helper") ||
base::EndsWith(path.value(), content::kMacHelperSuffix_plugin, path.value().ends_with(content::kMacHelperSuffix_plugin) ||
base::CompareCase::SENSITIVE) || path.value().ends_with(content::kMacHelperSuffix_renderer) ||
base::EndsWith(path.value(), content::kMacHelperSuffix_renderer, path.value().ends_with(content::kMacHelperSuffix_gpu))) {
base::CompareCase::SENSITIVE) ||
base::EndsWith(path.value(), content::kMacHelperSuffix_gpu,
base::CompareCase::SENSITIVE))) {
// The running executable is the helper. Go up five steps: // The running executable is the helper. Go up five steps:
// Contents/Frameworks/Helper.app/Contents/MacOS/Helper // Contents/Frameworks/Helper.app/Contents/MacOS/Helper
// ^ to here ^ from here // ^ to here ^ from here