Skip to content

Commit

Permalink
refactor: replace base::EndsWith() with std::ends_with() (#41937)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckerr committed Apr 24, 2024
1 parent 7621e7c commit b684a98
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
10 changes: 4 additions & 6 deletions shell/app/electron_main_delegate_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@
base::PathService::Get(base::FILE_EXE, &path);

std::string helper_name = "Helper";
if (base::EndsWith(path.value(), content::kMacHelperSuffix_renderer,
base::CompareCase::SENSITIVE)) {
if (const auto& val = path.value();
val.ends_with(content::kMacHelperSuffix_renderer)) {
helper_name += content::kMacHelperSuffix_renderer;
} else if (base::EndsWith(path.value(), content::kMacHelperSuffix_gpu,
base::CompareCase::SENSITIVE)) {
} else if (val.ends_with(content::kMacHelperSuffix_gpu)) {
helper_name += content::kMacHelperSuffix_gpu;
} else if (base::EndsWith(path.value(), content::kMacHelperSuffix_plugin,
base::CompareCase::SENSITIVE)) {
} else if (val.ends_with(content::kMacHelperSuffix_plugin)) {
helper_name += content::kMacHelperSuffix_plugin;
}

Expand Down
3 changes: 1 addition & 2 deletions shell/browser/api/electron_api_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
if (partition.empty()) {
browser_context =
ElectronBrowserContext::From("", false, std::move(options));
} else if (base::StartsWith(partition, kPersistPrefix,
base::CompareCase::SENSITIVE)) {
} else if (partition.starts_with(kPersistPrefix)) {
std::string name = partition.substr(8);
browser_context =
ElectronBrowserContext::From(name, false, std::move(options));
Expand Down
7 changes: 2 additions & 5 deletions shell/browser/browser_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,9 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
const std::vector<std::string> argv = {kXdgSettings, "check",
kXdgSettingsDefaultSchemeHandler,
protocol, desktop_name};
const auto output = GetXdgAppOutput(argv);
if (!output)
return false;

// 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
Expand Down
11 changes: 4 additions & 7 deletions shell/common/mac/main_application_bundle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@ bool HasMainProcessKey() {

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

0 comments on commit b684a98

Please sign in to comment.