refactor: use C++20's contains() method (35-x-y) (#45768)
refactor: use C++20's contains() method (#45742) * chore: use std::map<>::contains() instead of count() or find() * chore: use std::map<>::contains() instead of base::Contains()
This commit is contained in:
parent
2da02ec9bc
commit
4c81971213
29 changed files with 52 additions and 75 deletions
|
@ -9,7 +9,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/task/single_thread_task_runner.h"
|
#include "base/task/single_thread_task_runner.h"
|
||||||
#include "content/public/common/color_parser.h"
|
#include "content/public/common/color_parser.h"
|
||||||
#include "electron/buildflags/buildflags.h"
|
#include "electron/buildflags/buildflags.h"
|
||||||
|
@ -1052,7 +1051,7 @@ void BaseWindow::UnhookWindowMessage(UINT message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseWindow::IsWindowMessageHooked(UINT message) {
|
bool BaseWindow::IsWindowMessageHooked(UINT message) {
|
||||||
return base::Contains(messages_callback_map_, message);
|
return messages_callback_map_.contains(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWindow::UnhookAllWindowMessages() {
|
void BaseWindow::UnhookAllWindowMessages() {
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "extensions/common/command.h"
|
#include "extensions/common/command.h"
|
||||||
#include "gin/dictionary.h"
|
#include "gin/dictionary.h"
|
||||||
#include "gin/handle.h"
|
#include "gin/handle.h"
|
||||||
|
@ -52,7 +51,7 @@ GlobalShortcut::~GlobalShortcut() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcut::OnKeyPressed(const ui::Accelerator& accelerator) {
|
void GlobalShortcut::OnKeyPressed(const ui::Accelerator& accelerator) {
|
||||||
if (!base::Contains(accelerator_callback_map_, accelerator)) {
|
if (!accelerator_callback_map_.contains(accelerator)) {
|
||||||
// This should never occur, because if it does,
|
// This should never occur, because if it does,
|
||||||
// ui::GlobalAcceleratorListener notifies us with wrong accelerator.
|
// ui::GlobalAcceleratorListener notifies us with wrong accelerator.
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
|
@ -139,7 +138,7 @@ void GlobalShortcut::UnregisterSome(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) {
|
bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) {
|
||||||
return base::Contains(accelerator_callback_map_, accelerator);
|
return accelerator_callback_map_.contains(accelerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcut::UnregisterAll() {
|
void GlobalShortcut::UnregisterAll() {
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/functional/callback_helpers.h"
|
#include "base/functional/callback_helpers.h"
|
||||||
#include "content/public/browser/device_service.h"
|
#include "content/public/browser/device_service.h"
|
||||||
#include "gin/dictionary.h"
|
#include "gin/dictionary.h"
|
||||||
|
@ -110,7 +109,7 @@ bool PowerSaveBlocker::Stop(int id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PowerSaveBlocker::IsStarted(int id) const {
|
bool PowerSaveBlocker::IsStarted(int id) const {
|
||||||
return base::Contains(wake_lock_types_, id);
|
return wake_lock_types_.contains(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
|
#include "base/containers/contains.h"
|
||||||
#include "content/common/url_schemes.h"
|
#include "content/common/url_schemes.h"
|
||||||
#include "content/public/browser/child_process_security_policy.h"
|
#include "content/public/browser/child_process_security_policy.h"
|
||||||
#include "gin/handle.h"
|
#include "gin/handle.h"
|
||||||
|
|
|
@ -1523,7 +1523,7 @@ v8::Local<v8::Promise> Session::ClearCodeCaches(
|
||||||
if (options.Get("urls", &url_list) && !url_list.empty()) {
|
if (options.Get("urls", &url_list) && !url_list.empty()) {
|
||||||
url_matcher = base::BindRepeating(
|
url_matcher = base::BindRepeating(
|
||||||
[](const std::set<GURL>& url_list, const GURL& url) {
|
[](const std::set<GURL>& url_list, const GURL& url) {
|
||||||
return base::Contains(url_list, url);
|
return url_list.contains(url);
|
||||||
},
|
},
|
||||||
url_list);
|
url_list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/base64.h"
|
#include "base/base64.h"
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/containers/fixed_flat_map.h"
|
#include "base/containers/fixed_flat_map.h"
|
||||||
#include "base/containers/id_map.h"
|
#include "base/containers/id_map.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
|
@ -700,8 +699,7 @@ std::map<std::string, std::string> GetAddedFileSystemPaths(
|
||||||
|
|
||||||
bool IsDevToolsFileSystemAdded(content::WebContents* web_contents,
|
bool IsDevToolsFileSystemAdded(content::WebContents* web_contents,
|
||||||
const std::string& file_system_path) {
|
const std::string& file_system_path) {
|
||||||
return base::Contains(GetAddedFileSystemPaths(web_contents),
|
return GetAddedFileSystemPaths(web_contents).contains(file_system_path);
|
||||||
file_system_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content::RenderFrameHost* GetRenderFrameHost(
|
content::RenderFrameHost* GetRenderFrameHost(
|
||||||
|
@ -4249,7 +4247,7 @@ void WebContents::DevToolsIndexPath(
|
||||||
OnDevToolsIndexingDone(request_id, file_system_path);
|
OnDevToolsIndexingDone(request_id, file_system_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (devtools_indexing_jobs_.count(request_id) != 0)
|
if (devtools_indexing_jobs_.contains(request_id))
|
||||||
return;
|
return;
|
||||||
std::vector<std::string> excluded_folders;
|
std::vector<std::string> excluded_folders;
|
||||||
std::optional<base::Value> parsed_excluded_folders =
|
std::optional<base::Value> parsed_excluded_folders =
|
||||||
|
|
|
@ -160,7 +160,7 @@ WebFrameMain::WebFrameMain(content::RenderFrameHost* rfh)
|
||||||
if (!render_frame_detached_)
|
if (!render_frame_detached_)
|
||||||
GetFrameTreeNodeIdMap().emplace(frame_tree_node_id_, this);
|
GetFrameTreeNodeIdMap().emplace(frame_tree_node_id_, this);
|
||||||
|
|
||||||
DCHECK(GetFrameTokenMap().find(frame_token_) == GetFrameTokenMap().end());
|
DCHECK(!GetFrameTokenMap().contains(frame_token_));
|
||||||
GetFrameTokenMap().emplace(frame_token_, this);
|
GetFrameTokenMap().emplace(frame_token_, this);
|
||||||
|
|
||||||
// WebFrameMain should only be created for active or unloading frames.
|
// WebFrameMain should only be created for active or unloading frames.
|
||||||
|
@ -198,7 +198,7 @@ void WebFrameMain::UpdateRenderFrameHost(content::RenderFrameHost* rfh) {
|
||||||
// Ensure that RFH being swapped in doesn't already exist as its own
|
// Ensure that RFH being swapped in doesn't already exist as its own
|
||||||
// WebFrameMain instance.
|
// WebFrameMain instance.
|
||||||
frame_token_ = rfh->GetGlobalFrameToken();
|
frame_token_ = rfh->GetGlobalFrameToken();
|
||||||
DCHECK(GetFrameTokenMap().find(frame_token_) == GetFrameTokenMap().end());
|
DCHECK(!GetFrameTokenMap().contains(frame_token_));
|
||||||
GetFrameTokenMap().emplace(frame_token_, this);
|
GetFrameTokenMap().emplace(frame_token_, this);
|
||||||
|
|
||||||
render_frame_disposed_ = false;
|
render_frame_disposed_ = false;
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/containers/fixed_flat_map.h"
|
#include "base/containers/fixed_flat_map.h"
|
||||||
#include "base/memory/raw_ptr.h"
|
#include "base/memory/raw_ptr.h"
|
||||||
#include "base/task/sequenced_task_runner.h"
|
#include "base/task/sequenced_task_runner.h"
|
||||||
|
@ -251,7 +250,7 @@ bool WebRequest::RequestFilter::MatchesURL(
|
||||||
|
|
||||||
bool WebRequest::RequestFilter::MatchesType(
|
bool WebRequest::RequestFilter::MatchesType(
|
||||||
extensions::WebRequestResourceType type) const {
|
extensions::WebRequestResourceType type) const {
|
||||||
return types_.empty() || base::Contains(types_, type);
|
return types_.empty() || types_.contains(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebRequest::RequestFilter::MatchesRequest(
|
bool WebRequest::RequestFilter::MatchesRequest(
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/containers/to_vector.h"
|
#include "base/containers/to_vector.h"
|
||||||
#include "base/task/single_thread_task_runner.h"
|
#include "base/task/single_thread_task_runner.h"
|
||||||
#include "gin/arguments.h"
|
#include "gin/arguments.h"
|
||||||
|
@ -233,7 +232,7 @@ std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
|
||||||
// or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec).
|
// or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec).
|
||||||
for (unsigned i = 0; i < ports.size(); ++i) {
|
for (unsigned i = 0; i < ports.size(); ++i) {
|
||||||
auto* port = ports[i].get();
|
auto* port = ports[i].get();
|
||||||
if (!port || port->IsNeutered() || base::Contains(visited, port)) {
|
if (!port || port->IsNeutered() || visited.contains(port)) {
|
||||||
std::string type;
|
std::string type;
|
||||||
if (!port)
|
if (!port)
|
||||||
type = "null";
|
type = "null";
|
||||||
|
|
|
@ -83,7 +83,7 @@ AutofillDriver* AutofillDriverFactory::DriverForFrame(
|
||||||
driver.get());
|
driver.get());
|
||||||
} else {
|
} else {
|
||||||
driver_map_.erase(insertion_result.first);
|
driver_map_.erase(insertion_result.first);
|
||||||
DCHECK_EQ(driver_map_.count(render_frame_host), 0u);
|
DCHECK(!driver_map_.contains(render_frame_host));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,7 +379,7 @@ content::SiteInstance* ElectronBrowserClient::GetSiteInstanceFromAffinity(
|
||||||
|
|
||||||
bool ElectronBrowserClient::IsRendererSubFrame(
|
bool ElectronBrowserClient::IsRendererSubFrame(
|
||||||
content::ChildProcessId process_id) const {
|
content::ChildProcessId process_id) const {
|
||||||
return base::Contains(renderer_is_subframe_, process_id);
|
return renderer_is_subframe_.contains(process_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElectronBrowserClient::RenderProcessWillLaunch(
|
void ElectronBrowserClient::RenderProcessWillLaunch(
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "base/check.h"
|
#include "base/check.h"
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/json/json_writer.h"
|
#include "base/json/json_writer.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
@ -1085,13 +1084,13 @@ ScriptingGetRegisteredContentScriptsFunction::Run() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!id_filter.empty() && !base::Contains(id_filter, script->id())) {
|
if (!id_filter.empty() && !id_filter.contains(script->id())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto registered_script = CreateRegisteredContentScriptInfo(*script);
|
auto registered_script = CreateRegisteredContentScriptInfo(*script);
|
||||||
registered_script.persist_across_sessions =
|
registered_script.persist_across_sessions =
|
||||||
base::Contains(persistent_script_ids, script->id());
|
persistent_script_ids.contains(script->id());
|
||||||
|
|
||||||
// Remove the internally used prefix from the `script`'s ID before
|
// Remove the internally used prefix from the `script`'s ID before
|
||||||
// returning.
|
// returning.
|
||||||
|
@ -1261,7 +1260,7 @@ std::unique_ptr<UserScript> ScriptingUpdateContentScriptsFunction::ApplyUpdate(
|
||||||
// original script is persisted and the flag is not specified.
|
// original script is persisted and the flag is not specified.
|
||||||
if (new_script.persist_across_sessions.value_or(false) ||
|
if (new_script.persist_across_sessions.value_or(false) ||
|
||||||
(!new_script.persist_across_sessions &&
|
(!new_script.persist_across_sessions &&
|
||||||
base::Contains(*script_ids_to_persist, new_script.id))) {
|
script_ids_to_persist->contains(new_script.id))) {
|
||||||
script_ids_to_persist->insert(new_script.id);
|
script_ids_to_persist->insert(new_script.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
|
#include "base/containers/contains.h"
|
||||||
#include "base/strings/pattern.h"
|
#include "base/strings/pattern.h"
|
||||||
#include "base/types/expected_macros.h"
|
#include "base/types/expected_macros.h"
|
||||||
#include "chrome/common/url_constants.h"
|
#include "chrome/common/url_constants.h"
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
#include "chrome/common/chrome_paths.h"
|
#include "chrome/common/chrome_paths.h"
|
||||||
|
@ -89,7 +88,7 @@ void ElectronComponentExtensionResourceManager::AddComponentResourceEntries(
|
||||||
resource_path = resource_path.NormalizePathSeparators();
|
resource_path = resource_path.NormalizePathSeparators();
|
||||||
|
|
||||||
if (!gen_folder_path.IsParent(resource_path)) {
|
if (!gen_folder_path.IsParent(resource_path)) {
|
||||||
DCHECK(!base::Contains(path_to_resource_id_, resource_path));
|
DCHECK(!path_to_resource_id_.contains(resource_path));
|
||||||
path_to_resource_id_[resource_path] = entry.id;
|
path_to_resource_id_[resource_path] = entry.id;
|
||||||
} else {
|
} else {
|
||||||
// If the resource is a generated file, strip the generated folder's path,
|
// If the resource is a generated file, strip the generated folder's path,
|
||||||
|
@ -98,7 +97,7 @@ void ElectronComponentExtensionResourceManager::AddComponentResourceEntries(
|
||||||
base::FilePath effective_path =
|
base::FilePath effective_path =
|
||||||
base::FilePath().AppendASCII(resource_path.AsUTF8Unsafe().substr(
|
base::FilePath().AppendASCII(resource_path.AsUTF8Unsafe().substr(
|
||||||
gen_folder_path.value().length()));
|
gen_folder_path.value().length()));
|
||||||
DCHECK(!base::Contains(path_to_resource_id_, effective_path));
|
DCHECK(!path_to_resource_id_.contains(effective_path));
|
||||||
path_to_resource_id_[effective_path] = entry.id;
|
path_to_resource_id_[effective_path] = entry.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/scoped_observation.h"
|
#include "base/scoped_observation.h"
|
||||||
#include "chrome/common/chrome_features.h"
|
#include "chrome/common/chrome_features.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
|
@ -118,7 +117,7 @@ std::unique_ptr<content::HidChooser> ElectronHidDelegate::RunChooser(
|
||||||
|
|
||||||
// Start observing HidChooserContext for permission and device events.
|
// Start observing HidChooserContext for permission and device events.
|
||||||
GetContextObserver(browser_context);
|
GetContextObserver(browser_context);
|
||||||
DCHECK(base::Contains(observations_, browser_context));
|
DCHECK(observations_.contains(browser_context));
|
||||||
|
|
||||||
HidChooserController* controller = ControllerForFrame(render_frame_host);
|
HidChooserController* controller = ControllerForFrame(render_frame_host);
|
||||||
if (controller) {
|
if (controller) {
|
||||||
|
@ -188,7 +187,7 @@ void ElectronHidDelegate::RemoveObserver(
|
||||||
content::HidDelegate::Observer* observer) {
|
content::HidDelegate::Observer* observer) {
|
||||||
if (!browser_context)
|
if (!browser_context)
|
||||||
return;
|
return;
|
||||||
DCHECK(base::Contains(observations_, browser_context));
|
DCHECK(observations_.contains(browser_context));
|
||||||
GetContextObserver(browser_context)->RemoveObserver(observer);
|
GetContextObserver(browser_context)->RemoveObserver(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +221,7 @@ bool ElectronHidDelegate::IsServiceWorkerAllowedForOrigin(
|
||||||
ElectronHidDelegate::ContextObservation*
|
ElectronHidDelegate::ContextObservation*
|
||||||
ElectronHidDelegate::GetContextObserver(
|
ElectronHidDelegate::GetContextObserver(
|
||||||
content::BrowserContext* browser_context) {
|
content::BrowserContext* browser_context) {
|
||||||
if (!base::Contains(observations_, browser_context)) {
|
if (!observations_.contains(browser_context)) {
|
||||||
observations_.emplace(browser_context, std::make_unique<ContextObservation>(
|
observations_.emplace(browser_context, std::make_unique<ContextObservation>(
|
||||||
this, browser_context));
|
this, browser_context));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/containers/map_util.h"
|
#include "base/containers/map_util.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
|
@ -94,7 +93,7 @@ base::Value HidChooserContext::DeviceInfoToValue(
|
||||||
void HidChooserContext::GrantDevicePermission(
|
void HidChooserContext::GrantDevicePermission(
|
||||||
const url::Origin& origin,
|
const url::Origin& origin,
|
||||||
const device::mojom::HidDeviceInfo& device) {
|
const device::mojom::HidDeviceInfo& device) {
|
||||||
DCHECK(base::Contains(devices_, device.guid));
|
DCHECK(devices_.contains(device.guid));
|
||||||
if (CanStorePersistentEntry(device)) {
|
if (CanStorePersistentEntry(device)) {
|
||||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||||
browser_context_->GetPermissionControllerDelegate());
|
browser_context_->GetPermissionControllerDelegate());
|
||||||
|
@ -111,7 +110,7 @@ void HidChooserContext::GrantDevicePermission(
|
||||||
void HidChooserContext::RevokeDevicePermission(
|
void HidChooserContext::RevokeDevicePermission(
|
||||||
const url::Origin& origin,
|
const url::Origin& origin,
|
||||||
const device::mojom::HidDeviceInfo& device) {
|
const device::mojom::HidDeviceInfo& device) {
|
||||||
DCHECK(base::Contains(devices_, device.guid));
|
DCHECK(devices_.contains(device.guid));
|
||||||
if (CanStorePersistentEntry(device)) {
|
if (CanStorePersistentEntry(device)) {
|
||||||
RevokePersistentDevicePermission(origin, device);
|
RevokePersistentDevicePermission(origin, device);
|
||||||
} else {
|
} else {
|
||||||
|
@ -167,8 +166,7 @@ bool HidChooserContext::HasDevicePermission(
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto it = ephemeral_devices_.find(origin);
|
auto it = ephemeral_devices_.find(origin);
|
||||||
if (it != ephemeral_devices_.end() &&
|
if (it != ephemeral_devices_.end() && it->second.contains(device.guid)) {
|
||||||
base::Contains(it->second, device.guid)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +187,7 @@ bool HidChooserContext::IsFidoAllowedForOrigin(const url::Origin& origin) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (origin.scheme() == extensions::kExtensionScheme &&
|
if (origin.scheme() == extensions::kExtensionScheme &&
|
||||||
base::Contains(kPrivilegedExtensionIds, origin.host())) {
|
kPrivilegedExtensionIds.contains(origin.host())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
#endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||||
|
@ -245,7 +243,7 @@ void HidChooserContext::DeviceAdded(device::mojom::HidDeviceInfoPtr device) {
|
||||||
DCHECK(device);
|
DCHECK(device);
|
||||||
|
|
||||||
// Update the device list.
|
// Update the device list.
|
||||||
if (!base::Contains(devices_, device->guid))
|
if (!devices_.contains(device->guid))
|
||||||
devices_.insert({device->guid, device->Clone()});
|
devices_.insert({device->guid, device->Clone()});
|
||||||
|
|
||||||
// Notify all observers.
|
// Notify all observers.
|
||||||
|
@ -255,7 +253,7 @@ void HidChooserContext::DeviceAdded(device::mojom::HidDeviceInfoPtr device) {
|
||||||
|
|
||||||
void HidChooserContext::DeviceRemoved(device::mojom::HidDeviceInfoPtr device) {
|
void HidChooserContext::DeviceRemoved(device::mojom::HidDeviceInfoPtr device) {
|
||||||
DCHECK(device);
|
DCHECK(device);
|
||||||
DCHECK(base::Contains(devices_, device->guid));
|
DCHECK(devices_.contains(device->guid));
|
||||||
|
|
||||||
// Update the device list.
|
// Update the device list.
|
||||||
devices_.erase(device->guid);
|
devices_.erase(device->guid);
|
||||||
|
@ -276,7 +274,7 @@ void HidChooserContext::DeviceRemoved(device::mojom::HidDeviceInfoPtr device) {
|
||||||
|
|
||||||
void HidChooserContext::DeviceChanged(device::mojom::HidDeviceInfoPtr device) {
|
void HidChooserContext::DeviceChanged(device::mojom::HidDeviceInfoPtr device) {
|
||||||
DCHECK(device);
|
DCHECK(device);
|
||||||
DCHECK(base::Contains(devices_, device->guid));
|
DCHECK(devices_.contains(device->guid));
|
||||||
|
|
||||||
// Update the device list.
|
// Update the device list.
|
||||||
devices_[device->guid] = device->Clone();
|
devices_[device->guid] = device->Clone();
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "content/public/common/webplugininfo.h"
|
#include "content/public/common/webplugininfo.h"
|
||||||
#include "electron/buildflags/buildflags.h"
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "url/gurl.h"
|
#include "url/gurl.h"
|
||||||
|
@ -53,8 +52,7 @@ PluginUtils::GetMimeTypeToExtensionIdMap(
|
||||||
|
|
||||||
if (MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension)) {
|
if (MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension)) {
|
||||||
for (const auto& supported_mime_type : handler->mime_type_set()) {
|
for (const auto& supported_mime_type : handler->mime_type_set()) {
|
||||||
DCHECK(!base::Contains(mime_type_to_extension_id_map,
|
DCHECK(!mime_type_to_extension_id_map.contains(supported_mime_type));
|
||||||
supported_mime_type));
|
|
||||||
mime_type_to_extension_id_map[supported_mime_type] = extension_id;
|
mime_type_to_extension_id_map[supported_mime_type] = extension_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/base64.h"
|
#include "base/base64.h"
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
#include "content/public/browser/device_service.h"
|
#include "content/public/browser/device_service.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
|
@ -108,7 +107,7 @@ bool SerialChooserContext::HasPortPermission(
|
||||||
auto it = ephemeral_ports_.find(origin);
|
auto it = ephemeral_ports_.find(origin);
|
||||||
if (it != ephemeral_ports_.end()) {
|
if (it != ephemeral_ports_.end()) {
|
||||||
const std::set<base::UnguessableToken>& ports = it->second;
|
const std::set<base::UnguessableToken>& ports = it->second;
|
||||||
if (base::Contains(ports, port.token))
|
if (ports.contains(port.token))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +225,7 @@ base::WeakPtr<SerialChooserContext> SerialChooserContext::AsWeakPtr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialChooserContext::OnPortAdded(device::mojom::SerialPortInfoPtr port) {
|
void SerialChooserContext::OnPortAdded(device::mojom::SerialPortInfoPtr port) {
|
||||||
if (!base::Contains(port_info_, port->token))
|
if (!port_info_.contains(port->token))
|
||||||
port_info_.insert({port->token, port->Clone()});
|
port_info_.insert({port->token, port->Clone()});
|
||||||
|
|
||||||
for (auto& map_entry : ephemeral_ports_) {
|
for (auto& map_entry : ephemeral_ports_) {
|
||||||
|
|
|
@ -334,7 +334,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (bool)hasItemWithID:(const std::string&)item_id {
|
- (bool)hasItemWithID:(const std::string&)item_id {
|
||||||
return settings_.find(item_id) != settings_.end();
|
return settings_.contains(item_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor*)colorFromHexColorString:(const std::string&)colorString {
|
- (NSColor*)colorFromHexColorString:(const std::string&)colorString {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "shell/browser/ui/message_box.h"
|
#include "shell/browser/ui/message_box.h"
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/containers/flat_map.h"
|
#include "base/containers/flat_map.h"
|
||||||
#include "base/functional/bind.h"
|
#include "base/functional/bind.h"
|
||||||
#include "base/memory/raw_ptr.h"
|
#include "base/memory/raw_ptr.h"
|
||||||
|
@ -232,7 +231,7 @@ int ShowMessageBoxSync(const MessageBoxSettings& settings) {
|
||||||
|
|
||||||
void ShowMessageBox(const MessageBoxSettings& settings,
|
void ShowMessageBox(const MessageBoxSettings& settings,
|
||||||
MessageBoxCallback callback) {
|
MessageBoxCallback callback) {
|
||||||
if (settings.id && base::Contains(GetDialogsMap(), *settings.id))
|
if (settings.id && GetDialogsMap().contains(*settings.id))
|
||||||
CloseMessageBox(*settings.id);
|
CloseMessageBox(*settings.id);
|
||||||
(new GtkMessageBox(settings))->RunAsynchronous(std::move(callback));
|
(new GtkMessageBox(settings))->RunAsynchronous(std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/containers/flat_map.h"
|
#include "base/containers/flat_map.h"
|
||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
#include "base/no_destructor.h"
|
#include "base/no_destructor.h"
|
||||||
|
@ -146,7 +145,7 @@ void ShowMessageBox(const MessageBoxSettings& settings,
|
||||||
ret, alert.suppressionButton.state == NSControlStateValueOn);
|
ret, alert.suppressionButton.state == NSControlStateValueOn);
|
||||||
} else {
|
} else {
|
||||||
if (settings.id) {
|
if (settings.id) {
|
||||||
if (base::Contains(GetDialogsMap(), *settings.id))
|
if (GetDialogsMap().contains(*settings.id))
|
||||||
CloseMessageBox(*settings.id);
|
CloseMessageBox(*settings.id);
|
||||||
GetDialogsMap()[*settings.id] = alert;
|
GetDialogsMap()[*settings.id] = alert;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/containers/flat_map.h"
|
#include "base/containers/flat_map.h"
|
||||||
#include "base/no_destructor.h"
|
#include "base/no_destructor.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
|
@ -242,7 +241,7 @@ DialogResult ShowTaskDialogWstr(gfx::AcceleratedWidget parent,
|
||||||
TaskDialogIndirect(&config, &id, nullptr, &verification_flag_checked);
|
TaskDialogIndirect(&config, &id, nullptr, &verification_flag_checked);
|
||||||
|
|
||||||
int button_id;
|
int button_id;
|
||||||
if (base::Contains(id_map, id)) // common button.
|
if (id_map.contains(id)) // common button.
|
||||||
button_id = id_map[id];
|
button_id = id_map[id];
|
||||||
else if (id >= kIDStart) // custom button.
|
else if (id >= kIDStart) // custom button.
|
||||||
button_id = id - kIDStart;
|
button_id = id - kIDStart;
|
||||||
|
@ -289,7 +288,7 @@ void ShowMessageBox(const MessageBoxSettings& settings,
|
||||||
// kHwndReserve in the dialogs map for now.
|
// kHwndReserve in the dialogs map for now.
|
||||||
HWND* hwnd = nullptr;
|
HWND* hwnd = nullptr;
|
||||||
if (settings.id) {
|
if (settings.id) {
|
||||||
if (base::Contains(GetDialogsMap(), *settings.id))
|
if (GetDialogsMap().contains(*settings.id))
|
||||||
CloseMessageBox(*settings.id);
|
CloseMessageBox(*settings.id);
|
||||||
auto it = GetDialogsMap().emplace(*settings.id,
|
auto it = GetDialogsMap().emplace(*settings.id,
|
||||||
std::make_unique<HWND>(kHwndReserve));
|
std::make_unique<HWND>(kHwndReserve));
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/observer_list.h"
|
#include "base/observer_list.h"
|
||||||
#include "base/scoped_observation.h"
|
#include "base/scoped_observation.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
|
@ -72,7 +71,7 @@ bool IsDevicePermissionAutoGranted(
|
||||||
// Note: The `DeviceHasInterfaceWithClass()` call is made after checking the
|
// Note: The `DeviceHasInterfaceWithClass()` call is made after checking the
|
||||||
// origin, since that method call is expensive.
|
// origin, since that method call is expensive.
|
||||||
if (origin.scheme() == extensions::kExtensionScheme &&
|
if (origin.scheme() == extensions::kExtensionScheme &&
|
||||||
base::Contains(kSmartCardPrivilegedExtensionIds, origin.host()) &&
|
kSmartCardPrivilegedExtensionIds.contains(origin.host()) &&
|
||||||
DeviceHasInterfaceWithClass(device_info,
|
DeviceHasInterfaceWithClass(device_info,
|
||||||
device::mojom::kUsbSmartCardClass)) {
|
device::mojom::kUsbSmartCardClass)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -269,7 +268,7 @@ ElectronUsbDelegate::ContextObservation*
|
||||||
ElectronUsbDelegate::GetContextObserver(
|
ElectronUsbDelegate::GetContextObserver(
|
||||||
content::BrowserContext* browser_context) {
|
content::BrowserContext* browser_context) {
|
||||||
CHECK(browser_context);
|
CHECK(browser_context);
|
||||||
if (!base::Contains(observations_, browser_context)) {
|
if (!observations_.contains(browser_context)) {
|
||||||
observations_.emplace(browser_context, std::make_unique<ContextObservation>(
|
observations_.emplace(browser_context, std::make_unique<ContextObservation>(
|
||||||
this, browser_context));
|
this, browser_context));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/functional/bind.h"
|
#include "base/functional/bind.h"
|
||||||
#include "base/task/sequenced_task_runner.h"
|
#include "base/task/sequenced_task_runner.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
|
@ -158,7 +157,7 @@ UsbChooserContext::~UsbChooserContext() {
|
||||||
void UsbChooserContext::RevokeDevicePermissionWebInitiated(
|
void UsbChooserContext::RevokeDevicePermissionWebInitiated(
|
||||||
const url::Origin& origin,
|
const url::Origin& origin,
|
||||||
const device::mojom::UsbDeviceInfo& device) {
|
const device::mojom::UsbDeviceInfo& device) {
|
||||||
DCHECK(base::Contains(devices_, device.guid));
|
DCHECK(devices_.contains(device.guid));
|
||||||
RevokeObjectPermissionInternal(origin, DeviceInfoToValue(device),
|
RevokeObjectPermissionInternal(origin, DeviceInfoToValue(device),
|
||||||
/*revoked_by_website=*/true);
|
/*revoked_by_website=*/true);
|
||||||
}
|
}
|
||||||
|
@ -217,8 +216,7 @@ bool UsbChooserContext::HasDevicePermission(
|
||||||
const url::Origin& origin,
|
const url::Origin& origin,
|
||||||
const device::mojom::UsbDeviceInfo& device_info) {
|
const device::mojom::UsbDeviceInfo& device_info) {
|
||||||
auto it = ephemeral_devices_.find(origin);
|
auto it = ephemeral_devices_.find(origin);
|
||||||
if (it != ephemeral_devices_.end() &&
|
if (it != ephemeral_devices_.end() && it->second.contains(device_info.guid)) {
|
||||||
base::Contains(it->second, device_info.guid)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +282,7 @@ void UsbChooserContext::OnDeviceAdded(
|
||||||
device::mojom::UsbDeviceInfoPtr device_info) {
|
device::mojom::UsbDeviceInfoPtr device_info) {
|
||||||
DCHECK(device_info);
|
DCHECK(device_info);
|
||||||
// Update the device list.
|
// Update the device list.
|
||||||
DCHECK(!base::Contains(devices_, device_info->guid));
|
DCHECK(!devices_.contains(device_info->guid));
|
||||||
if (!ShouldExposeDevice(*device_info))
|
if (!ShouldExposeDevice(*device_info))
|
||||||
return;
|
return;
|
||||||
devices_.insert(std::make_pair(device_info->guid, device_info->Clone()));
|
devices_.insert(std::make_pair(device_info->guid, device_info->Clone()));
|
||||||
|
@ -299,12 +297,12 @@ void UsbChooserContext::OnDeviceRemoved(
|
||||||
DCHECK(device_info);
|
DCHECK(device_info);
|
||||||
|
|
||||||
if (!ShouldExposeDevice(*device_info)) {
|
if (!ShouldExposeDevice(*device_info)) {
|
||||||
DCHECK(!base::Contains(devices_, device_info->guid));
|
DCHECK(!devices_.contains(device_info->guid));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the device list.
|
// Update the device list.
|
||||||
DCHECK(base::Contains(devices_, device_info->guid));
|
DCHECK(devices_.contains(device_info->guid));
|
||||||
devices_.erase(device_info->guid);
|
devices_.erase(device_info->guid);
|
||||||
|
|
||||||
// Notify all device observers.
|
// Notify all device observers.
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/containers/to_vector.h"
|
#include "base/containers/to_vector.h"
|
||||||
#include "base/run_loop.h"
|
#include "base/run_loop.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
@ -76,7 +75,7 @@ std::string Clipboard::Read(const std::string& format_string) {
|
||||||
clipboard->ExtractCustomPlatformNames(ui::ClipboardBuffer::kCopyPaste,
|
clipboard->ExtractCustomPlatformNames(ui::ClipboardBuffer::kCopyPaste,
|
||||||
/* data_dst = */ nullptr);
|
/* data_dst = */ nullptr);
|
||||||
#if BUILDFLAG(IS_LINUX)
|
#if BUILDFLAG(IS_LINUX)
|
||||||
if (!base::Contains(custom_format_names, format_string)) {
|
if (!custom_format_names.contains(format_string)) {
|
||||||
custom_format_names =
|
custom_format_names =
|
||||||
clipboard->ExtractCustomPlatformNames(ui::ClipboardBuffer::kSelection,
|
clipboard->ExtractCustomPlatformNames(ui::ClipboardBuffer::kSelection,
|
||||||
/* data_dst = */ nullptr);
|
/* data_dst = */ nullptr);
|
||||||
|
@ -84,7 +83,7 @@ std::string Clipboard::Read(const std::string& format_string) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ui::ClipboardFormatType format;
|
ui::ClipboardFormatType format;
|
||||||
if (base::Contains(custom_format_names, format_string)) {
|
if (custom_format_names.contains(format_string)) {
|
||||||
format =
|
format =
|
||||||
ui::ClipboardFormatType(ui::ClipboardFormatType::CustomPlatformType(
|
ui::ClipboardFormatType(ui::ClipboardFormatType::CustomPlatformType(
|
||||||
custom_format_names[format_string]));
|
custom_format_names[format_string]));
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/feature_list.h"
|
#include "base/feature_list.h"
|
||||||
#include "base/json/json_writer.h"
|
#include "base/json/json_writer.h"
|
||||||
#include "base/trace_event/trace_event.h"
|
#include "base/trace_event/trace_event.h"
|
||||||
|
@ -69,7 +68,7 @@ bool DeepFreeze(const v8::Local<v8::Object>& object,
|
||||||
const v8::Local<v8::Context>& context,
|
const v8::Local<v8::Context>& context,
|
||||||
std::set<int> frozen = std::set<int>()) {
|
std::set<int> frozen = std::set<int>()) {
|
||||||
int hash = object->GetIdentityHash();
|
int hash = object->GetIdentityHash();
|
||||||
if (base::Contains(frozen, hash))
|
if (frozen.contains(hash))
|
||||||
return true;
|
return true;
|
||||||
frozen.insert(hash);
|
frozen.insert(hash);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/numerics/safe_conversions.h"
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "base/strings/utf_string_conversion_utils.h"
|
#include "base/strings/utf_string_conversion_utils.h"
|
||||||
|
@ -190,13 +189,13 @@ void SpellCheckClient::OnSpellCheckDone(
|
||||||
auto& word_list = pending_request_param_->wordlist();
|
auto& word_list = pending_request_param_->wordlist();
|
||||||
|
|
||||||
for (const auto& word : word_list) {
|
for (const auto& word : word_list) {
|
||||||
if (base::Contains(misspelled, word.text)) {
|
if (misspelled.contains(word.text)) {
|
||||||
// If this is a contraction, iterate through parts and accept the word
|
// If this is a contraction, iterate through parts and accept the word
|
||||||
// if none of them are misspelled
|
// if none of them are misspelled
|
||||||
if (!word.contraction_words.empty()) {
|
if (!word.contraction_words.empty()) {
|
||||||
auto all_correct = true;
|
auto all_correct = true;
|
||||||
for (const auto& contraction_word : word.contraction_words) {
|
for (const auto& contraction_word : word.contraction_words) {
|
||||||
if (base::Contains(misspelled, contraction_word)) {
|
if (misspelled.contains(contraction_word)) {
|
||||||
all_correct = false;
|
all_correct = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ void ElectronRendererClient::WillDestroyWorkerContextOnWorkerThread(
|
||||||
|
|
||||||
node::Environment* ElectronRendererClient::GetEnvironment(
|
node::Environment* ElectronRendererClient::GetEnvironment(
|
||||||
content::RenderFrame* render_frame) const {
|
content::RenderFrame* render_frame) const {
|
||||||
if (!base::Contains(injected_frames_, render_frame))
|
if (!injected_frames_.contains(render_frame))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
||||||
auto context =
|
auto context =
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "base/base_paths.h"
|
#include "base/base_paths.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/containers/contains.h"
|
|
||||||
#include "base/process/process_metrics.h"
|
#include "base/process/process_metrics.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "shell/common/api/electron_bindings.h"
|
#include "shell/common/api/electron_bindings.h"
|
||||||
|
@ -158,7 +157,7 @@ void ElectronSandboxedRendererClient::WillReleaseScriptContext(
|
||||||
void ElectronSandboxedRendererClient::EmitProcessEvent(
|
void ElectronSandboxedRendererClient::EmitProcessEvent(
|
||||||
content::RenderFrame* render_frame,
|
content::RenderFrame* render_frame,
|
||||||
const char* event_name) {
|
const char* event_name) {
|
||||||
if (!base::Contains(injected_frames_, render_frame))
|
if (!injected_frames_.contains(render_frame))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blink::WebLocalFrame* frame = render_frame->GetWebFrame();
|
blink::WebLocalFrame* frame = render_frame->GetWebFrame();
|
||||||
|
|
Loading…
Add table
Reference in a new issue