Charles Kerr 2024-08-02 21:21:59 -05:00 committed by GitHub
parent 305b28e9c7
commit 5a809a6694
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 28 additions and 24 deletions

View file

@ -4,9 +4,9 @@
#include "shell/browser/electron_browser_context.h" #include "shell/browser/electron_browser_context.h"
#include <algorithm>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <utility> #include <utility>
#include "base/barrier_closure.h" #include "base/barrier_closure.h"
@ -129,7 +129,7 @@ media::mojom::CaptureHandlePtr CreateCaptureHandle(
const auto& captured_config = captured->GetCaptureHandleConfig(); const auto& captured_config = captured->GetCaptureHandleConfig();
if (!captured_config.all_origins_permitted && if (!captured_config.all_origins_permitted &&
base::ranges::none_of( std::ranges::none_of(
captured_config.permitted_origins, captured_config.permitted_origins,
[capturer_origin](const url::Origin& permitted_origin) { [capturer_origin](const url::Origin& permitted_origin) {
return capturer_origin.IsSameOriginWith(permitted_origin); return capturer_origin.IsSameOriginWith(permitted_origin);

View file

@ -4,6 +4,7 @@
#include "shell/browser/file_system_access/file_system_access_permission_context.h" #include "shell/browser/file_system_access/file_system_access_permission_context.h"
#include <algorithm>
#include <string> #include <string>
#include <utility> #include <utility>
@ -98,7 +99,7 @@ constexpr base::TimeDelta kPermissionRevocationTimeout = base::Seconds(5);
#if BUILDFLAG(IS_WIN) #if BUILDFLAG(IS_WIN)
[[nodiscard]] constexpr bool ContainsInvalidDNSCharacter( [[nodiscard]] constexpr bool ContainsInvalidDNSCharacter(
base::FilePath::StringType hostname) { base::FilePath::StringType hostname) {
return !base::ranges::all_of(hostname, [](base::FilePath::CharType c) { return !std::ranges::all_of(hostname, [](base::FilePath::CharType c) {
return (c >= L'A' && c <= L'Z') || (c >= L'a' && c <= L'z') || return (c >= L'A' && c <= L'Z') || (c >= L'a' && c <= L'z') ||
(c >= L'0' && c <= L'9') || (c == L'.') || (c == L'-'); (c >= L'0' && c <= L'9') || (c == L'.') || (c == L'-');
}); });
@ -355,7 +356,7 @@ class FileSystemAccessPermissionContext::PermissionGrantImpl
const base::FilePath& old_path, const base::FilePath& old_path,
const base::FilePath& new_path) { const base::FilePath& new_path) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto entry_it = base::ranges::find_if( auto entry_it = std::ranges::find_if(
grants, grants,
[&old_path](const auto& entry) { return entry.first == old_path; }); [&old_path](const auto& entry) { return entry.first == old_path; });
@ -683,7 +684,7 @@ void FileSystemAccessPermissionContext::MaybeEvictEntries(
return; return;
} }
base::ranges::sort(entries); std::ranges::sort(entries);
size_t entries_to_remove = entries.size() - max_ids_per_origin_; size_t entries_to_remove = entries.size() - max_ids_per_origin_;
for (size_t i = 0; i < entries_to_remove; ++i) { for (size_t i = 0; i < entries_to_remove; ++i) {
bool did_remove_entry = dict.Remove(entries[i].second); bool did_remove_entry = dict.Remove(entries[i].second);
@ -862,7 +863,7 @@ bool FileSystemAccessPermissionContext::OriginHasReadAccess(
auto it = active_permissions_map_.find(origin); auto it = active_permissions_map_.find(origin);
if (it != active_permissions_map_.end()) { if (it != active_permissions_map_.end()) {
return base::ranges::any_of(it->second.read_grants, [&](const auto& grant) { return std::ranges::any_of(it->second.read_grants, [&](const auto& grant) {
return grant.second->GetStatus() == PermissionStatus::GRANTED; return grant.second->GetStatus() == PermissionStatus::GRANTED;
}); });
} }
@ -876,10 +877,9 @@ bool FileSystemAccessPermissionContext::OriginHasWriteAccess(
auto it = active_permissions_map_.find(origin); auto it = active_permissions_map_.find(origin);
if (it != active_permissions_map_.end()) { if (it != active_permissions_map_.end()) {
return base::ranges::any_of( return std::ranges::any_of(it->second.write_grants, [&](const auto& grant) {
it->second.write_grants, [&](const auto& grant) { return grant.second->GetStatus() == PermissionStatus::GRANTED;
return grant.second->GetStatus() == PermissionStatus::GRANTED; });
});
} }
return false; return false;

View file

@ -4,6 +4,7 @@
#include "shell/browser/hid/hid_chooser_controller.h" #include "shell/browser/hid/hid_chooser_controller.h"
#include <algorithm>
#include <utility> #include <utility>
#include "base/command_line.h" #include "base/command_line.h"
@ -368,8 +369,8 @@ void HidChooserController::UpdateDeviceInfo(
auto physical_device_it = device_map_.find(id); auto physical_device_it = device_map_.find(id);
DCHECK(physical_device_it != device_map_.end()); DCHECK(physical_device_it != device_map_.end());
auto& device_infos = physical_device_it->second; auto& device_infos = physical_device_it->second;
auto device_it = base::ranges::find(device_infos, device.guid, auto device_it = std::ranges::find(device_infos, device.guid,
&device::mojom::HidDeviceInfo::guid); &device::mojom::HidDeviceInfo::guid);
DCHECK(device_it != device_infos.end()); DCHECK(device_it != device_infos.end());
*device_it = device.Clone(); *device_it = device.Clone();
} }

View file

@ -154,8 +154,8 @@ void SerialChooserController::OnPortAdded(
void SerialChooserController::OnPortRemoved( void SerialChooserController::OnPortRemoved(
const device::mojom::SerialPortInfo& port) { const device::mojom::SerialPortInfo& port) {
const auto it = base::ranges::find(ports_, port.token, const auto it = std::ranges::find(ports_, port.token,
&device::mojom::SerialPortInfo::token); &device::mojom::SerialPortInfo::token);
if (it != ports_.end()) { if (it != ports_.end()) {
api::Session* session = GetSession(); api::Session* session = GetSession();
if (session) { if (session) {

View file

@ -2,6 +2,7 @@
// Use of this source code is governed by the MIT license that can be // Use of this source code is governed by the MIT license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <algorithm>
#include <vector> #include <vector>
#include "base/files/file_util.h" #include "base/files/file_util.h"
@ -45,7 +46,7 @@ ui::SelectFileDialog::FileTypeInfo GetFilterInfo(const Filters& filters) {
file_type_info.extension_description_overrides.push_back( file_type_info.extension_description_overrides.push_back(
base::UTF8ToUTF16(name)); base::UTF8ToUTF16(name));
const bool has_all_files_wildcard = base::ranges::any_of( const bool has_all_files_wildcard = std::ranges::any_of(
extension_group, [](const auto& ext) { return ext == "*"; }); extension_group, [](const auto& ext) { return ext == "*"; });
if (has_all_files_wildcard) { if (has_all_files_wildcard) {
file_type_info.include_all_files = true; file_type_info.include_all_files = true;

View file

@ -5,6 +5,7 @@
#include "shell/browser/ui/inspectable_web_contents.h" #include "shell/browser/ui/inspectable_web_contents.h"
#include <algorithm>
#include <memory> #include <memory>
#include <string_view> #include <string_view>
#include <utility> #include <utility>
@ -13,7 +14,6 @@
#include "base/base64.h" #include "base/base64.h"
#include "base/memory/raw_ptr.h" #include "base/memory/raw_ptr.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/ranges/algorithm.h"
#include "base/strings/pattern.h" #include "base/strings/pattern.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
@ -111,10 +111,10 @@ gfx::Rect DictionaryToRect(const base::Value::Dict& dict) {
} }
bool IsPointInScreen(const gfx::Point& point) { bool IsPointInScreen(const gfx::Point& point) {
return base::ranges::any_of(display::Screen::GetScreen()->GetAllDisplays(), return std::ranges::any_of(display::Screen::GetScreen()->GetAllDisplays(),
[&point](auto const& display) { [&point](auto const& display) {
return display.bounds().Contains(point); return display.bounds().Contains(point);
}); });
} }
void SetZoomLevelForWebContents(content::WebContents* web_contents, void SetZoomLevelForWebContents(content::WebContents* web_contents,

View file

@ -4,11 +4,11 @@
#include "shell/browser/usb/usb_chooser_controller.h" #include "shell/browser/usb/usb_chooser_controller.h"
#include <stddef.h> #include <algorithm>
#include <cstddef>
#include <utility> #include <utility>
#include "base/functional/bind.h" #include "base/functional/bind.h"
#include "base/ranges/algorithm.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
@ -146,7 +146,7 @@ bool UsbChooserController::DisplayDevice(
return false; return false;
} }
if (base::ranges::any_of( if (std::ranges::any_of(
options_->exclusion_filters, [&device_info](const auto& filter) { options_->exclusion_filters, [&device_info](const auto& filter) {
return device::UsbDeviceFilterMatches(*filter, device_info); return device::UsbDeviceFilterMatches(*filter, device_info);
})) { })) {

View file

@ -4,6 +4,8 @@
#include "shell/renderer/electron_renderer_client.h" #include "shell/renderer/electron_renderer_client.h"
#include <algorithm>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/containers/contains.h" #include "base/containers/contains.h"
#include "base/debug/stack_trace.h" #include "base/debug/stack_trace.h"
@ -163,7 +165,7 @@ void ElectronRendererClient::WillReleaseScriptContext(
return; return;
node::Environment* env = node::Environment::GetCurrent(context); node::Environment* env = node::Environment::GetCurrent(context);
const auto iter = base::ranges::find_if( const auto iter = std::ranges::find_if(
environments_, [env](auto& item) { return env == item.get(); }); environments_, [env](auto& item) { return env == item.get(); });
if (iter == environments_.end()) if (iter == environments_.end())
return; return;