diff --git a/libcef/browser/alloy/alloy_browser_context.cc b/libcef/browser/alloy/alloy_browser_context.cc index 9eb99ef4f..c0a025713 100644 --- a/libcef/browser/alloy/alloy_browser_context.cc +++ b/libcef/browser/alloy/alloy_browser_context.cc @@ -5,6 +5,7 @@ #include "libcef/browser/alloy/alloy_browser_context.h" #include +#include #include #include "libcef/browser/download_manager_delegate.h" @@ -167,15 +168,15 @@ void AlloyBrowserContext::Initialize() { visited_link_path = cache_path_.Append(FILE_PATH_LITERAL("Visited Links")); } visitedlink_listener_ = new CefVisitedLinkListener; - visitedlink_master_.reset(new visitedlink::VisitedLinkWriter( + visitedlink_master_ = std::make_unique( visitedlink_listener_, this, !visited_link_path.empty(), false, - visited_link_path, 0)); + visited_link_path, 0); visitedlink_listener_->CreateListenerForContext(this); visitedlink_master_->Init(); // Initialize proxy configuration tracker. - pref_proxy_config_tracker_.reset(new PrefProxyConfigTrackerImpl( - GetPrefs(), content::GetIOThreadTaskRunner({}))); + pref_proxy_config_tracker_ = std::make_unique( + GetPrefs(), content::GetIOThreadTaskRunner({})); // Spell checking support and possibly other subsystems retrieve the // PrefService associated with a BrowserContext via UserPrefs::Get(). @@ -355,8 +356,8 @@ AlloyBrowserContext::CreateZoomLevelDelegate( content::DownloadManagerDelegate* AlloyBrowserContext::GetDownloadManagerDelegate() { if (!download_manager_delegate_) { - download_manager_delegate_.reset( - new CefDownloadManagerDelegate(GetDownloadManager())); + download_manager_delegate_ = + std::make_unique(GetDownloadManager()); } return download_manager_delegate_.get(); } @@ -388,7 +389,7 @@ AlloyBrowserContext::GetStorageNotificationService() { content::SSLHostStateDelegate* AlloyBrowserContext::GetSSLHostStateDelegate() { if (!ssl_host_state_delegate_) { - ssl_host_state_delegate_.reset(new CefSSLHostStateDelegate()); + ssl_host_state_delegate_ = std::make_unique(); } return ssl_host_state_delegate_.get(); } @@ -475,7 +476,7 @@ void AlloyBrowserContext::RebuildTable( DownloadPrefs* AlloyBrowserContext::GetDownloadPrefs() { CEF_REQUIRE_UIT(); if (!download_prefs_) { - download_prefs_.reset(new DownloadPrefs(this)); + download_prefs_ = std::make_unique(this); } return download_prefs_.get(); } diff --git a/libcef/browser/alloy/alloy_browser_host_impl.cc b/libcef/browser/alloy/alloy_browser_host_impl.cc index a6d2195c7..77427f543 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.cc +++ b/libcef/browser/alloy/alloy_browser_host_impl.cc @@ -5,6 +5,7 @@ #include "libcef/browser/alloy/alloy_browser_host_impl.h" +#include #include #include @@ -233,7 +234,7 @@ CefRefPtr AlloyBrowserHostImpl::GetBrowserForGlobalId( // AlloyBrowserHostImpl methods. // ----------------------------------------------------------------------------- -AlloyBrowserHostImpl::~AlloyBrowserHostImpl() {} +AlloyBrowserHostImpl::~AlloyBrowserHostImpl() = default; void AlloyBrowserHostImpl::CloseBrowser(bool force_close) { if (CEF_CURRENTLY_ON_UIT()) { @@ -1206,13 +1207,14 @@ void AlloyBrowserHostImpl::WebContentsCreated( CefRefPtr browser = CreateInternal(settings, client, new_contents, /*own_web_contents=*/false, info, opener, /*is_devtools_popup=*/false, request_context, - std::move(platform_delegate), /*cef_extension=*/nullptr); + std::move(platform_delegate), /*extension=*/nullptr); } content::JavaScriptDialogManager* AlloyBrowserHostImpl::GetJavaScriptDialogManager(content::WebContents* source) { if (!javascript_dialog_manager_) { - javascript_dialog_manager_.reset(new CefJavaScriptDialogManager(this)); + javascript_dialog_manager_ = + std::make_unique(this); } return javascript_dialog_manager_.get(); } @@ -1230,8 +1232,8 @@ bool AlloyBrowserHostImpl::ShowContextMenu( const content::ContextMenuParams& params) { CEF_REQUIRE_UIT(); if (!menu_manager_.get() && platform_delegate_) { - menu_manager_.reset( - new CefMenuManager(this, platform_delegate_->CreateMenuRunner())); + menu_manager_ = std::make_unique( + this, platform_delegate_->CreateMenuRunner()); } return menu_manager_->CreateContextMenu(params); } @@ -1402,7 +1404,8 @@ void AlloyBrowserHostImpl::StartAudioCapturer() { return; } - audio_capturer_.reset(new CefAudioCapturer(params, this, audio_handler)); + audio_capturer_ = + std::make_unique(params, this, audio_handler); } // AlloyBrowserHostImpl private methods. diff --git a/libcef/browser/alloy/alloy_browser_main.cc b/libcef/browser/alloy/alloy_browser_main.cc index 71e4e44ae..4ea948ada 100644 --- a/libcef/browser/alloy/alloy_browser_main.cc +++ b/libcef/browser/alloy/alloy_browser_main.cc @@ -6,6 +6,7 @@ #include +#include #include #include "libcef/browser/alloy/dialogs/alloy_constrained_window_views_client.h" @@ -206,7 +207,7 @@ void AlloyBrowserMainParts::ToolkitInitialized() { #if defined(USE_AURA) CHECK(aura::Env::GetInstance()); - wm_state_.reset(new wm::WMState); + wm_state_ = std::make_unique(); #endif // defined(USE_AURA) #if BUILDFLAG(IS_MAC) diff --git a/libcef/browser/alloy/alloy_content_browser_client.cc b/libcef/browser/alloy/alloy_content_browser_client.cc index aed6538e9..0a7778d0c 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.cc +++ b/libcef/browser/alloy/alloy_content_browser_client.cc @@ -196,7 +196,7 @@ class CefSelectClientCertificateCallbackImpl CefSelectClientCertificateCallbackImpl& operator=( const CefSelectClientCertificateCallbackImpl&) = delete; - ~CefSelectClientCertificateCallbackImpl() { + ~CefSelectClientCertificateCallbackImpl() override { // If Select has not been called, call it with NULL to continue without any // client certificate. if (delegate_) { @@ -792,9 +792,8 @@ base::OnceClosure AlloyContentBrowserClient::SelectClientCertificate( } CefRequestHandler::X509CertificateList certs; - for (net::ClientCertIdentityList::iterator iter = client_certs.begin(); - iter != client_certs.end(); iter++) { - certs.push_back(new CefX509CertificateImpl(std::move(*iter))); + for (auto& client_cert : client_certs) { + certs.push_back(new CefX509CertificateImpl(std::move(client_cert))); } CefRefPtr callbackImpl( diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/libcef/browser/alloy/browser_platform_delegate_alloy.cc index 6d6de7ec6..012d0da07 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.cc +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.cc @@ -4,6 +4,8 @@ #include "libcef/browser/alloy/browser_platform_delegate_alloy.h" +#include + #include "libcef/browser/alloy/alloy_browser_host_impl.h" #include "libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h" #include "libcef/browser/extensions/browser_extensions_util.h" @@ -173,8 +175,8 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated( CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop(web_contents_)); // Used for print preview and JavaScript dialogs. - web_contents_dialog_helper_.reset( - new AlloyWebContentsDialogHelper(web_contents_, this)); + web_contents_dialog_helper_ = + std::make_unique(web_contents_, this); } void CefBrowserPlatformDelegateAlloy::CreateExtensionHost( diff --git a/libcef/browser/alloy/chrome_browser_process_alloy.cc b/libcef/browser/alloy/chrome_browser_process_alloy.cc index f69a9b4ca..f40cb2375 100644 --- a/libcef/browser/alloy/chrome_browser_process_alloy.cc +++ b/libcef/browser/alloy/chrome_browser_process_alloy.cc @@ -5,6 +5,8 @@ #include "libcef/browser/alloy/chrome_browser_process_alloy.h" +#include + #include "libcef/browser/alloy/chrome_profile_manager_alloy.h" #include "libcef/browser/browser_context.h" #include "libcef/browser/context.h" @@ -37,11 +39,7 @@ #include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -ChromeBrowserProcessAlloy::ChromeBrowserProcessAlloy() - : initialized_(false), - context_initialized_(false), - shutdown_(false), - locale_("en-US") {} +ChromeBrowserProcessAlloy::ChromeBrowserProcessAlloy() : locale_("en-US") {} ChromeBrowserProcessAlloy::~ChromeBrowserProcessAlloy() { DCHECK((!initialized_ && !context_initialized_) || shutdown_); @@ -64,10 +62,10 @@ void ChromeBrowserProcessAlloy::Initialize() { if (extensions::ExtensionsEnabled()) { // Initialize extension global objects before creating the global // BrowserContext. - extensions_client_.reset(new extensions::CefExtensionsClient()); + extensions_client_ = std::make_unique(); extensions::ExtensionsClient::Set(extensions_client_.get()); - extensions_browser_client_.reset( - new extensions::CefExtensionsBrowserClient); + extensions_browser_client_ = + std::make_unique(); extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); } @@ -84,8 +82,8 @@ void ChromeBrowserProcessAlloy::OnContextInitialized() { DCHECK(!shutdown_); // Must be created after the NotificationService. - print_job_manager_.reset(new printing::PrintJobManager()); - profile_manager_.reset(new ChromeProfileManagerAlloy()); + print_job_manager_ = std::make_unique(); + profile_manager_ = std::make_unique(); event_router_forwarder_ = new extensions::EventRouterForwarder(); context_initialized_ = true; } @@ -282,8 +280,8 @@ ChromeBrowserProcessAlloy::print_preview_dialog_controller() { printing::BackgroundPrintingManager* ChromeBrowserProcessAlloy::background_printing_manager() { if (!background_printing_manager_.get()) { - background_printing_manager_.reset( - new printing::BackgroundPrintingManager()); + background_printing_manager_ = + std::make_unique(); } return background_printing_manager_.get(); } diff --git a/libcef/browser/alloy/chrome_browser_process_alloy.h b/libcef/browser/alloy/chrome_browser_process_alloy.h index ab2d69440..e442bb045 100644 --- a/libcef/browser/alloy/chrome_browser_process_alloy.h +++ b/libcef/browser/alloy/chrome_browser_process_alloy.h @@ -113,9 +113,9 @@ class ChromeBrowserProcessAlloy : public BrowserProcess { UsbSystemTrayIcon* usb_system_tray_icon() override; private: - bool initialized_; - bool context_initialized_; - bool shutdown_; + bool initialized_ = false; + bool context_initialized_ = false; + bool shutdown_ = false; std::unique_ptr extensions_client_; std::unique_ptr diff --git a/libcef/browser/alloy/chrome_profile_alloy.cc b/libcef/browser/alloy/chrome_profile_alloy.cc index 5615c5627..0886505d2 100644 --- a/libcef/browser/alloy/chrome_profile_alloy.cc +++ b/libcef/browser/alloy/chrome_profile_alloy.cc @@ -41,7 +41,7 @@ ChromeProfileAlloy::ChromeProfileAlloy() { this, profile_metrics::BrowserProfileType::kRegular); } -ChromeProfileAlloy::~ChromeProfileAlloy() {} +ChromeProfileAlloy::~ChromeProfileAlloy() = default; bool ChromeProfileAlloy::IsOffTheRecord() { return false; diff --git a/libcef/browser/alloy/chrome_profile_manager_alloy.cc b/libcef/browser/alloy/chrome_profile_manager_alloy.cc index 8a577f5c5..7225c8260 100644 --- a/libcef/browser/alloy/chrome_profile_manager_alloy.cc +++ b/libcef/browser/alloy/chrome_profile_manager_alloy.cc @@ -32,7 +32,7 @@ CefBrowserContext* GetActiveBrowserContext() { ChromeProfileManagerAlloy::ChromeProfileManagerAlloy() : ProfileManager(base::FilePath()) {} -ChromeProfileManagerAlloy::~ChromeProfileManagerAlloy() {} +ChromeProfileManagerAlloy::~ChromeProfileManagerAlloy() = default; Profile* ChromeProfileManagerAlloy::GetProfile( const base::FilePath& profile_dir) { diff --git a/libcef/browser/audio_loopback_stream_creator.cc b/libcef/browser/audio_loopback_stream_creator.cc index 48aea22dd..7ad284d69 100644 --- a/libcef/browser/audio_loopback_stream_creator.cc +++ b/libcef/browser/audio_loopback_stream_creator.cc @@ -39,7 +39,7 @@ class StreamCreatedCallbackAdapter final StreamCreatedCallbackAdapter& operator=(const StreamCreatedCallbackAdapter&) = delete; - ~StreamCreatedCallbackAdapter() override {} + ~StreamCreatedCallbackAdapter() override = default; // blink::mojom::RendererAudioInputStreamFactoryClient implementation. void StreamCreated( diff --git a/libcef/browser/browser_contents_delegate.h b/libcef/browser/browser_contents_delegate.h index 4e1a051a8..d222af272 100644 --- a/libcef/browser/browser_contents_delegate.h +++ b/libcef/browser/browser_contents_delegate.h @@ -63,7 +63,7 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate, virtual void OnWebContentsDestroyed(content::WebContents* web_contents) = 0; protected: - ~Observer() override {} + ~Observer() override = default; }; explicit CefBrowserContentsDelegate( diff --git a/libcef/browser/browser_context.cc b/libcef/browser/browser_context.cc index eddb623c2..58b2cd23b 100644 --- a/libcef/browser/browser_context.cc +++ b/libcef/browser/browser_context.cc @@ -5,6 +5,7 @@ #include "libcef/browser/browser_context.h" #include +#include #include #include "libcef/browser/context.h" @@ -36,7 +37,7 @@ class ImplManager { public: using Vector = std::vector; - ImplManager() {} + ImplManager() = default; ImplManager(const ImplManager&) = delete; ImplManager& operator=(const ImplManager&) = delete; @@ -423,7 +424,8 @@ network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() { CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() { CEF_REQUIRE_UIT(); if (!media_router_manager_) { - media_router_manager_.reset(new CefMediaRouterManager(AsBrowserContext())); + media_router_manager_ = + std::make_unique(AsBrowserContext()); } return media_router_manager_.get(); } diff --git a/libcef/browser/browser_host_base.cc b/libcef/browser/browser_host_base.cc index 3f310c4d1..7bb40109b 100644 --- a/libcef/browser/browser_host_base.cc +++ b/libcef/browser/browser_host_base.cc @@ -61,7 +61,7 @@ class WebContentsUserDataAdapter : public base::SupportsUserData::Data { } private: - WebContentsUserDataAdapter(CefRefPtr browser) + explicit WebContentsUserDataAdapter(CefRefPtr browser) : browser_(browser) { auto web_contents = browser->GetWebContents(); DCHECK(web_contents); diff --git a/libcef/browser/browser_host_base.h b/libcef/browser/browser_host_base.h index f1724c5d0..9ec11dfb4 100644 --- a/libcef/browser/browser_host_base.h +++ b/libcef/browser/browser_host_base.h @@ -28,7 +28,7 @@ class Extension; // Parameters that are passed to the runtime-specific Create methods. struct CefBrowserCreateParams { - CefBrowserCreateParams() {} + CefBrowserCreateParams() = default; // Copy constructor used with the chrome runtime only. CefBrowserCreateParams(const CefBrowserCreateParams& that) { @@ -127,7 +127,7 @@ class CefBrowserHostBase : public CefBrowserHost, virtual void OnBrowserDestroyed(CefBrowserHostBase* browser) = 0; protected: - virtual ~Observer() {} + ~Observer() override = default; }; // Create a new CefBrowserHost instance of the current runtime type with diff --git a/libcef/browser/browser_info.cc b/libcef/browser/browser_info.cc index d77d3f2a4..d0d65097f 100644 --- a/libcef/browser/browser_info.cc +++ b/libcef/browser/browser_info.cc @@ -4,6 +4,8 @@ #include "libcef/browser/browser_info.h" +#include + #include "libcef/browser/browser_host_base.h" #include "libcef/browser/thread_util.h" #include "libcef/common/frame_util.h" @@ -542,7 +544,8 @@ CefBrowserInfo::NotificationStateLock::NotificationStateLock( } // Take the browser info state lock. - browser_info_lock_scope_.reset(new base::AutoLock(browser_info_->lock_)); + browser_info_lock_scope_ = + std::make_unique(browser_info_->lock_); } CefBrowserInfo::NotificationStateLock::~NotificationStateLock() { diff --git a/libcef/browser/certificate_query.cc b/libcef/browser/certificate_query.cc index ca7879842..e5af82c49 100644 --- a/libcef/browser/certificate_query.cc +++ b/libcef/browser/certificate_query.cc @@ -32,7 +32,7 @@ class CefAllowCertificateErrorCallbackImpl : public CefCallback { CefAllowCertificateErrorCallbackImpl& operator=( const CefAllowCertificateErrorCallbackImpl&) = delete; - ~CefAllowCertificateErrorCallbackImpl() { + ~CefAllowCertificateErrorCallbackImpl() override { if (!callback_.is_null()) { // The callback is still pending. Cancel it now. if (CEF_CURRENTLY_ON_UIT()) { diff --git a/libcef/browser/chrome/browser_delegate.h b/libcef/browser/chrome/browser_delegate.h index 92a0c0bb4..8202a0206 100644 --- a/libcef/browser/chrome/browser_delegate.h +++ b/libcef/browser/chrome/browser_delegate.h @@ -30,7 +30,7 @@ class BrowserDelegate : public content::WebContentsDelegate { // instances. class CreateParams : public base::RefCounted { public: - virtual ~CreateParams() {} + virtual ~CreateParams() = default; }; // Called from the Browser constructor to create a new delegate. @@ -39,7 +39,7 @@ class BrowserDelegate : public content::WebContentsDelegate { scoped_refptr cef_params, const Browser* opener); - ~BrowserDelegate() override {} + ~BrowserDelegate() override = default; // Optionally override Browser creation in // DevToolsWindow::CreateDevToolsBrowser. The returned Browser, if any, will diff --git a/libcef/browser/chrome/chrome_browser_context.cc b/libcef/browser/chrome/chrome_browser_context.cc index c35b733ef..3eb9e005d 100644 --- a/libcef/browser/chrome/chrome_browser_context.cc +++ b/libcef/browser/chrome/chrome_browser_context.cc @@ -4,6 +4,8 @@ #include "libcef/browser/chrome/chrome_browser_context.h" +#include + #include "libcef/browser/prefs/browser_prefs.h" #include "libcef/browser/thread_util.h" @@ -144,8 +146,8 @@ void ChromeBrowserContext::ProfileCreated(Profile::CreateStatus status, // exists. profile_ = profile; profile_->AddObserver(this); - profile_keep_alive_.reset(new ScopedProfileKeepAlive( - profile_, ProfileKeepAliveOrigin::kAppWindow)); + profile_keep_alive_ = std::make_unique( + profile_, ProfileKeepAliveOrigin::kAppWindow); } if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) { diff --git a/libcef/browser/chrome/chrome_browser_host_impl.h b/libcef/browser/chrome/chrome_browser_host_impl.h index fb162fa1a..8ffd89a17 100644 --- a/libcef/browser/chrome/chrome_browser_host_impl.h +++ b/libcef/browser/chrome/chrome_browser_host_impl.h @@ -27,7 +27,7 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase { // possibly shared by multiple Browser instances. class DelegateCreateParams : public cef::BrowserDelegate::CreateParams { public: - DelegateCreateParams(const CefBrowserCreateParams& create_params) + explicit DelegateCreateParams(const CefBrowserCreateParams& create_params) : create_params_(create_params) {} CefBrowserCreateParams create_params_; diff --git a/libcef/browser/chrome/chrome_context_menu_handler.cc b/libcef/browser/chrome/chrome_context_menu_handler.cc index 95fa54033..1a0a10f20 100644 --- a/libcef/browser/chrome/chrome_context_menu_handler.cc +++ b/libcef/browser/chrome/chrome_context_menu_handler.cc @@ -132,7 +132,7 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver, private: struct ItemInfo { - ItemInfo() {} + ItemInfo() = default; bool checked = false; absl::optional accel; diff --git a/libcef/browser/chrome/views/chrome_browser_frame.h b/libcef/browser/chrome/views/chrome_browser_frame.h index ffd823e22..fb44932d6 100644 --- a/libcef/browser/chrome/views/chrome_browser_frame.h +++ b/libcef/browser/chrome/views/chrome_browser_frame.h @@ -91,7 +91,7 @@ class BrowserView; // CefWindowView::CreateWidget() when the Chrome runtime is enabled. class ChromeBrowserFrame : public BrowserFrame { public: - ChromeBrowserFrame() {} + ChromeBrowserFrame() = default; ChromeBrowserFrame(const ChromeBrowserFrame&) = delete; ChromeBrowserFrame& operator=(const ChromeBrowserFrame&) = delete; diff --git a/libcef/browser/context.cc b/libcef/browser/context.cc index f012872de..a20b70269 100644 --- a/libcef/browser/context.cc +++ b/libcef/browser/context.cc @@ -4,6 +4,8 @@ #include "libcef/browser/context.h" +#include + #include "libcef/browser/browser_info_manager.h" #include "libcef/browser/request_context_impl.h" #include "libcef/browser/thread_util.h" @@ -426,10 +428,9 @@ void CefSetOSModalLoop(bool osModalLoop) { // CefContext -CefContext::CefContext() - : initialized_(false), shutting_down_(false), init_thread_id_(0) {} +CefContext::CefContext() = default; -CefContext::~CefContext() {} +CefContext::~CefContext() = default; // static CefContext* CefContext::Get() { @@ -472,10 +473,10 @@ bool CefContext::Initialize(const CefMainArgs& args, NormalizePathAndSet(settings_.resources_dir_path, "resources_dir_path"); NormalizePathAndSet(settings_.locales_dir_path, "locales_dir_path"); - browser_info_manager_.reset(new CefBrowserInfoManager); + browser_info_manager_ = std::make_unique(); - main_runner_.reset(new CefMainRunner(settings_.multi_threaded_message_loop, - settings_.external_message_pump)); + main_runner_ = std::make_unique( + settings_.multi_threaded_message_loop, settings_.external_message_pump); if (!main_runner_->Initialize( &settings_, application, args, windows_sandbox_info, &initialized_, base::BindOnce(&CefContext::OnContextInitialized, @@ -543,7 +544,7 @@ CefTraceSubscriber* CefContext::GetTraceSubscriber() { return nullptr; } if (!trace_subscriber_.get()) { - trace_subscriber_.reset(new CefTraceSubscriber()); + trace_subscriber_ = std::make_unique(); } return trace_subscriber_.get(); } diff --git a/libcef/browser/context.h b/libcef/browser/context.h index 40530c016..fc06e28ae 100644 --- a/libcef/browser/context.h +++ b/libcef/browser/context.h @@ -30,7 +30,7 @@ class CefContext { virtual void OnContextDestroyed() = 0; protected: - virtual ~Observer() {} + virtual ~Observer() = default; }; CefContext(); @@ -98,11 +98,11 @@ class CefContext { void FinalizeShutdown(); // Track context state. - bool initialized_; - bool shutting_down_; + bool initialized_ = false; + bool shutting_down_ = false; // The thread on which the context was initialized. - base::PlatformThreadId init_thread_id_; + base::PlatformThreadId init_thread_id_ = 0; CefSettings settings_; CefRefPtr application_; diff --git a/libcef/browser/devtools/devtools_controller.h b/libcef/browser/devtools/devtools_controller.h index 3bed09ff0..52790d676 100644 --- a/libcef/browser/devtools/devtools_controller.h +++ b/libcef/browser/devtools/devtools_controller.h @@ -36,7 +36,7 @@ class CefDevToolsController : public content::DevToolsAgentHostClient { virtual void OnDevToolsControllerDestroyed() = 0; protected: - ~Observer() override {} + ~Observer() override = default; }; // |inspected_contents| will outlive this object. diff --git a/libcef/browser/devtools/devtools_frontend.cc b/libcef/browser/devtools/devtools_frontend.cc index 008cc59a1..0fd3d88bf 100644 --- a/libcef/browser/devtools/devtools_frontend.cc +++ b/libcef/browser/devtools/devtools_frontend.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include "libcef/browser/browser_context.h" @@ -256,7 +257,7 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show( if (inspected_browser->is_views_hosted()) { create_params.popup_with_views_hosted_opener = true; } else { - create_params.window_info.reset(new CefWindowInfo(windowInfo)); + create_params.window_info = std::make_unique(windowInfo); } create_params.client = client; create_params.settings = new_settings; @@ -322,7 +323,7 @@ CefDevToolsFrontend::CefDevToolsFrontend( DCHECK(!frontend_destroyed_callback_.is_null()); } -CefDevToolsFrontend::~CefDevToolsFrontend() {} +CefDevToolsFrontend::~CefDevToolsFrontend() = default; void CefDevToolsFrontend::ReadyToCommitNavigation( content::NavigationHandle* navigation_handle) { diff --git a/libcef/browser/devtools/devtools_manager.cc b/libcef/browser/devtools/devtools_manager.cc index 170f60956..8927dab4d 100644 --- a/libcef/browser/devtools/devtools_manager.cc +++ b/libcef/browser/devtools/devtools_manager.cc @@ -4,6 +4,8 @@ #include "libcef/browser/devtools/devtools_manager.h" +#include + #include "libcef/browser/devtools/devtools_controller.h" #include "libcef/browser/devtools/devtools_frontend.h" #include "libcef/features/runtime.h" @@ -209,8 +211,8 @@ void CefDevToolsManager::OnFrontEndDestroyed() { bool CefDevToolsManager::EnsureController() { if (!devtools_controller_) { - devtools_controller_.reset(new CefDevToolsController( - inspected_browser_->contents_delegate()->web_contents())); + devtools_controller_ = std::make_unique( + inspected_browser_->contents_delegate()->web_contents()); } return true; } diff --git a/libcef/browser/devtools/devtools_manager_delegate.cc b/libcef/browser/devtools/devtools_manager_delegate.cc index 86230794f..9e6de98c7 100644 --- a/libcef/browser/devtools/devtools_manager_delegate.cc +++ b/libcef/browser/devtools/devtools_manager_delegate.cc @@ -123,9 +123,9 @@ void CefDevToolsManagerDelegate::StopHttpHandler() { content::DevToolsAgentHost::StopRemoteDebuggingServer(); } -CefDevToolsManagerDelegate::CefDevToolsManagerDelegate() {} +CefDevToolsManagerDelegate::CefDevToolsManagerDelegate() = default; -CefDevToolsManagerDelegate::~CefDevToolsManagerDelegate() {} +CefDevToolsManagerDelegate::~CefDevToolsManagerDelegate() = default; scoped_refptr CefDevToolsManagerDelegate::CreateNewTarget( diff --git a/libcef/browser/extensions/alloy_extensions_util.cc b/libcef/browser/extensions/alloy_extensions_util.cc index a802ab1b1..68a718f4d 100644 --- a/libcef/browser/extensions/alloy_extensions_util.cc +++ b/libcef/browser/extensions/alloy_extensions_util.cc @@ -6,8 +6,7 @@ #include "libcef/browser/alloy/alloy_browser_host_impl.h" -namespace extensions { -namespace alloy { +namespace extensions::alloy { int GetTabIdForWebContents(content::WebContents* web_contents) { auto browser = AlloyBrowserHostImpl::GetBrowserForContents(web_contents); @@ -17,5 +16,4 @@ int GetTabIdForWebContents(content::WebContents* web_contents) { return browser->GetIdentifier(); } -} // namespace alloy -} // namespace extensions +} // namespace extensions::alloy diff --git a/libcef/browser/extensions/alloy_extensions_util.h b/libcef/browser/extensions/alloy_extensions_util.h index e68c0c2e1..e401f7bf9 100644 --- a/libcef/browser/extensions/alloy_extensions_util.h +++ b/libcef/browser/extensions/alloy_extensions_util.h @@ -9,13 +9,11 @@ namespace content { class WebContents; } -namespace extensions { -namespace alloy { +namespace extensions::alloy { // Returns the tabId for |web_contents|, or -1 if not found. int GetTabIdForWebContents(content::WebContents* web_contents); -} // namespace alloy -} // namespace extensions +} // namespace extensions::alloy #endif // CEF_LIBCEF_BROWSER_EXTENSIONS_ALLOY_EXTENSIONS_UTIL_H_ diff --git a/libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc b/libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc index abe577b97..25b858c26 100644 --- a/libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc +++ b/libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc @@ -1,89 +1,87 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "libcef/browser/extensions/api/file_system/cef_file_system_delegate.h" - -#include "apps/saved_files_service.h" -#include "base/files/file_path.h" -#include "base/functional/callback.h" -#include "chrome/browser/extensions/api/file_system/file_entry_picker.h" -#include "chrome/grit/generated_resources.h" -#include "content/public/browser/web_contents.h" -#include "extensions/common/api/file_system.h" -#include "extensions/common/extension.h" - -namespace extensions { -namespace cef { - -CefFileSystemDelegate::CefFileSystemDelegate() = default; - -CefFileSystemDelegate::~CefFileSystemDelegate() = default; - -base::FilePath CefFileSystemDelegate::GetDefaultDirectory() { - return base::FilePath(); -} - -base::FilePath CefFileSystemDelegate::GetManagedSaveAsDirectory( - content::BrowserContext* browser_context, - const Extension& extension) { - return base::FilePath(); -} - -bool CefFileSystemDelegate::ShowSelectFileDialog( - scoped_refptr extension_function, - ui::SelectFileDialog::Type type, - const base::FilePath& default_path, - const ui::SelectFileDialog::FileTypeInfo* file_types, - FileSystemDelegate::FilesSelectedCallback files_selected_callback, - base::OnceClosure file_selection_canceled_callback) { - auto web_contents = extension_function->GetSenderWebContents(); - if (!web_contents) { - return false; - } - - // The file picker will hold a reference to the ExtensionFunction - // instance, preventing its destruction (and subsequent sending of the - // function response) until the user has selected a file or cancelled the - // picker. At that point, the picker will delete itself, which will also free - // the function instance. - new FileEntryPicker(web_contents, default_path, *file_types, type, - std::move(files_selected_callback), - std::move(file_selection_canceled_callback)); - return true; -} - -void CefFileSystemDelegate::ConfirmSensitiveDirectoryAccess( - bool has_write_permission, - const std::u16string& app_name, - content::WebContents* web_contents, - base::OnceClosure on_accept, - base::OnceClosure on_cancel) { - NOTIMPLEMENTED(); - - // Run the cancel callback by default. - std::move(on_cancel).Run(); -} - -// Based on ChromeFileSystemDelegate::GetDescriptionIdForAcceptType. -int CefFileSystemDelegate::GetDescriptionIdForAcceptType( - const std::string& accept_type) { - if (accept_type == "image/*") { - return IDS_IMAGE_FILES; - } - if (accept_type == "audio/*") { - return IDS_AUDIO_FILES; - } - if (accept_type == "video/*") { - return IDS_VIDEO_FILES; - } - return 0; -} - -SavedFilesServiceInterface* CefFileSystemDelegate::GetSavedFilesService( - content::BrowserContext* browser_context) { - return apps::SavedFilesService::Get(browser_context); -} - -} // namespace cef -} // namespace extensions +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/extensions/api/file_system/cef_file_system_delegate.h" + +#include "apps/saved_files_service.h" +#include "base/files/file_path.h" +#include "base/functional/callback.h" +#include "chrome/browser/extensions/api/file_system/file_entry_picker.h" +#include "chrome/grit/generated_resources.h" +#include "content/public/browser/web_contents.h" +#include "extensions/common/api/file_system.h" +#include "extensions/common/extension.h" + +namespace extensions::cef { + +CefFileSystemDelegate::CefFileSystemDelegate() = default; + +CefFileSystemDelegate::~CefFileSystemDelegate() = default; + +base::FilePath CefFileSystemDelegate::GetDefaultDirectory() { + return base::FilePath(); +} + +base::FilePath CefFileSystemDelegate::GetManagedSaveAsDirectory( + content::BrowserContext* browser_context, + const Extension& extension) { + return base::FilePath(); +} + +bool CefFileSystemDelegate::ShowSelectFileDialog( + scoped_refptr extension_function, + ui::SelectFileDialog::Type type, + const base::FilePath& default_path, + const ui::SelectFileDialog::FileTypeInfo* file_types, + FileSystemDelegate::FilesSelectedCallback files_selected_callback, + base::OnceClosure file_selection_canceled_callback) { + auto web_contents = extension_function->GetSenderWebContents(); + if (!web_contents) { + return false; + } + + // The file picker will hold a reference to the ExtensionFunction + // instance, preventing its destruction (and subsequent sending of the + // function response) until the user has selected a file or cancelled the + // picker. At that point, the picker will delete itself, which will also free + // the function instance. + new FileEntryPicker(web_contents, default_path, *file_types, type, + std::move(files_selected_callback), + std::move(file_selection_canceled_callback)); + return true; +} + +void CefFileSystemDelegate::ConfirmSensitiveDirectoryAccess( + bool has_write_permission, + const std::u16string& app_name, + content::WebContents* web_contents, + base::OnceClosure on_accept, + base::OnceClosure on_cancel) { + NOTIMPLEMENTED(); + + // Run the cancel callback by default. + std::move(on_cancel).Run(); +} + +// Based on ChromeFileSystemDelegate::GetDescriptionIdForAcceptType. +int CefFileSystemDelegate::GetDescriptionIdForAcceptType( + const std::string& accept_type) { + if (accept_type == "image/*") { + return IDS_IMAGE_FILES; + } + if (accept_type == "audio/*") { + return IDS_AUDIO_FILES; + } + if (accept_type == "video/*") { + return IDS_VIDEO_FILES; + } + return 0; +} + +SavedFilesServiceInterface* CefFileSystemDelegate::GetSavedFilesService( + content::BrowserContext* browser_context) { + return apps::SavedFilesService::Get(browser_context); +} + +} // namespace extensions::cef diff --git a/libcef/browser/extensions/api/file_system/cef_file_system_delegate.h b/libcef/browser/extensions/api/file_system/cef_file_system_delegate.h index bfcb02031..7d84e5d7a 100644 --- a/libcef/browser/extensions/api/file_system/cef_file_system_delegate.h +++ b/libcef/browser/extensions/api/file_system/cef_file_system_delegate.h @@ -1,58 +1,56 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_ -#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_ - -#include - -#include "base/compiler_specific.h" -#include "base/functional/callback.h" -#include "base/memory/ref_counted.h" -#include "extensions/browser/api/execute_code_function.h" -#include "extensions/browser/api/file_system/file_system_delegate.h" -#include "extensions/browser/extension_function.h" - -namespace content { -class WebContents; -} - -namespace extensions { -namespace cef { - -class CefFileSystemDelegate : public FileSystemDelegate { - public: - CefFileSystemDelegate(); - - CefFileSystemDelegate(const CefFileSystemDelegate&) = delete; - CefFileSystemDelegate& operator=(const CefFileSystemDelegate&) = delete; - - ~CefFileSystemDelegate() override; - - // FileSystemDelegate - base::FilePath GetDefaultDirectory() override; - base::FilePath GetManagedSaveAsDirectory( - content::BrowserContext* browser_context, - const Extension& extension) override; - bool ShowSelectFileDialog( - scoped_refptr extension_function, - ui::SelectFileDialog::Type type, - const base::FilePath& default_path, - const ui::SelectFileDialog::FileTypeInfo* file_types, - FileSystemDelegate::FilesSelectedCallback files_selected_callback, - base::OnceClosure file_selection_canceled_callback) override; - void ConfirmSensitiveDirectoryAccess(bool has_write_permission, - const std::u16string& app_name, - content::WebContents* web_contents, - base::OnceClosure on_accept, - base::OnceClosure on_cancel) override; - int GetDescriptionIdForAcceptType(const std::string& accept_type) override; - SavedFilesServiceInterface* GetSavedFilesService( - content::BrowserContext* browser_context) override; -}; - -} // namespace cef -} // namespace extensions - -#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_ +#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_ + +#include + +#include "base/compiler_specific.h" +#include "base/functional/callback.h" +#include "base/memory/ref_counted.h" +#include "extensions/browser/api/execute_code_function.h" +#include "extensions/browser/api/file_system/file_system_delegate.h" +#include "extensions/browser/extension_function.h" + +namespace content { +class WebContents; +} + +namespace extensions::cef { + +class CefFileSystemDelegate : public FileSystemDelegate { + public: + CefFileSystemDelegate(); + + CefFileSystemDelegate(const CefFileSystemDelegate&) = delete; + CefFileSystemDelegate& operator=(const CefFileSystemDelegate&) = delete; + + ~CefFileSystemDelegate() override; + + // FileSystemDelegate + base::FilePath GetDefaultDirectory() override; + base::FilePath GetManagedSaveAsDirectory( + content::BrowserContext* browser_context, + const Extension& extension) override; + bool ShowSelectFileDialog( + scoped_refptr extension_function, + ui::SelectFileDialog::Type type, + const base::FilePath& default_path, + const ui::SelectFileDialog::FileTypeInfo* file_types, + FileSystemDelegate::FilesSelectedCallback files_selected_callback, + base::OnceClosure file_selection_canceled_callback) override; + void ConfirmSensitiveDirectoryAccess(bool has_write_permission, + const std::u16string& app_name, + content::WebContents* web_contents, + base::OnceClosure on_accept, + base::OnceClosure on_cancel) override; + int GetDescriptionIdForAcceptType(const std::string& accept_type) override; + SavedFilesServiceInterface* GetSavedFilesService( + content::BrowserContext* browser_context) override; +}; + +} // namespace extensions::cef + +#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_ diff --git a/libcef/browser/extensions/api/storage/sync_value_store_cache.cc b/libcef/browser/extensions/api/storage/sync_value_store_cache.cc index 5dff6f61b..a52df6ad2 100644 --- a/libcef/browser/extensions/api/storage/sync_value_store_cache.cc +++ b/libcef/browser/extensions/api/storage/sync_value_store_cache.cc @@ -21,9 +21,7 @@ using content::BrowserThread; -namespace extensions { - -namespace cef { +namespace extensions::cef { namespace { @@ -101,5 +99,4 @@ value_store::ValueStore* SyncValueStoreCache::GetStorage( storage_map_[extension->id()] = std::move(storage); return storage_ptr; } -} // namespace cef -} // namespace extensions +} // namespace extensions::cef diff --git a/libcef/browser/extensions/api/storage/sync_value_store_cache.h b/libcef/browser/extensions/api/storage/sync_value_store_cache.h index 626c182f2..6e9321f9f 100644 --- a/libcef/browser/extensions/api/storage/sync_value_store_cache.h +++ b/libcef/browser/extensions/api/storage/sync_value_store_cache.h @@ -16,8 +16,7 @@ namespace value_store { class ValueStoreFactory; } -namespace extensions { -namespace cef { +namespace extensions::cef { // Based on LocalValueStoreCache // ValueStoreCache for the SYNC namespace. It owns a backend for apps and @@ -54,7 +53,6 @@ class SyncValueStoreCache : public ValueStoreCache { StorageMap storage_map_; }; -} // namespace cef -} // namespace extensions +} // namespace extensions::cef #endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_STORAGE_SYNC_VALUE_STORE_CACHE_H_ diff --git a/libcef/browser/extensions/api/tabs/tabs_api.cc b/libcef/browser/extensions/api/tabs/tabs_api.cc index 33cf2aadd..f0ef42e51 100644 --- a/libcef/browser/extensions/api/tabs/tabs_api.cc +++ b/libcef/browser/extensions/api/tabs/tabs_api.cc @@ -25,8 +25,7 @@ using zoom::ZoomController; -namespace extensions { -namespace cef { +namespace extensions::cef { namespace keys = extensions::tabs_constants; namespace tabs = api::tabs; @@ -241,10 +240,9 @@ ExtensionFunction::ResponseValue TabsUpdateFunction::GetResult() { /*opener_browser_id=*/-1, /*active=*/true, tab_id_))); } -ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() - : cef_details_(this), execute_tab_id_(-1) {} +ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() : cef_details_(this) {} -ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {} +ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() = default; ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() { if (init_result_) { @@ -538,5 +536,4 @@ ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() { ArgumentList(tabs::GetZoomSettings::Results::Create(zoom_settings))); } -} // namespace cef -} // namespace extensions +} // namespace extensions::cef diff --git a/libcef/browser/extensions/api/tabs/tabs_api.h b/libcef/browser/extensions/api/tabs/tabs_api.h index 409d758db..d35b76e40 100644 --- a/libcef/browser/extensions/api/tabs/tabs_api.h +++ b/libcef/browser/extensions/api/tabs/tabs_api.h @@ -18,11 +18,10 @@ namespace content { class WebContents; } -namespace extensions { -namespace cef { +namespace extensions::cef { class TabsGetFunction : public ExtensionFunction { - ~TabsGetFunction() override {} + ~TabsGetFunction() override = default; ResponseAction Run() override; @@ -32,7 +31,7 @@ class TabsGetFunction : public ExtensionFunction { class TabsCreateFunction : public ExtensionFunction { public: TabsCreateFunction(); - ~TabsCreateFunction() override {} + ~TabsCreateFunction() override = default; ResponseAction Run() override; @@ -47,7 +46,7 @@ class BaseAPIFunction : public ExtensionFunction { BaseAPIFunction(); protected: - ~BaseAPIFunction() override {} + ~BaseAPIFunction() override = default; // Gets the WebContents for |tab_id| if it is specified. Otherwise get the // WebContents for the active tab in the current window. Calling this function @@ -60,7 +59,7 @@ class BaseAPIFunction : public ExtensionFunction { class TabsUpdateFunction : public BaseAPIFunction { private: - ~TabsUpdateFunction() override {} + ~TabsUpdateFunction() override = default; ResponseAction Run() override; @@ -98,19 +97,19 @@ class ExecuteCodeInTabFunction : public ExecuteCodeFunction { std::unique_ptr data); // Id of tab which executes code. - int execute_tab_id_; + int execute_tab_id_ = -1; }; class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction { private: - ~TabsExecuteScriptFunction() override {} + ~TabsExecuteScriptFunction() override = default; DECLARE_EXTENSION_FUNCTION("tabs.executeScript", TABS_EXECUTESCRIPT) }; class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { private: - ~TabsInsertCSSFunction() override {} + ~TabsInsertCSSFunction() override = default; bool ShouldInsertCSS() const override; @@ -119,7 +118,7 @@ class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { class TabsRemoveCSSFunction : public ExecuteCodeInTabFunction { private: - ~TabsRemoveCSSFunction() override {} + ~TabsRemoveCSSFunction() override = default; bool ShouldRemoveCSS() const override; @@ -132,7 +131,7 @@ class ZoomAPIFunction : public ExtensionFunction { ZoomAPIFunction(); protected: - ~ZoomAPIFunction() override {} + ~ZoomAPIFunction() override = default; // Gets the WebContents for |tab_id| if it is specified. Otherwise get the // WebContents for the active tab in the current window. Calling this function @@ -147,7 +146,7 @@ class ZoomAPIFunction : public ExtensionFunction { class TabsSetZoomFunction : public BaseAPIFunction { private: - ~TabsSetZoomFunction() override {} + ~TabsSetZoomFunction() override = default; ResponseAction Run() override; @@ -156,7 +155,7 @@ class TabsSetZoomFunction : public BaseAPIFunction { class TabsGetZoomFunction : public BaseAPIFunction { private: - ~TabsGetZoomFunction() override {} + ~TabsGetZoomFunction() override = default; ResponseAction Run() override; @@ -165,7 +164,7 @@ class TabsGetZoomFunction : public BaseAPIFunction { class TabsSetZoomSettingsFunction : public BaseAPIFunction { private: - ~TabsSetZoomSettingsFunction() override {} + ~TabsSetZoomSettingsFunction() override = default; ResponseAction Run() override; @@ -174,14 +173,13 @@ class TabsSetZoomSettingsFunction : public BaseAPIFunction { class TabsGetZoomSettingsFunction : public BaseAPIFunction { private: - ~TabsGetZoomSettingsFunction() override {} + ~TabsGetZoomSettingsFunction() override = default; ResponseAction Run() override; DECLARE_EXTENSION_FUNCTION("tabs.getZoomSettings", TABS_GETZOOMSETTINGS) }; -} // namespace cef -} // namespace extensions +} // namespace extensions::cef #endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ diff --git a/libcef/browser/extensions/browser_platform_delegate_background.h b/libcef/browser/extensions/browser_platform_delegate_background.h index 39ae59f2f..29ed20f42 100644 --- a/libcef/browser/extensions/browser_platform_delegate_background.h +++ b/libcef/browser/extensions/browser_platform_delegate_background.h @@ -14,7 +14,7 @@ class CefBrowserPlatformDelegateBackground public CefBrowserPlatformDelegateNative::WindowlessHandler { public: // Platform-specific behaviors will be delegated to |native_delegate|. - CefBrowserPlatformDelegateBackground( + explicit CefBrowserPlatformDelegateBackground( std::unique_ptr native_delegate); // CefBrowserPlatformDelegate methods: diff --git a/libcef/browser/extensions/chrome_api_registration.cc b/libcef/browser/extensions/chrome_api_registration.cc index 60c6153d3..c4a8e2a49 100644 --- a/libcef/browser/extensions/chrome_api_registration.cc +++ b/libcef/browser/extensions/chrome_api_registration.cc @@ -18,9 +18,7 @@ #include "extensions/browser/api/storage/storage_api.h" #include "extensions/browser/extension_function_registry.h" -namespace extensions { -namespace api { -namespace cef { +namespace extensions::api::cef { namespace cefimpl = extensions::cef; @@ -111,6 +109,4 @@ void ChromeFunctionRegistry::RegisterAll(ExtensionFunctionRegistry* registry) { registry->RegisterFunction(); } -} // namespace cef -} // namespace api -} // namespace extensions +} // namespace extensions::api::cef diff --git a/libcef/browser/extensions/chrome_api_registration.h b/libcef/browser/extensions/chrome_api_registration.h index 52e86c39c..3d0fde892 100644 --- a/libcef/browser/extensions/chrome_api_registration.h +++ b/libcef/browser/extensions/chrome_api_registration.h @@ -9,9 +9,7 @@ class ExtensionFunctionRegistry; -namespace extensions { -namespace api { -namespace cef { +namespace extensions::api::cef { // Array of currently supported APIs. extern const char* const kSupportedAPIs[]; @@ -22,8 +20,6 @@ class ChromeFunctionRegistry { static void RegisterAll(ExtensionFunctionRegistry* registry); }; -} // namespace cef -} // namespace api -} // namespace extensions +} // namespace extensions::api::cef #endif // CEF_LIBCEF_BROWSER_EXTENSIONS_CHROME_API_REGISTRATION_H_ diff --git a/libcef/browser/extensions/component_extension_resource_manager.cc b/libcef/browser/extensions/component_extension_resource_manager.cc index c7a3af041..23bdee0f9 100644 --- a/libcef/browser/extensions/component_extension_resource_manager.cc +++ b/libcef/browser/extensions/component_extension_resource_manager.cc @@ -33,7 +33,8 @@ CefComponentExtensionResourceManager::CefComponentExtensionResourceManager() { std::move(pdf_viewer_replacements); } -CefComponentExtensionResourceManager::~CefComponentExtensionResourceManager() {} +CefComponentExtensionResourceManager::~CefComponentExtensionResourceManager() = + default; bool CefComponentExtensionResourceManager::IsComponentExtensionResource( const base::FilePath& extension_path, diff --git a/libcef/browser/extensions/extension_function_details.cc b/libcef/browser/extensions/extension_function_details.cc index e1c0de975..0d514e8af 100644 --- a/libcef/browser/extensions/extension_function_details.cc +++ b/libcef/browser/extensions/extension_function_details.cc @@ -4,6 +4,8 @@ #include "libcef/browser/extensions/extension_function_details.h" +#include + #include "libcef/browser/browser_context.h" #include "libcef/browser/extensions/browser_extensions_util.h" #include "libcef/browser/extensions/extension_system.h" @@ -42,7 +44,7 @@ class CefGetExtensionLoadFileCallbackImpl CefGetExtensionLoadFileCallbackImpl& operator=( const CefGetExtensionLoadFileCallbackImpl&) = delete; - ~CefGetExtensionLoadFileCallbackImpl() { + ~CefGetExtensionLoadFileCallbackImpl() override { if (!callback_.is_null()) { // The callback is still pending. Cancel it now. if (CEF_CURRENTLY_ON_UIT()) { @@ -139,7 +141,7 @@ CefExtensionFunctionDetails::CefExtensionFunctionDetails( ExtensionFunction* function) : function_(function) {} -CefExtensionFunctionDetails::~CefExtensionFunctionDetails() {} +CefExtensionFunctionDetails::~CefExtensionFunctionDetails() = default; Profile* CefExtensionFunctionDetails::GetProfile() const { return Profile::FromBrowserContext(function_->browser_context()); @@ -285,9 +287,9 @@ bool CefExtensionFunctionDetails::LoadFile(const std::string& file, return false; } -CefExtensionFunctionDetails::OpenTabParams::OpenTabParams() {} +CefExtensionFunctionDetails::OpenTabParams::OpenTabParams() = default; -CefExtensionFunctionDetails::OpenTabParams::~OpenTabParams() {} +CefExtensionFunctionDetails::OpenTabParams::~OpenTabParams() = default; std::unique_ptr CefExtensionFunctionDetails::OpenTab( const OpenTabParams& params, @@ -369,7 +371,7 @@ std::unique_ptr CefExtensionFunctionDetails::OpenTab( CefBrowserCreateParams create_params; create_params.url = url.spec(); create_params.request_context = request_context; - create_params.window_info.reset(new CefWindowInfo); + create_params.window_info = std::make_unique(); #if BUILDFLAG(IS_WIN) create_params.window_info->SetAsPopup(nullptr, CefString()); diff --git a/libcef/browser/extensions/extension_host_delegate.cc b/libcef/browser/extensions/extension_host_delegate.cc index 8725e4e1c..5731781a4 100644 --- a/libcef/browser/extensions/extension_host_delegate.cc +++ b/libcef/browser/extensions/extension_host_delegate.cc @@ -15,7 +15,7 @@ namespace extensions { CefExtensionHostDelegate::CefExtensionHostDelegate( AlloyBrowserHostImpl* browser) {} -CefExtensionHostDelegate::~CefExtensionHostDelegate() {} +CefExtensionHostDelegate::~CefExtensionHostDelegate() = default; void CefExtensionHostDelegate::OnExtensionHostCreated( content::WebContents* web_contents) {} diff --git a/libcef/browser/extensions/extension_system.cc b/libcef/browser/extensions/extension_system.cc index 9a0050ffa..050e4f433 100644 --- a/libcef/browser/extensions/extension_system.cc +++ b/libcef/browser/extensions/extension_system.cc @@ -148,7 +148,7 @@ void LoadExtensionFromDisk(base::WeakPtr context, CefExtensionSystem::CefExtensionSystem(BrowserContext* browser_context) : browser_context_(browser_context), - initialized_(false), + registry_(ExtensionRegistry::Get(browser_context)), renderer_helper_( extensions::RendererStartupHelperFactory::GetForBrowserContext( @@ -157,7 +157,7 @@ CefExtensionSystem::CefExtensionSystem(BrowserContext* browser_context) InitPrefs(); } -CefExtensionSystem::~CefExtensionSystem() {} +CefExtensionSystem::~CefExtensionSystem() = default; void CefExtensionSystem::Init() { DCHECK(!initialized_); @@ -621,13 +621,11 @@ void CefExtensionSystem::NotifyExtensionLoaded(const Extension* extension) { info.name = base::UTF8ToUTF16(extension->name()); info.path = base::FilePath::FromUTF8Unsafe(extension->url().spec()); - for (std::set::const_iterator mime_type = - handler->mime_type_set().begin(); - mime_type != handler->mime_type_set().end(); ++mime_type) { + for (const auto& mime_type : handler->mime_type_set()) { content::WebPluginMimeType mime_type_info; - mime_type_info.mime_type = *mime_type; + mime_type_info.mime_type = mime_type; base::FilePath::StringType file_extension; - if (net::GetPreferredExtensionForMimeType(*mime_type, &file_extension)) { + if (net::GetPreferredExtensionForMimeType(mime_type, &file_extension)) { mime_type_info.file_extensions.push_back( base::FilePath(file_extension).AsUTF8Unsafe()); } diff --git a/libcef/browser/extensions/extension_system.h b/libcef/browser/extensions/extension_system.h index 599a2de66..e415a1647 100644 --- a/libcef/browser/extensions/extension_system.h +++ b/libcef/browser/extensions/extension_system.h @@ -155,7 +155,7 @@ class CefExtensionSystem : public ExtensionSystem { content::BrowserContext* browser_context_; // Not owned. - bool initialized_; + bool initialized_ = false; std::unique_ptr service_worker_manager_; std::unique_ptr quota_service_; diff --git a/libcef/browser/extensions/extension_system_factory.cc b/libcef/browser/extensions/extension_system_factory.cc index 2b82a4cbe..c49791c22 100644 --- a/libcef/browser/extensions/extension_system_factory.cc +++ b/libcef/browser/extensions/extension_system_factory.cc @@ -35,7 +35,7 @@ CefExtensionSystemFactory::CefExtensionSystemFactory() DependsOn(ExtensionRegistryFactory::GetInstance()); } -CefExtensionSystemFactory::~CefExtensionSystemFactory() {} +CefExtensionSystemFactory::~CefExtensionSystemFactory() = default; std::unique_ptr CefExtensionSystemFactory::BuildServiceInstanceForBrowserContext( diff --git a/libcef/browser/extensions/extension_view_host.cc b/libcef/browser/extensions/extension_view_host.cc index 9ed8c6898..141eeb975 100644 --- a/libcef/browser/extensions/extension_view_host.cc +++ b/libcef/browser/extensions/extension_view_host.cc @@ -33,7 +33,7 @@ CefExtensionViewHost::CefExtensionViewHost(AlloyBrowserHostImpl* browser, DCHECK(host_type == mojom::ViewType::kExtensionPopup); } -CefExtensionViewHost::~CefExtensionViewHost() {} +CefExtensionViewHost::~CefExtensionViewHost() = default; void CefExtensionViewHost::OnDidStopFirstLoad() { // Nothing to do here, but don't call the base class method. diff --git a/libcef/browser/extensions/extension_web_contents_observer.cc b/libcef/browser/extensions/extension_web_contents_observer.cc index 6e50ebea2..6be37ee0b 100644 --- a/libcef/browser/extensions/extension_web_contents_observer.cc +++ b/libcef/browser/extensions/extension_web_contents_observer.cc @@ -20,7 +20,7 @@ CefExtensionWebContentsObserver::CefExtensionWebContentsObserver( *web_contents), script_executor_(new ScriptExecutor(web_contents)) {} -CefExtensionWebContentsObserver::~CefExtensionWebContentsObserver() {} +CefExtensionWebContentsObserver::~CefExtensionWebContentsObserver() = default; // static void CefExtensionWebContentsObserver::CreateForWebContents( diff --git a/libcef/browser/extensions/extensions_api_client.cc b/libcef/browser/extensions/extensions_api_client.cc index 5d39a213c..742f4210d 100644 --- a/libcef/browser/extensions/extensions_api_client.cc +++ b/libcef/browser/extensions/extensions_api_client.cc @@ -21,7 +21,7 @@ namespace extensions { -CefExtensionsAPIClient::CefExtensionsAPIClient() {} +CefExtensionsAPIClient::CefExtensionsAPIClient() = default; AppViewGuestDelegate* CefExtensionsAPIClient::CreateAppViewGuestDelegate() const { diff --git a/libcef/browser/extensions/extensions_browser_client.cc b/libcef/browser/extensions/extensions_browser_client.cc index f99d711f7..1f89c87d8 100644 --- a/libcef/browser/extensions/extensions_browser_client.cc +++ b/libcef/browser/extensions/extensions_browser_client.cc @@ -5,6 +5,7 @@ #include "libcef/browser/extensions/extensions_browser_client.h" +#include #include #include "libcef/browser/alloy/alloy_browser_host_impl.h" @@ -100,7 +101,7 @@ CefExtensionsBrowserClient::CefExtensionsBrowserClient() AddAPIProvider(std::make_unique()); } -CefExtensionsBrowserClient::~CefExtensionsBrowserClient() {} +CefExtensionsBrowserClient::~CefExtensionsBrowserClient() = default; // static CefExtensionsBrowserClient* CefExtensionsBrowserClient::Get() { @@ -401,7 +402,7 @@ CefExtensionsBrowserClient::GetExtensionWebContentsObserver( KioskDelegate* CefExtensionsBrowserClient::GetKioskDelegate() { if (!kiosk_delegate_) { - kiosk_delegate_.reset(new CefKioskDelegate()); + kiosk_delegate_ = std::make_unique(); } return kiosk_delegate_.get(); } diff --git a/libcef/browser/extensions/mime_handler_view_guest_delegate.cc b/libcef/browser/extensions/mime_handler_view_guest_delegate.cc index ae5b67b39..9c947bb3e 100644 --- a/libcef/browser/extensions/mime_handler_view_guest_delegate.cc +++ b/libcef/browser/extensions/mime_handler_view_guest_delegate.cc @@ -19,7 +19,7 @@ CefMimeHandlerViewGuestDelegate::CefMimeHandlerViewGuestDelegate( MimeHandlerViewGuest* guest) : guest_(guest), owner_web_contents_(guest_->owner_web_contents()) {} -CefMimeHandlerViewGuestDelegate::~CefMimeHandlerViewGuestDelegate() {} +CefMimeHandlerViewGuestDelegate::~CefMimeHandlerViewGuestDelegate() = default; void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams( content::WebContents::CreateParams* params) { diff --git a/libcef/browser/file_dialog_manager.cc b/libcef/browser/file_dialog_manager.cc index 13b2b30a0..deae4f787 100644 --- a/libcef/browser/file_dialog_manager.cc +++ b/libcef/browser/file_dialog_manager.cc @@ -90,8 +90,8 @@ void RunFileDialogDismissed(CefRefPtr callback, const std::vector& file_paths) { std::vector paths; if (file_paths.size() > 0) { - for (size_t i = 0; i < file_paths.size(); ++i) { - paths.push_back(file_paths[i].value()); + for (const auto& file_path : file_paths) { + paths.push_back(file_path.value()); } } callback->OnFileDialogDismissed(paths); diff --git a/libcef/browser/frame_host_impl.cc b/libcef/browser/frame_host_impl.cc index 33c53dc54..2401c2f8b 100644 --- a/libcef/browser/frame_host_impl.cc +++ b/libcef/browser/frame_host_impl.cc @@ -615,8 +615,7 @@ void CefFrameHostImpl::SendToRenderFrame(const std::string& function_name, if (!render_frame_.is_bound()) { // Queue actions until we're notified by the renderer that it's ready to // handle them. - queued_renderer_actions_.push( - std::make_pair(function_name, std::move(action))); + queued_renderer_actions_.emplace(function_name, std::move(action)); return; } @@ -706,8 +705,7 @@ void CefFrameHostImpl::UpdateDraggableRegions( for (const auto& region : *regions) { const auto& rect = region->bounds; const CefRect bounds(rect.x(), rect.y(), rect.width(), rect.height()); - draggable_regions.push_back( - CefDraggableRegion(bounds, region->draggable)); + draggable_regions.emplace_back(bounds, region->draggable); } } diff --git a/libcef/browser/frame_service_base.h b/libcef/browser/frame_service_base.h index 795ac299c..da9bc8a4c 100644 --- a/libcef/browser/frame_service_base.h +++ b/libcef/browser/frame_service_base.h @@ -51,7 +51,7 @@ class FrameServiceBase : public Interface, public WebContentsObserver { protected: // Make the destructor private since |this| can only be deleted by Close(). - virtual ~FrameServiceBase() = default; + ~FrameServiceBase() override = default; // All subclasses should use this function to obtain the origin instead of // trying to get it from the RenderFrameHost pointer directly. diff --git a/libcef/browser/javascript_dialog_manager.cc b/libcef/browser/javascript_dialog_manager.cc index 1debbf12a..86622b229 100644 --- a/libcef/browser/javascript_dialog_manager.cc +++ b/libcef/browser/javascript_dialog_manager.cc @@ -21,7 +21,7 @@ class CefJSDialogCallbackImpl : public CefJSDialogCallback { public: using CallbackType = content::JavaScriptDialogManager::DialogClosedCallback; - CefJSDialogCallbackImpl(CallbackType callback) + explicit CefJSDialogCallbackImpl(CallbackType callback) : callback_(std::move(callback)) {} ~CefJSDialogCallbackImpl() override { if (!callback_.is_null()) { @@ -72,7 +72,7 @@ CefJavaScriptDialogManager::CefJavaScriptDialogManager( CefBrowserHostBase* browser) : browser_(browser), weak_ptr_factory_(this) {} -CefJavaScriptDialogManager::~CefJavaScriptDialogManager() {} +CefJavaScriptDialogManager::~CefJavaScriptDialogManager() = default; void CefJavaScriptDialogManager::Destroy() { if (handler_) { @@ -308,4 +308,4 @@ bool CefJavaScriptDialogManager::CanUseChromeDialogs() const { } return true; -} \ No newline at end of file +} diff --git a/libcef/browser/main_runner.cc b/libcef/browser/main_runner.cc index 3dbf759ab..24540b56b 100644 --- a/libcef/browser/main_runner.cc +++ b/libcef/browser/main_runner.cc @@ -34,6 +34,8 @@ #if BUILDFLAG(IS_WIN) #include #include + +#include #include "content/public/app/sandbox_helper_win.h" #include "sandbox/win/src/sandbox_types.h" #endif @@ -498,7 +500,7 @@ int CefMainRunner::RunMainProcess( bool CefMainRunner::CreateUIThread(base::OnceClosure setup_callback) { DCHECK(!ui_thread_); - ui_thread_.reset(new CefUIThread(this, std::move(setup_callback))); + ui_thread_ = std::make_unique(this, std::move(setup_callback)); ui_thread_->Start(); ui_thread_->WaitUntilThreadStarted(); diff --git a/libcef/browser/main_runner.h b/libcef/browser/main_runner.h index f9252a6ab..b7163adf4 100644 --- a/libcef/browser/main_runner.h +++ b/libcef/browser/main_runner.h @@ -32,7 +32,7 @@ class CefMainRunner : public CefMainRunnerHandler { CefMainRunner(const CefMainRunner&) = delete; CefMainRunner& operator=(const CefMainRunner&) = delete; - ~CefMainRunner(); + ~CefMainRunner() override; // Called from CefContext::Initialize. bool Initialize(CefSettings* settings, diff --git a/libcef/browser/media_access_query.cc b/libcef/browser/media_access_query.cc index c0b644954..93f101d42 100644 --- a/libcef/browser/media_access_query.cc +++ b/libcef/browser/media_access_query.cc @@ -146,8 +146,8 @@ class CefMediaAccessQuery { } if (desktop_audio_requested()) { - audio_devices.push_back(blink::MediaStreamDevice( - request_.audio_type, "loopback", "System Audio")); + audio_devices.emplace_back(request_.audio_type, "loopback", + "System Audio"); } if (desktop_video_requested()) { @@ -160,8 +160,8 @@ class CefMediaAccessQuery { media_id = content::DesktopMediaID::Parse(request_.requested_video_device_id); } - video_devices.push_back(blink::MediaStreamDevice( - request_.video_type, media_id.ToString(), "Screen")); + video_devices.emplace_back(request_.video_type, media_id.ToString(), + "Screen"); } blink::mojom::StreamDevicesSetPtr stream_devices_set = diff --git a/libcef/browser/media_capture_devices_dispatcher.cc b/libcef/browser/media_capture_devices_dispatcher.cc index 25d53017c..329643921 100644 --- a/libcef/browser/media_capture_devices_dispatcher.cc +++ b/libcef/browser/media_capture_devices_dispatcher.cc @@ -39,9 +39,9 @@ CefMediaCaptureDevicesDispatcher::GetInstance() { return base::Singleton::get(); } -CefMediaCaptureDevicesDispatcher::CefMediaCaptureDevicesDispatcher() {} +CefMediaCaptureDevicesDispatcher::CefMediaCaptureDevicesDispatcher() = default; -CefMediaCaptureDevicesDispatcher::~CefMediaCaptureDevicesDispatcher() {} +CefMediaCaptureDevicesDispatcher::~CefMediaCaptureDevicesDispatcher() = default; void CefMediaCaptureDevicesDispatcher::RegisterPrefs( PrefRegistrySimple* registry) { diff --git a/libcef/browser/media_router/media_router_manager.h b/libcef/browser/media_router/media_router_manager.h index 10f831d60..90bebabf3 100644 --- a/libcef/browser/media_router/media_router_manager.h +++ b/libcef/browser/media_router/media_router_manager.h @@ -45,7 +45,7 @@ class CefMediaRouterManager const content::PresentationConnectionStateChangeInfo& info) = 0; protected: - ~Observer() override {} + ~Observer() override = default; }; explicit CefMediaRouterManager(content::BrowserContext* browser_context); diff --git a/libcef/browser/menu_manager.cc b/libcef/browser/menu_manager.cc index ccc4fc029..c4cefed2d 100644 --- a/libcef/browser/menu_manager.cc +++ b/libcef/browser/menu_manager.cc @@ -44,7 +44,7 @@ class CefRunContextMenuCallbackImpl : public CefRunContextMenuCallback { CefRunContextMenuCallbackImpl& operator=( const CefRunContextMenuCallbackImpl&) = delete; - ~CefRunContextMenuCallbackImpl() { + ~CefRunContextMenuCallbackImpl() override { if (!callback_.is_null()) { // The callback is still pending. Cancel it now. if (CEF_CURRENTLY_ON_UIT()) { @@ -95,7 +95,7 @@ CefMenuManager::CefMenuManager(AlloyBrowserHostImpl* browser, : content::WebContentsObserver(browser->web_contents()), browser_(browser), runner_(std::move(runner)), - custom_menu_callback_(nullptr), + weak_ptr_factory_(this) { DCHECK(web_contents()); model_ = new CefMenuModelImpl(this, nullptr, false); @@ -497,8 +497,8 @@ bool CefMenuManager::IsCustomContextMenuCommand(int command_id) { // Verify that the specific command ID was passed from the renderer process. if (!params_.custom_items.empty()) { - for (size_t i = 0; i < params_.custom_items.size(); ++i) { - if (static_cast(params_.custom_items[i]->action) == command_id) { + for (const auto& custom_item : params_.custom_items) { + if (static_cast(custom_item->action) == command_id) { return true; } } diff --git a/libcef/browser/menu_manager.h b/libcef/browser/menu_manager.h index 239e3b7c3..e5d185f8f 100644 --- a/libcef/browser/menu_manager.h +++ b/libcef/browser/menu_manager.h @@ -72,7 +72,7 @@ class CefMenuManager : public CefMenuModelImpl::Delegate, content::ContextMenuParams params_; // Not owned by this class. - CefRunContextMenuCallback* custom_menu_callback_; + CefRunContextMenuCallback* custom_menu_callback_ = nullptr; // Must be the last member. base::WeakPtrFactory weak_ptr_factory_; diff --git a/libcef/browser/menu_model_impl.cc b/libcef/browser/menu_model_impl.cc index de66b0c5b..130b03caf 100644 --- a/libcef/browser/menu_model_impl.cc +++ b/libcef/browser/menu_model_impl.cc @@ -5,6 +5,7 @@ #include "libcef/browser/menu_model_impl.h" +#include #include #include "libcef/browser/thread_util.h" @@ -247,10 +248,10 @@ CefMenuModelImpl::CefMenuModelImpl( menu_model_delegate_(menu_model_delegate), is_submenu_(is_submenu) { DCHECK(delegate_ || menu_model_delegate_); - model_.reset(new CefSimpleMenuModel(this)); + model_ = std::make_unique(this); } -CefMenuModelImpl::~CefMenuModelImpl() {} +CefMenuModelImpl::~CefMenuModelImpl() = default; bool CefMenuModelImpl::IsSubMenu() { if (!VerifyContext()) { @@ -986,9 +987,9 @@ bool CefMenuModelImpl::VerifyRefCount() { return false; } - for (ItemVector::iterator i = items_.begin(); i != items_.end(); ++i) { - if ((*i).submenu_.get()) { - if (!(*i).submenu_->VerifyRefCount()) { + for (auto& item : items_) { + if (item.submenu_.get()) { + if (!item.submenu_->VerifyRefCount()) { return false; } } @@ -1017,8 +1018,8 @@ void CefMenuModelImpl::AddMenuItem( case blink::mojom::CustomContextMenuItemType::kSubMenu: { CefRefPtr sub_menu = static_cast( AddSubMenu(command_id, menu_item.label).get()); - for (size_t i = 0; i < menu_item.submenu.size(); ++i) { - sub_menu->AddMenuItem(*menu_item.submenu[i]); + for (const auto& i : menu_item.submenu) { + sub_menu->AddMenuItem(*i); } break; } diff --git a/libcef/browser/menu_model_impl.h b/libcef/browser/menu_model_impl.h index b8965121b..8e4a93d77 100644 --- a/libcef/browser/menu_model_impl.h +++ b/libcef/browser/menu_model_impl.h @@ -50,7 +50,7 @@ class CefMenuModelImpl : public CefMenuModel { std::u16string& label) = 0; protected: - virtual ~Delegate() {} + virtual ~Delegate() = default; }; // Either |delegate| or |menu_model_delegate| must be non-nullptr. diff --git a/libcef/browser/native/browser_platform_delegate_native.cc b/libcef/browser/native/browser_platform_delegate_native.cc index 6547a137b..d60eebdb0 100644 --- a/libcef/browser/native/browser_platform_delegate_native.cc +++ b/libcef/browser/native/browser_platform_delegate_native.cc @@ -13,9 +13,7 @@ CefBrowserPlatformDelegateNative::CefBrowserPlatformDelegateNative( const CefWindowInfo& window_info, SkColor background_color) - : window_info_(window_info), - background_color_(background_color), - windowless_handler_(nullptr) {} + : window_info_(window_info), background_color_(background_color) {} SkColor CefBrowserPlatformDelegateNative::GetBackgroundColor() const { return background_color_; diff --git a/libcef/browser/native/browser_platform_delegate_native.h b/libcef/browser/native/browser_platform_delegate_native.h index 704da0d1a..a208039a5 100644 --- a/libcef/browser/native/browser_platform_delegate_native.h +++ b/libcef/browser/native/browser_platform_delegate_native.h @@ -25,7 +25,7 @@ class CefBrowserPlatformDelegateNative bool want_dip_coords) const = 0; protected: - virtual ~WindowlessHandler() {} + virtual ~WindowlessHandler() = default; }; // CefBrowserPlatformDelegate methods: @@ -69,7 +69,8 @@ class CefBrowserPlatformDelegateNative CefWindowInfo window_info_; const SkColor background_color_; - WindowlessHandler* windowless_handler_; // Not owned by this object. + // Not owned by this object. + WindowlessHandler* windowless_handler_ = nullptr; }; #endif // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_H_ diff --git a/libcef/browser/native/browser_platform_delegate_native_win.cc b/libcef/browser/native/browser_platform_delegate_native_win.cc index 705ddb9fc..7d353c093 100644 --- a/libcef/browser/native/browser_platform_delegate_native_win.cc +++ b/libcef/browser/native/browser_platform_delegate_native_win.cc @@ -162,7 +162,7 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() { if (!window_info_.parent_window) { const bool has_menu = - !(window_info_.style & WS_CHILD) && (window_info_.menu != NULL); + !(window_info_.style & WS_CHILD) && (window_info_.menu != nullptr); window_rect = GetAdjustedScreenFrameRect(window_rect, window_info_.style, window_info_.ex_style, has_menu); } @@ -172,7 +172,7 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() { window_info_.style, window_rect.x, window_rect.y, window_rect.width, window_rect.height, window_info_.parent_window, window_info_.menu, - ::GetModuleHandle(NULL), this); + ::GetModuleHandle(nullptr), this); // It's possible for CreateWindowEx to fail if the parent window was // destroyed between the call to CreateBrowser and the above one. @@ -248,7 +248,7 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() { } void CefBrowserPlatformDelegateNativeWin::CloseHostWindow() { - if (window_info_.window != NULL) { + if (window_info_.window != nullptr) { HWND frameWnd = GetAncestor(window_info_.window, GA_ROOT); PostMessage(frameWnd, WM_CLOSE, 0, 0); } @@ -361,13 +361,13 @@ void CefBrowserPlatformDelegateNativeWin::SizeTo(int width, int height) { const DWORD style = GetWindowLong(window, GWL_STYLE); const DWORD ex_style = GetWindowLong(window, GWL_EXSTYLE); - const bool has_menu = !(style & WS_CHILD) && (GetMenu(window) != NULL); + const bool has_menu = !(style & WS_CHILD) && (GetMenu(window) != nullptr); const auto frame_rect = GetScreenFrameRectFromDIPContentRect( window, gfx::Rect(0, 0, width, height), style, ex_style, has_menu); // Size the window. The left/top values may be negative. - SetWindowPos(window, NULL, 0, 0, frame_rect.width, frame_rect.height, + SetWindowPos(window, nullptr, 0, 0, frame_rect.width, frame_rect.height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); } @@ -421,7 +421,7 @@ bool CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent( CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle( const content::NativeWebKeyboardEvent& event) const { if (!event.os_event) { - return NULL; + return nullptr; } return ChromeToWindowsType( const_cast(&event.os_event->native_event())); @@ -496,13 +496,13 @@ void CefBrowserPlatformDelegateNativeWin::RegisterWindowClass() { /* lpfnWndProc = */ CefBrowserPlatformDelegateNativeWin::WndProc, /* cbClsExtra = */ 0, /* cbWndExtra = */ 0, - /* hInstance = */ ::GetModuleHandle(NULL), - /* hIcon = */ NULL, - /* hCursor = */ LoadCursor(NULL, IDC_ARROW), - /* hbrBackground = */ 0, - /* lpszMenuName = */ NULL, + /* hInstance = */ ::GetModuleHandle(nullptr), + /* hIcon = */ nullptr, + /* hCursor = */ LoadCursor(nullptr, IDC_ARROW), + /* hbrBackground = */ nullptr, + /* lpszMenuName = */ nullptr, /* lpszClassName = */ CefBrowserPlatformDelegateNativeWin::GetWndClass(), - /* hIconSm = */ NULL, + /* hIconSm = */ nullptr, }; RegisterClassEx(&wcex); @@ -568,7 +568,7 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd, case WM_NCDESTROY: if (platform_delegate) { // Clear the user data pointer. - gfx::SetWindowUserData(hwnd, NULL); + gfx::SetWindowUserData(hwnd, nullptr); // Force the browser to be destroyed. This will result in a call to // BrowserDestroyed() that will release the reference added in @@ -584,7 +584,7 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd, // will cause the widget to be hidden which reduces resource usage. RECT rc; GetClientRect(hwnd, &rc); - SetWindowPos(HWNDForWidget(platform_delegate->window_widget_), NULL, + SetWindowPos(HWNDForWidget(platform_delegate->window_widget_), nullptr, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER); } @@ -614,8 +614,8 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd, // Suggested size and position of the current window scaled for the // new DPI. const RECT* rect = reinterpret_cast(lParam); - SetWindowPos(platform_delegate->GetHostWindowHandle(), NULL, rect->left, - rect->top, rect->right - rect->left, + SetWindowPos(platform_delegate->GetHostWindowHandle(), nullptr, + rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top, SWP_NOZORDER | SWP_NOACTIVATE); } break; diff --git a/libcef/browser/native/menu_runner_views_aura.cc b/libcef/browser/native/menu_runner_views_aura.cc index 2b0accc4f..a2b5e222e 100644 --- a/libcef/browser/native/menu_runner_views_aura.cc +++ b/libcef/browser/native/menu_runner_views_aura.cc @@ -4,12 +4,14 @@ #include "libcef/browser/native/menu_runner_views_aura.h" +#include + #include "libcef/browser/alloy/alloy_browser_host_impl.h" #include "base/strings/string_util.h" #include "ui/gfx/geometry/point.h" -CefMenuRunnerViewsAura::CefMenuRunnerViewsAura() {} +CefMenuRunnerViewsAura::CefMenuRunnerViewsAura() = default; bool CefMenuRunnerViewsAura::RunContextMenu( AlloyBrowserHostImpl* browser, @@ -27,8 +29,8 @@ bool CefMenuRunnerViewsAura::RunContextMenu( widget = browser->GetWindowWidget(); } - menu_.reset( - new views::MenuRunner(model->model(), views::MenuRunner::CONTEXT_MENU)); + menu_ = std::make_unique(model->model(), + views::MenuRunner::CONTEXT_MENU); gfx::Point screen_point = browser->GetScreenPoint( gfx::Point(params.x, params.y), /*want_dip_coords=*/true); diff --git a/libcef/browser/net/chrome_scheme_handler.cc b/libcef/browser/net/chrome_scheme_handler.cc index 18922d58d..facd69fe1 100644 --- a/libcef/browser/net/chrome_scheme_handler.cc +++ b/libcef/browser/net/chrome_scheme_handler.cc @@ -136,11 +136,9 @@ const struct { }; ChromeHostId GetChromeHostId(const std::string& host) { - for (size_t i = 0; i < sizeof(kAllowedCefHosts) / sizeof(kAllowedCefHosts[0]); - ++i) { - if (base::EqualsCaseInsensitiveASCII(kAllowedCefHosts[i].host, - host.c_str())) { - return kAllowedCefHosts[i].host_id; + for (auto kAllowedCefHost : kAllowedCefHosts) { + if (base::EqualsCaseInsensitiveASCII(kAllowedCefHost.host, host.c_str())) { + return kAllowedCefHost.host_id; } } @@ -150,17 +148,15 @@ ChromeHostId GetChromeHostId(const std::string& host) { // Returns WebUI hosts. Does not include chrome debug hosts (for crashing, etc). void GetAllowedHosts(std::vector* hosts) { // Explicitly whitelisted WebUI hosts. - for (size_t i = 0; - i < sizeof(kAllowedWebUIHosts) / sizeof(kAllowedWebUIHosts[0]); ++i) { - hosts->push_back(kAllowedWebUIHosts[i]); + for (auto& kAllowedWebUIHost : kAllowedWebUIHosts) { + hosts->push_back(kAllowedWebUIHost); } } // Returns true if a host should not be listed on "chrome://webui-hosts". bool IsUnlistedHost(const std::string& host) { - for (size_t i = 0; i < sizeof(kUnlistedHosts) / sizeof(kUnlistedHosts[0]); - ++i) { - if (host == kUnlistedHosts[i]) { + for (auto& kUnlistedHost : kUnlistedHosts) { + if (host == kUnlistedHost) { return true; } } @@ -175,9 +171,8 @@ bool IsAllowedWebUIHost(const std::string& host) { } // Explicitly whitelisted WebUI hosts. - for (size_t i = 0; - i < sizeof(kAllowedWebUIHosts) / sizeof(kAllowedWebUIHosts[0]); ++i) { - if (base::EqualsCaseInsensitiveASCII(kAllowedWebUIHosts[i], host.c_str())) { + for (auto& kAllowedWebUIHost : kAllowedWebUIHosts) { + if (base::EqualsCaseInsensitiveASCII(kAllowedWebUIHost, host.c_str())) { return true; } } @@ -195,9 +190,8 @@ void GetDebugURLs(std::vector* urls) { urls->push_back(chrome::kChromeDebugURLs[i]); } - for (size_t i = 0; - i < sizeof(kAllowedDebugURLs) / sizeof(kAllowedDebugURLs[0]); ++i) { - urls->push_back(kAllowedDebugURLs[i]); + for (auto& kAllowedDebugURL : kAllowedDebugURLs) { + urls->push_back(kAllowedDebugURL); } } @@ -425,13 +419,12 @@ bool OnWebUIHostsUI(std::string* mime_type, std::string* output) { GetAllowedHosts(&list); std::sort(list.begin(), list.end()); - for (size_t i = 0U; i < list.size(); ++i) { - if (IsUnlistedHost(list[i])) { + for (const auto& i : list) { + if (IsUnlistedHost(i)) { continue; } - html += "
  • chrome://" + list[i] + - "
  • \n"; + html += "
  • chrome://" + i + "
  • \n"; } list.clear(); @@ -443,8 +436,8 @@ bool OnWebUIHostsUI(std::string* mime_type, std::string* output) { "

    The following pages are for debugging purposes only. Because they " "crash or hang the renderer, they're not linked directly; you can type " "them into the address bar if you need them.

    \n
      \n"; - for (size_t i = 0U; i < list.size(); ++i) { - html += "
    • " + std::string(list[i]) + "
    • \n"; + for (const auto& i : list) { + html += "
    • " + std::string(i) + "
    • \n"; } html += "
    \n"; diff --git a/libcef/browser/net/devtools_scheme_handler.cc b/libcef/browser/net/devtools_scheme_handler.cc index 97f120427..d9d0f1f17 100644 --- a/libcef/browser/net/devtools_scheme_handler.cc +++ b/libcef/browser/net/devtools_scheme_handler.cc @@ -22,7 +22,7 @@ namespace { class Delegate : public InternalHandlerDelegate { public: - Delegate() {} + Delegate() = default; bool OnRequest(CefRefPtr browser, CefRefPtr request, diff --git a/libcef/browser/net/internal_scheme_handler.cc b/libcef/browser/net/internal_scheme_handler.cc index 5967810ee..b7da1d766 100644 --- a/libcef/browser/net/internal_scheme_handler.cc +++ b/libcef/browser/net/internal_scheme_handler.cc @@ -209,7 +209,7 @@ class InternalHandlerFactory : public CefSchemeHandlerFactory { } // namespace -InternalHandlerDelegate::Action::Action() : stream_size(-1), resource_id(-1) {} +InternalHandlerDelegate::Action::Action() = default; CefRefPtr CreateInternalHandlerFactory( std::unique_ptr delegate) { diff --git a/libcef/browser/net/internal_scheme_handler.h b/libcef/browser/net/internal_scheme_handler.h index 3db3ef074..e63c2bc62 100644 --- a/libcef/browser/net/internal_scheme_handler.h +++ b/libcef/browser/net/internal_scheme_handler.h @@ -29,19 +29,19 @@ class InternalHandlerDelegate { // Option 1: Provide a stream for the resource contents. Set |stream_size| // to the stream size or to -1 if unknown. CefRefPtr stream; - int stream_size; + int stream_size = -1; // Option 2: Provide a base::RefCountedMemory for the resource contents. scoped_refptr bytes; // Option 3: Specify a resource id to load static content. - int resource_id; + int resource_id = -1; // Option 4: Redirect to the specified URL. GURL redirect_url; }; - virtual ~InternalHandlerDelegate() {} + virtual ~InternalHandlerDelegate() = default; // Populate |action| and return true if the request was handled. virtual bool OnRequest(CefRefPtr browser, diff --git a/libcef/browser/net_service/browser_urlrequest_impl.cc b/libcef/browser/net_service/browser_urlrequest_impl.cc index 90f9e2683..0bfead72b 100644 --- a/libcef/browser/net_service/browser_urlrequest_impl.cc +++ b/libcef/browser/net_service/browser_urlrequest_impl.cc @@ -5,6 +5,7 @@ #include "libcef/browser/net_service/browser_urlrequest_impl.h" +#include #include #include @@ -59,7 +60,7 @@ bool IsValidRequestID(int32_t request_id) { // Manages the mapping of request IDs to request objects. class RequestManager { public: - RequestManager() {} + RequestManager() = default; RequestManager(const RequestManager&) = delete; RequestManager& operator=(const RequestManager&) = delete; @@ -626,10 +627,11 @@ CefBrowserURLRequest::CefBrowserURLRequest( CefRefPtr request, CefRefPtr client, CefRefPtr request_context) { - context_.reset(new Context(this, frame, request, client, request_context)); + context_ = + std::make_unique(this, frame, request, client, request_context); } -CefBrowserURLRequest::~CefBrowserURLRequest() {} +CefBrowserURLRequest::~CefBrowserURLRequest() = default; bool CefBrowserURLRequest::Start() { if (!VerifyContext()) { diff --git a/libcef/browser/net_service/cookie_helper.cc b/libcef/browser/net_service/cookie_helper.cc index 77b95375c..c944b6c2a 100644 --- a/libcef/browser/net_service/cookie_helper.cc +++ b/libcef/browser/net_service/cookie_helper.cc @@ -17,8 +17,7 @@ #include "services/network/cookie_manager.h" #include "services/network/public/cpp/resource_request.h" -namespace net_service { -namespace cookie_helper { +namespace net_service::cookie_helper { namespace { @@ -300,7 +299,7 @@ void SaveCookies(const CefBrowserContext::Getter& browser_context_getter, std::unique_ptr cookie = net::CanonicalCookie::Create( request.url, cookie_string, base::Time::Now(), absl::make_optional(response_date), /*partition_key=*/absl::nullopt, - /*block_truncated_cookies=*/true, &returned_status); + /*block_truncated=*/true, &returned_status); if (!returned_status.IsInclude()) { continue; } @@ -325,5 +324,4 @@ void SaveCookies(const CefBrowserContext::Getter& browser_context_getter, } } -} // namespace cookie_helper -} // namespace net_service +} // namespace net_service::cookie_helper diff --git a/libcef/browser/net_service/cookie_helper.h b/libcef/browser/net_service/cookie_helper.h index c975fd1fe..323644a89 100644 --- a/libcef/browser/net_service/cookie_helper.h +++ b/libcef/browser/net_service/cookie_helper.h @@ -18,8 +18,7 @@ namespace network { struct ResourceRequest; } // namespace network -namespace net_service { -namespace cookie_helper { +namespace net_service::cookie_helper { // Returns true if the scheme for |url| supports cookies. |cookieable_schemes| // is the optional list of schemes that the client has explicitly registered as @@ -59,7 +58,6 @@ void SaveCookies(const CefBrowserContext::Getter& browser_context_getter, const AllowCookieCallback& allow_cookie_callback, DoneCookieCallback done_callback); -} // namespace cookie_helper -} // namespace net_service +} // namespace net_service::cookie_helper #endif // CEF_LIBCEF_BROWSER_NET_SERVICE_COOKIE_HELPER_H_ diff --git a/libcef/browser/net_service/cookie_manager_impl.cc b/libcef/browser/net_service/cookie_manager_impl.cc index 89714105f..575fbf0a8 100644 --- a/libcef/browser/net_service/cookie_manager_impl.cc +++ b/libcef/browser/net_service/cookie_manager_impl.cc @@ -122,7 +122,7 @@ void GetCookiesCallbackImpl( } // namespace -CefCookieManagerImpl::CefCookieManagerImpl() {} +CefCookieManagerImpl::CefCookieManagerImpl() = default; void CefCookieManagerImpl::Initialize( CefBrowserContext::Getter browser_context_getter, diff --git a/libcef/browser/net_service/proxy_url_loader_factory.cc b/libcef/browser/net_service/proxy_url_loader_factory.cc index b52d03ad4..6c1ef1fc3 100644 --- a/libcef/browser/net_service/proxy_url_loader_factory.cc +++ b/libcef/browser/net_service/proxy_url_loader_factory.cc @@ -92,7 +92,7 @@ class ResourceContextData : public base::SupportsUserData::Data { ResourceContextData(const ResourceContextData&) = delete; ResourceContextData& operator=(const ResourceContextData&) = delete; - ~ResourceContextData() override {} + ~ResourceContextData() override = default; static void AddProxyOnUIThread( ProxyURLLoaderFactory* proxy, @@ -1250,8 +1250,8 @@ void InterceptedRequest::OnUploadProgressACK() { // InterceptedRequestHandler //============================== -InterceptedRequestHandler::InterceptedRequestHandler() {} -InterceptedRequestHandler::~InterceptedRequestHandler() {} +InterceptedRequestHandler::InterceptedRequestHandler() = default; +InterceptedRequestHandler::~InterceptedRequestHandler() = default; void InterceptedRequestHandler::OnBeforeRequest( int32_t request_id, diff --git a/libcef/browser/net_service/resource_request_handler_wrapper.cc b/libcef/browser/net_service/resource_request_handler_wrapper.cc index 7efaa7e74..f000df98d 100644 --- a/libcef/browser/net_service/resource_request_handler_wrapper.cc +++ b/libcef/browser/net_service/resource_request_handler_wrapper.cc @@ -4,6 +4,8 @@ #include "libcef/browser/net_service/resource_request_handler_wrapper.h" +#include + #include "libcef/browser/browser_host_base.h" #include "libcef/browser/context.h" #include "libcef/browser/iothread_state.h" @@ -89,7 +91,7 @@ class RequestCallbackWrapper : public CefCallback { class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { public: struct RequestState { - RequestState() {} + RequestState() = default; void Reset(CefRefPtr handler, CefRefPtr scheme_factory, @@ -164,7 +166,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { DestructionObserver(const DestructionObserver&) = delete; DestructionObserver& operator=(const DestructionObserver&) = delete; - virtual ~DestructionObserver() { + ~DestructionObserver() override { CEF_REQUIRE_UIT(); if (!registered_) { return; @@ -225,7 +227,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { // initialized on the UI thread and later passed to the *Wrapper object on // the IO thread. struct InitState { - InitState() {} + InitState() = default; ~InitState() { if (destruction_observer_) { @@ -259,7 +261,8 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { // that we can stop accepting new requests and cancel pending/in-progress // requests in a timely manner (e.g. before we start asserting about // leaked objects during CEF shutdown). - destruction_observer_.reset(new DestructionObserver(browser.get())); + destruction_observer_ = + std::make_unique(browser.get()); if (browser) { // These references will be released in OnDestroyed(). diff --git a/libcef/browser/net_service/stream_reader_url_loader.cc b/libcef/browser/net_service/stream_reader_url_loader.cc index 0ea7875f8..1372f1c08 100644 --- a/libcef/browser/net_service/stream_reader_url_loader.cc +++ b/libcef/browser/net_service/stream_reader_url_loader.cc @@ -249,7 +249,7 @@ InputStreamReader::InputStreamReader( DCHECK(work_thread_task_runner_); } -InputStreamReader::~InputStreamReader() {} +InputStreamReader::~InputStreamReader() = default; void InputStreamReader::Skip(int64_t skip_bytes, InputStream::SkipCallback callback) { @@ -698,7 +698,7 @@ void StreamReaderURLLoader::ContinueWithResponseHeaders( if (has_redirect_url || pending_headers->IsRedirect(&location)) { pending_response->encoded_data_length = header_length_; pending_response->content_length = 0; - pending_response->encoded_body_length = 0; + pending_response->encoded_body_length = nullptr; const GURL new_location = has_redirect_url ? *redirect_url : request_.url.Resolve(location); client_->OnReceiveRedirect( diff --git a/libcef/browser/net_service/stream_reader_url_loader.h b/libcef/browser/net_service/stream_reader_url_loader.h index ea3ec46bb..81b827650 100644 --- a/libcef/browser/net_service/stream_reader_url_loader.h +++ b/libcef/browser/net_service/stream_reader_url_loader.h @@ -27,7 +27,7 @@ class InputStreamReader; // sequence on a worker thread, but not necessarily on the same thread. class InputStream { public: - virtual ~InputStream() {} + virtual ~InputStream() = default; // Callback for asynchronous continuation of Skip(). If |bytes_skipped| > 0 // then either Skip() will be called again until the requested number of @@ -69,7 +69,7 @@ class InputStream { // called on the IO thread unless otherwise indicated. class ResourceResponse { public: - virtual ~ResourceResponse() {} + virtual ~ResourceResponse() = default; // Callback for asynchronous continuation of Open(). If the InputStream is // null the request will be canceled. diff --git a/libcef/browser/osr/host_display_client_osr.cc b/libcef/browser/osr/host_display_client_osr.cc index b1aa583fe..e3f8a2652 100644 --- a/libcef/browser/osr/host_display_client_osr.cc +++ b/libcef/browser/osr/host_display_client_osr.cc @@ -114,7 +114,7 @@ CefHostDisplayClientOSR::CefHostDisplayClientOSR( gfx::AcceleratedWidget widget) : viz::HostDisplayClient(widget), view_(view) {} -CefHostDisplayClientOSR::~CefHostDisplayClientOSR() {} +CefHostDisplayClientOSR::~CefHostDisplayClientOSR() = default; void CefHostDisplayClientOSR::SetActive(bool active) { active_ = active; diff --git a/libcef/browser/osr/motion_event_osr.cc b/libcef/browser/osr/motion_event_osr.cc index 1f83e84b2..e7132bae2 100644 --- a/libcef/browser/osr/motion_event_osr.cc +++ b/libcef/browser/osr/motion_event_osr.cc @@ -36,7 +36,7 @@ CefMotionEventOSR::CefMotionEventOSR() { std::fill(id_map_, id_map_ + blink::WebTouchEvent::kTouchesLengthCap, -1); } -CefMotionEventOSR::~CefMotionEventOSR() {} +CefMotionEventOSR::~CefMotionEventOSR() = default; int CefMotionEventOSR::GetSourceDeviceId(size_t pointer_index) const { if (IsValidIndex(pointer_index)) { @@ -165,9 +165,9 @@ int CefMotionEventOSR::AddId(int id) { } void CefMotionEventOSR::RemoveId(int id) { - for (int i = 0; i < blink::WebTouchEvent::kTouchesLengthCap; i++) { - if (id_map_[i] == id) { - id_map_[i] = -1; + for (int& i : id_map_) { + if (i == id) { + i = -1; } } } diff --git a/libcef/browser/osr/osr_accessibility_util.cc b/libcef/browser/osr/osr_accessibility_util.cc index 919d01d5a..bff17184b 100644 --- a/libcef/browser/osr/osr_accessibility_util.cc +++ b/libcef/browser/osr/osr_accessibility_util.cc @@ -206,9 +206,9 @@ struct PopulateAxNodeAttributes { CefRefPtr list = CefListValue::Create(); int index = 0; // Iterate and find which states are set. - for (unsigned i = 0; i < std::size(textStyleArr); i++) { - if (attr.second & static_cast(textStyleArr[i])) { - list->SetString(index++, ToString(textStyleArr[i])); + for (auto& i : textStyleArr) { + if (attr.second & static_cast(i)) { + list->SetString(index++, ToString(i)); } } attributes->SetList(ToString(attr.first), list); @@ -259,8 +259,8 @@ struct PopulateAxNodeAttributes { if (ax::mojom::IntListAttribute::kMarkerTypes == attr.first) { list = CefListValue::Create(); int index = 0; - for (size_t i = 0; i < attr.second.size(); ++i) { - auto type = static_cast(attr.second[i]); + for (int i : attr.second) { + auto type = static_cast(i); if (type == ax::mojom::MarkerType::kNone) { continue; @@ -271,9 +271,9 @@ struct PopulateAxNodeAttributes { ax::mojom::MarkerType::kTextMatch}; // Iterate and find which markers are set. - for (unsigned j = 0; j < std::size(marktypeArr); j++) { - if (attr.second[i] & static_cast(marktypeArr[j])) { - list->SetString(index++, ToString(marktypeArr[j])); + for (auto& j : marktypeArr) { + if (i & static_cast(j)) { + list->SetString(index++, ToString(j)); } } } diff --git a/libcef/browser/osr/render_widget_host_view_osr.cc b/libcef/browser/osr/render_widget_host_view_osr.cc index e06be07f3..59148eeea 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.cc +++ b/libcef/browser/osr/render_widget_host_view_osr.cc @@ -6,6 +6,7 @@ #include "libcef/browser/osr/render_widget_host_view_osr.h" #include +#include #include #include "libcef/browser/alloy/alloy_browser_host_impl.h" @@ -220,14 +221,15 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( content::RenderViewHost::From(render_widget_host_)); } - delegated_frame_host_client_.reset(new CefDelegatedFrameHostClient(this)); + delegated_frame_host_client_ = + std::make_unique(this); // Matching the attributes from BrowserCompositorMac. delegated_frame_host_ = std::make_unique( AllocateFrameSinkId(), delegated_frame_host_client_.get(), false /* should_register_frame_sink_id */); - root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); + root_layer_ = std::make_unique(ui::LAYER_SOLID_COLOR); bool opaque = SkColorGetA(background_color_) == SK_AlphaOPAQUE; GetRootLayer()->SetFillsBoundsOpaquely(opaque); @@ -238,10 +240,10 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( auto context_factory = content::GetContextFactory(); // Matching the attributes from RecyclableCompositorMac. - compositor_.reset(new ui::Compositor( + compositor_ = std::make_unique( context_factory->AllocateFrameSinkId(), context_factory, base::SingleThreadTaskRunner::GetCurrentDefault(), - false /* enable_pixel_canvas */, use_external_begin_frame)); + false /* enable_pixel_canvas */, use_external_begin_frame); compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); compositor_->SetDelegate(this); @@ -254,7 +256,7 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( render_widget_host_impl->SetCompositorForFlingScheduler(compositor_.get()); } - cursor_manager_.reset(new content::CursorManager(this)); + cursor_manager_ = std::make_unique(this); // This may result in a call to GetFrameSinkId(). render_widget_host_->SetView(this); @@ -395,7 +397,7 @@ void CefRenderWidgetHostViewOSR::ShowWithVisibility( if (!content::GpuDataManagerImpl::GetInstance()->IsGpuCompositingDisabled()) { // Start generating frames when we're visible and at the correct size. if (!video_consumer_) { - video_consumer_.reset(new CefVideoConsumerOSR(this)); + video_consumer_ = std::make_unique(this); UpdateFrameRate(); } else { video_consumer_->SetActive(true); @@ -805,12 +807,12 @@ void CefRenderWidgetHostViewOSR::ImeSetComposition( std::vector web_underlines; web_underlines.reserve(underlines.size()); for (const CefCompositionUnderline& line : underlines) { - web_underlines.push_back(ui::ImeTextSpan( + web_underlines.emplace_back( ui::ImeTextSpan::Type::kComposition, line.range.from, line.range.to, line.thick ? ui::ImeTextSpan::Thickness::kThick : ui::ImeTextSpan::Thickness::kThin, GetImeUnderlineStyle(line.style), line.background_color, line.color, - std::vector())); + std::vector()); } gfx::Range range(replacement_range.from, replacement_range.to); @@ -1571,8 +1573,8 @@ void CefRenderWidgetHostViewOSR::OnPaint(const gfx::Rect& damage_rect, rect_in_pixels.Intersect(damage_rect); CefRenderHandler::RectList rcList; - rcList.push_back(CefRect(rect_in_pixels.x(), rect_in_pixels.y(), - rect_in_pixels.width(), rect_in_pixels.height())); + rcList.emplace_back(rect_in_pixels.x(), rect_in_pixels.y(), + rect_in_pixels.width(), rect_in_pixels.height()); handler->OnPaint(browser_impl_.get(), IsPopupWidget() ? PET_POPUP : PET_VIEW, rcList, pixels, pixel_size.width(), pixel_size.height()); @@ -1816,8 +1818,7 @@ void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged( if (character_bounds.has_value()) { for (auto& rect : character_bounds.value()) { - rcList.push_back( - CefRect(rect.x(), rect.y(), rect.width(), rect.height())); + rcList.emplace_back(rect.x(), rect.y(), rect.width(), rect.height()); } } diff --git a/libcef/browser/osr/touch_selection_controller_client_osr.cc b/libcef/browser/osr/touch_selection_controller_client_osr.cc index 634e0f47a..7206c0ba4 100644 --- a/libcef/browser/osr/touch_selection_controller_client_osr.cc +++ b/libcef/browser/osr/touch_selection_controller_client_osr.cc @@ -46,7 +46,7 @@ class CefRunQuickMenuCallbackImpl : public CefRunQuickMenuCallback { CefRunQuickMenuCallbackImpl& operator=(const CefRunQuickMenuCallbackImpl&) = delete; - ~CefRunQuickMenuCallbackImpl() { + ~CefRunQuickMenuCallbackImpl() override { if (!callback_.is_null()) { // The callback is still pending. Cancel it now. if (CEF_CURRENTLY_ON_UIT()) { diff --git a/libcef/browser/osr/touch_selection_controller_client_osr.h b/libcef/browser/osr/touch_selection_controller_client_osr.h index 2ec8e9191..e1009bd57 100644 --- a/libcef/browser/osr/touch_selection_controller_client_osr.h +++ b/libcef/browser/osr/touch_selection_controller_client_osr.h @@ -120,7 +120,7 @@ class CefTouchSelectionControllerClientOSR class InternalClient final : public ui::TouchSelectionControllerClient { public: explicit InternalClient(CefRenderWidgetHostViewOSR* rwhv) : rwhv_(rwhv) {} - ~InternalClient() final {} + ~InternalClient() final = default; bool SupportsAnimation() const final; void SetNeedsAnimate() final; diff --git a/libcef/browser/osr/web_contents_view_osr.cc b/libcef/browser/osr/web_contents_view_osr.cc index d9a48986b..4e21c9136 100644 --- a/libcef/browser/osr/web_contents_view_osr.cc +++ b/libcef/browser/osr/web_contents_view_osr.cc @@ -20,10 +20,9 @@ CefWebContentsViewOSR::CefWebContentsViewOSR(SkColor background_color, bool use_external_begin_frame) : background_color_(background_color), use_shared_texture_(use_shared_texture), - use_external_begin_frame_(use_external_begin_frame), - web_contents_(nullptr) {} + use_external_begin_frame_(use_external_begin_frame) {} -CefWebContentsViewOSR::~CefWebContentsViewOSR() {} +CefWebContentsViewOSR::~CefWebContentsViewOSR() = default; void CefWebContentsViewOSR::WebContentsCreated( content::WebContents* web_contents) { diff --git a/libcef/browser/osr/web_contents_view_osr.h b/libcef/browser/osr/web_contents_view_osr.h index 8843ac613..b3577c542 100644 --- a/libcef/browser/osr/web_contents_view_osr.h +++ b/libcef/browser/osr/web_contents_view_osr.h @@ -85,12 +85,10 @@ class CefWebContentsViewOSR : public content::WebContentsView, content::RenderWidgetHostImpl* source_rwh) override; void UpdateDragOperation(ui::mojom::DragOperation operation, bool document_is_handling_drag) override; - virtual void GotFocus( - content::RenderWidgetHostImpl* render_widget_host) override; - virtual void LostFocus( - content::RenderWidgetHostImpl* render_widget_host) override; - virtual void TakeFocus(bool reverse) override; - virtual void FullscreenStateChanged(bool is_fullscreen) override {} + void GotFocus(content::RenderWidgetHostImpl* render_widget_host) override; + void LostFocus(content::RenderWidgetHostImpl* render_widget_host) override; + void TakeFocus(bool reverse) override; + void FullscreenStateChanged(bool is_fullscreen) override {} private: CefRenderWidgetHostViewOSR* GetView() const; @@ -101,7 +99,7 @@ class CefWebContentsViewOSR : public content::WebContentsView, const bool use_shared_texture_; const bool use_external_begin_frame_; - content::WebContents* web_contents_; + content::WebContents* web_contents_ = nullptr; }; #endif // CEF_LIBCEF_BROWSER_OSR_WEB_CONTENTS_VIEW_OSR_H_ diff --git a/libcef/browser/prefs/pref_store.cc b/libcef/browser/prefs/pref_store.cc index 0fb170bf2..e465893ad 100644 --- a/libcef/browser/prefs/pref_store.cc +++ b/libcef/browser/prefs/pref_store.cc @@ -10,14 +10,7 @@ #include "base/memory/ptr_util.h" #include "base/values.h" -CefPrefStore::CefPrefStore() - : read_only_(true), - read_success_(true), - read_error_(PersistentPrefStore::PREF_READ_ERROR_NONE), - block_async_read_(false), - pending_async_read_(false), - init_complete_(false), - committed_(true) {} +CefPrefStore::CefPrefStore() = default; bool CefPrefStore::GetValue(base::StringPiece key, const base::Value** value) const { @@ -214,4 +207,4 @@ void CefPrefStore::set_read_error( read_error_ = read_error; } -CefPrefStore::~CefPrefStore() {} +CefPrefStore::~CefPrefStore() = default; diff --git a/libcef/browser/prefs/pref_store.h b/libcef/browser/prefs/pref_store.h index c5dc4218c..92ea86409 100644 --- a/libcef/browser/prefs/pref_store.h +++ b/libcef/browser/prefs/pref_store.h @@ -47,9 +47,8 @@ class CefPrefStore : public PersistentPrefStore { PrefReadError GetReadError() const override; PersistentPrefStore::PrefReadError ReadPrefs() override; void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override; - virtual void CommitPendingWrite( - base::OnceClosure done_callback, - base::OnceClosure synchronous_done_callback) override; + void CommitPendingWrite(base::OnceClosure done_callback, + base::OnceClosure synchronous_done_callback) override; void SchedulePendingLossyWrites() override; void OnStoreDeletionFromDisk() override; @@ -90,26 +89,27 @@ class CefPrefStore : public PersistentPrefStore { PrefValueMap prefs_; // Flag that indicates if the PrefStore is read-only - bool read_only_; + bool read_only_ = true; // The result to pass to PrefStore::Observer::OnInitializationCompleted - bool read_success_; + bool read_success_ = true; // The result to return from ReadPrefs or ReadPrefsAsync. - PersistentPrefStore::PrefReadError read_error_; + PersistentPrefStore::PrefReadError read_error_ = + PersistentPrefStore::PREF_READ_ERROR_NONE; // Whether a call to ReadPrefsAsync should block. - bool block_async_read_; + bool block_async_read_ = false; // Whether there is a pending call to ReadPrefsAsync. - bool pending_async_read_; + bool pending_async_read_ = false; // Whether initialization has been completed. - bool init_complete_; + bool init_complete_ = false; // Whether the store contents have been committed to disk since the last // mutation. - bool committed_; + bool committed_ = true; std::unique_ptr error_delegate_; base::ObserverList::Unchecked observers_; diff --git a/libcef/browser/prefs/renderer_prefs.h b/libcef/browser/prefs/renderer_prefs.h index 7222d6ec7..096aff9ca 100644 --- a/libcef/browser/prefs/renderer_prefs.h +++ b/libcef/browser/prefs/renderer_prefs.h @@ -12,11 +12,9 @@ class CommandLinePrefStore; -namespace blink { -namespace web_pref { +namespace blink::web_pref { struct WebPreferences; } -} // namespace blink namespace content { class RenderViewHost; diff --git a/libcef/browser/print_settings_impl.cc b/libcef/browser/print_settings_impl.cc index b789c8ff1..8a8dda7f1 100644 --- a/libcef/browser/print_settings_impl.cc +++ b/libcef/browser/print_settings_impl.cc @@ -97,7 +97,7 @@ void CefPrintSettingsImpl::GetPageRanges(PageRangeList& ranges) { printing::PageRanges::const_iterator it = page_ranges.begin(); for (; it != page_ranges.end(); ++it) { const printing::PageRange& range = *it; - ranges.push_back(CefRange(range.from, range.to)); + ranges.emplace_back(range.from, range.to); } } diff --git a/libcef/browser/server_impl.cc b/libcef/browser/server_impl.cc index 4697d2e03..cc57d7481 100644 --- a/libcef/browser/server_impl.cc +++ b/libcef/browser/server_impl.cc @@ -4,6 +4,8 @@ #include "libcef/browser/server_impl.h" +#include + #include "libcef/browser/thread_util.h" #include "libcef/common/request_impl.h" #include "libcef/common/task_runner_impl.h" @@ -46,9 +48,10 @@ std::unique_ptr CreateUniqueString(const void* data, size_t data_size) { std::unique_ptr ptr; if (data && data_size > 0) { - ptr.reset(new std::string(static_cast(data), data_size)); + ptr = std::make_unique(static_cast(data), + data_size); } else { - ptr.reset(new std::string()); + ptr = std::make_unique(); } return ptr; } @@ -165,11 +168,11 @@ void CefServer::CreateServer(const CefString& address, // CefServerImpl struct CefServerImpl::ConnectionInfo { - ConnectionInfo() : is_websocket(false), is_websocket_pending(false) {} + ConnectionInfo() = default; // True if this connection is a WebSocket connection. - bool is_websocket; - bool is_websocket_pending; + bool is_websocket = false; + bool is_websocket_pending = false; }; CefServerImpl::CefServerImpl(CefRefPtr handler) @@ -569,7 +572,7 @@ void CefServerImpl::StartOnHandlerThread(const std::string& address, std::unique_ptr socket( new net::TCPServerSocket(nullptr, net::NetLogSource())); if (socket->ListenWithAddressAndPort(address, port, backlog) == net::OK) { - server_.reset(new net::HttpServer(std::move(socket), this)); + server_ = std::make_unique(std::move(socket), this); net::IPEndPoint ip_address; if (server_->GetLocalAddress(&ip_address) == net::OK) { diff --git a/libcef/browser/server_impl.h b/libcef/browser/server_impl.h index 693ab7831..57ab34d69 100644 --- a/libcef/browser/server_impl.h +++ b/libcef/browser/server_impl.h @@ -18,7 +18,7 @@ namespace base { class Thread; } -class CefServerImpl : public CefServer, net::HttpServer::Delegate { +class CefServerImpl : public CefServer, public net::HttpServer::Delegate { public: explicit CefServerImpl(CefRefPtr handler); diff --git a/libcef/browser/simple_menu_model_impl.cc b/libcef/browser/simple_menu_model_impl.cc index 82de3982f..47d6211dd 100644 --- a/libcef/browser/simple_menu_model_impl.cc +++ b/libcef/browser/simple_menu_model_impl.cc @@ -564,7 +564,7 @@ CefRefPtr CefSimpleMenuModelImpl::CreateNewSubMenu( } CefRefPtr new_impl = new CefSimpleMenuModelImpl( - model, delegate_, state_delegate_, is_owned, /*is_submodel=*/true); + model, delegate_, state_delegate_, is_owned, /*is_submenu=*/true); submenumap_.insert(std::make_pair(model, new_impl)); return new_impl; } diff --git a/libcef/browser/simple_menu_model_impl.h b/libcef/browser/simple_menu_model_impl.h index 00f348acf..3d1d15eca 100644 --- a/libcef/browser/simple_menu_model_impl.h +++ b/libcef/browser/simple_menu_model_impl.h @@ -27,7 +27,7 @@ class CefSimpleMenuModelImpl : public CefMenuModel { absl::optional accel) = 0; protected: - virtual ~StateDelegate() {} + virtual ~StateDelegate() = default; }; // |delegate| should be the same that was used to create |model|. diff --git a/libcef/browser/speech_recognition_manager_delegate.cc b/libcef/browser/speech_recognition_manager_delegate.cc index 1a7c669ac..75b054584 100644 --- a/libcef/browser/speech_recognition_manager_delegate.cc +++ b/libcef/browser/speech_recognition_manager_delegate.cc @@ -35,7 +35,8 @@ CefSpeechRecognitionManagerDelegate ::CefSpeechRecognitionManagerDelegate() { command_line->HasSwitch(switches::kEnableProfanityFilter); } -CefSpeechRecognitionManagerDelegate ::~CefSpeechRecognitionManagerDelegate() {} +CefSpeechRecognitionManagerDelegate ::~CefSpeechRecognitionManagerDelegate() = + default; void CefSpeechRecognitionManagerDelegate::OnRecognitionStart(int session_id) {} diff --git a/libcef/browser/ssl_host_state_delegate.cc b/libcef/browser/ssl_host_state_delegate.cc index 07111daed..a7aec8419 100644 --- a/libcef/browser/ssl_host_state_delegate.cc +++ b/libcef/browser/ssl_host_state_delegate.cc @@ -11,8 +11,8 @@ using content::SSLHostStateDelegate; namespace internal { -CertPolicy::CertPolicy() {} -CertPolicy::~CertPolicy() {} +CertPolicy::CertPolicy() = default; +CertPolicy::~CertPolicy() = default; // For an allowance, we consider a given |cert| to be a match to a saved // allowed cert if the |error| is an exact match to or subset of the errors @@ -36,9 +36,9 @@ void CertPolicy::Allow(const net::X509Certificate& cert, int error) { } // namespace internal -CefSSLHostStateDelegate::CefSSLHostStateDelegate() {} +CefSSLHostStateDelegate::CefSSLHostStateDelegate() = default; -CefSSLHostStateDelegate::~CefSSLHostStateDelegate() {} +CefSSLHostStateDelegate::~CefSSLHostStateDelegate() = default; void CefSSLHostStateDelegate::HostRanInsecureContent( const std::string& host, diff --git a/libcef/browser/ssl_info_impl.cc b/libcef/browser/ssl_info_impl.cc index 7c8812758..ca406cd3a 100644 --- a/libcef/browser/ssl_info_impl.cc +++ b/libcef/browser/ssl_info_impl.cc @@ -7,8 +7,7 @@ #include "net/cert/cert_status_flags.h" -CefSSLInfoImpl::CefSSLInfoImpl(const net::SSLInfo& value) - : cert_status_(CERT_STATUS_NONE) { +CefSSLInfoImpl::CefSSLInfoImpl(const net::SSLInfo& value) { cert_status_ = static_cast(value.cert_status); if (value.cert.get()) { cert_ = new CefX509CertificateImpl(value.cert); diff --git a/libcef/browser/ssl_info_impl.h b/libcef/browser/ssl_info_impl.h index 2179a0f98..62d410e58 100644 --- a/libcef/browser/ssl_info_impl.h +++ b/libcef/browser/ssl_info_impl.h @@ -23,7 +23,7 @@ class CefSSLInfoImpl : public CefSSLInfo { CefRefPtr GetX509Certificate() override; private: - cef_cert_status_t cert_status_; + cef_cert_status_t cert_status_ = CERT_STATUS_NONE; CefRefPtr cert_; IMPLEMENT_REFCOUNTING(CefSSLInfoImpl); diff --git a/libcef/browser/stream_impl.cc b/libcef/browser/stream_impl.cc index 0244a932d..cf6d31e3d 100644 --- a/libcef/browser/stream_impl.cc +++ b/libcef/browser/stream_impl.cc @@ -145,8 +145,7 @@ int CefFileWriter::Flush() { // CefBytesReader -CefBytesReader::CefBytesReader(void* data, int64_t datasize, bool copy) - : data_(nullptr), datasize_(0), copy_(false), offset_(0) { +CefBytesReader::CefBytesReader(void* data, int64_t datasize, bool copy) { SetData(data, datasize, copy); } @@ -228,8 +227,7 @@ void CefBytesReader::SetData(void* data, int64_t datasize, bool copy) { // CefBytesWriter -CefBytesWriter::CefBytesWriter(size_t grow) - : grow_(grow), datasize_(grow), offset_(0) { +CefBytesWriter::CefBytesWriter(size_t grow) : grow_(grow), datasize_(grow) { DCHECK(grow > 0); data_ = malloc(grow); DCHECK(data_ != nullptr); diff --git a/libcef/browser/stream_impl.h b/libcef/browser/stream_impl.h index d2a11cec2..880ceec82 100644 --- a/libcef/browser/stream_impl.h +++ b/libcef/browser/stream_impl.h @@ -73,10 +73,10 @@ class CefBytesReader : public CefStreamReader { size_t GetDataSize() { return offset_; } protected: - void* data_; - int64_t datasize_; - bool copy_; - int64_t offset_; + void* data_ = nullptr; + int64_t datasize_ = 0; + bool copy_ = false; + int64_t offset_ = 0; base::Lock lock_; @@ -105,7 +105,7 @@ class CefBytesWriter : public CefStreamWriter { size_t grow_; void* data_; int64_t datasize_; - int64_t offset_; + int64_t offset_ = 0; base::Lock lock_; diff --git a/libcef/browser/trace_subscriber.cc b/libcef/browser/trace_subscriber.cc index 1f6c0300f..24e381b59 100644 --- a/libcef/browser/trace_subscriber.cc +++ b/libcef/browser/trace_subscriber.cc @@ -55,8 +55,7 @@ class CefCompletionCallbackWrapper : public CefCompletionCallback { using content::TracingController; -CefTraceSubscriber::CefTraceSubscriber() - : collecting_trace_data_(false), weak_factory_(this) { +CefTraceSubscriber::CefTraceSubscriber() : weak_factory_(this) { CEF_REQUIRE_UIT(); } diff --git a/libcef/browser/trace_subscriber.h b/libcef/browser/trace_subscriber.h index 007b15e13..01d279104 100644 --- a/libcef/browser/trace_subscriber.h +++ b/libcef/browser/trace_subscriber.h @@ -29,7 +29,7 @@ class CefTraceSubscriber { void OnTracingFileResult(CefRefPtr callback, const base::FilePath& tracing_file); - bool collecting_trace_data_; + bool collecting_trace_data_ = false; base::WeakPtrFactory weak_factory_; }; diff --git a/libcef/browser/views/browser_view_impl.cc b/libcef/browser/views/browser_view_impl.cc index 8897cd117..7d15d05b9 100644 --- a/libcef/browser/views/browser_view_impl.cc +++ b/libcef/browser/views/browser_view_impl.cc @@ -4,6 +4,8 @@ #include "libcef/browser/views/browser_view_impl.h" +#include + #include "libcef/browser/browser_host_base.h" #include "libcef/browser/browser_util.h" #include "libcef/browser/chrome/views/chrome_browser_view.h" @@ -269,7 +271,7 @@ void CefBrowserViewImpl::SetPendingBrowserCreateParams( CefRefPtr extra_info, CefRefPtr request_context) { DCHECK(!pending_browser_create_params_); - pending_browser_create_params_.reset(new CefBrowserCreateParams()); + pending_browser_create_params_ = std::make_unique(); pending_browser_create_params_->MaybeSetWindowInfo(window_info); pending_browser_create_params_->client = client; pending_browser_create_params_->url = url; diff --git a/libcef/browser/views/browser_view_view.h b/libcef/browser/views/browser_view_view.h index ba0a51ae5..123da8f0d 100644 --- a/libcef/browser/views/browser_view_view.h +++ b/libcef/browser/views/browser_view_view.h @@ -46,7 +46,7 @@ class CefBrowserViewView virtual bool OnGestureEvent(ui::GestureEvent* event) = 0; protected: - virtual ~Delegate() {} + virtual ~Delegate() = default; }; // |cef_delegate| may be nullptr. diff --git a/libcef/browser/views/display_impl.cc b/libcef/browser/views/display_impl.cc index 43e5fda0f..e6262718e 100644 --- a/libcef/browser/views/display_impl.cc +++ b/libcef/browser/views/display_impl.cc @@ -47,8 +47,8 @@ void CefDisplay::GetAllDisplays(std::vector>& displays) { using DisplayVector = std::vector; DisplayVector vec = display::Screen::GetScreen()->GetAllDisplays(); - for (size_t i = 0; i < vec.size(); ++i) { - displays.push_back(new CefDisplayImpl(vec[i])); + for (const auto& i : vec) { + displays.push_back(new CefDisplayImpl(i)); } } diff --git a/libcef/browser/views/fill_layout_impl.cc b/libcef/browser/views/fill_layout_impl.cc index fa7bdf93e..1ed452b8a 100644 --- a/libcef/browser/views/fill_layout_impl.cc +++ b/libcef/browser/views/fill_layout_impl.cc @@ -14,7 +14,7 @@ CefRefPtr CefFillLayoutImpl::Create(views::View* owner_view) { return impl; } -CefFillLayoutImpl::CefFillLayoutImpl() {} +CefFillLayoutImpl::CefFillLayoutImpl() = default; views::FillLayout* CefFillLayoutImpl::CreateLayout() { return new views::FillLayout(); diff --git a/libcef/browser/views/layout_adapter.h b/libcef/browser/views/layout_adapter.h index 04a2d9029..ef479deaf 100644 --- a/libcef/browser/views/layout_adapter.h +++ b/libcef/browser/views/layout_adapter.h @@ -17,7 +17,7 @@ class LayoutManager; // usage overview. class CefLayoutAdapter { public: - CefLayoutAdapter() {} + CefLayoutAdapter() = default; // Returns the CefLayoutAdapter for the specified |layout|. static CefLayoutAdapter* GetFor(CefRefPtr layout); @@ -32,7 +32,7 @@ class CefLayoutAdapter { virtual void Detach() = 0; protected: - virtual ~CefLayoutAdapter() {} + virtual ~CefLayoutAdapter() = default; }; #endif // CEF_LIBCEF_BROWSER_VIEWS_LAYOUT_ADAPTER_H_ diff --git a/libcef/browser/views/layout_impl.h b/libcef/browser/views/layout_impl.h index 9bfd8e9a5..d2f2cd6ca 100644 --- a/libcef/browser/views/layout_impl.h +++ b/libcef/browser/views/layout_impl.h @@ -49,7 +49,7 @@ class CefLayoutImpl : public CefLayoutAdapter, public CefLayoutClass { protected: // Create a new implementation object. // Always call Initialize() after creation. - CefLayoutImpl() : layout_ref_(nullptr), owner_view_(nullptr) {} + CefLayoutImpl() = default; // Initialize this object and assign ownership to |owner_view|. void Initialize(views::View* owner_view) { @@ -67,11 +67,11 @@ class CefLayoutImpl : public CefLayoutAdapter, public CefLayoutClass { private: // Unowned reference to the views::LayoutManager wrapped by this object. Will // be nullptr after the views::LayoutManager is destroyed. - ViewsLayoutClass* layout_ref_; + ViewsLayoutClass* layout_ref_ = nullptr; // Unowned reference to the views::View that owns this object. Will be nullptr // after the views::LayoutManager is destroyed. - views::View* owner_view_; + views::View* owner_view_ = nullptr; }; #endif // CEF_LIBCEF_BROWSER_VIEWS_LAYOUT_IMPL_H_ diff --git a/libcef/browser/views/scroll_view_impl.h b/libcef/browser/views/scroll_view_impl.h index 47d47cfb2..38cb9badc 100644 --- a/libcef/browser/views/scroll_view_impl.h +++ b/libcef/browser/views/scroll_view_impl.h @@ -43,7 +43,7 @@ class CefScrollViewImpl // Create a new implementation object. // Always call Initialize() after creation. // |delegate| may be nullptr. - CefScrollViewImpl(CefRefPtr delegate); + explicit CefScrollViewImpl(CefRefPtr delegate); // CefViewImpl methods: CefScrollViewView* CreateRootView() override; diff --git a/libcef/browser/views/view_adapter.h b/libcef/browser/views/view_adapter.h index 958be7f71..2bdb7354d 100644 --- a/libcef/browser/views/view_adapter.h +++ b/libcef/browser/views/view_adapter.h @@ -19,7 +19,7 @@ class View; // usage overview. class CefViewAdapter { public: - CefViewAdapter() {} + CefViewAdapter() = default; // Returns the CefViewAdapter for the specified |view|. static CefViewAdapter* GetFor(CefRefPtr view); @@ -49,7 +49,7 @@ class CefViewAdapter { virtual void GetDebugInfo(base::Value::Dict* info, bool include_children) = 0; protected: - virtual ~CefViewAdapter() {} + virtual ~CefViewAdapter() = default; }; #endif // CEF_LIBCEF_BROWSER_VIEWS_VIEW_ADAPTER_H_ diff --git a/libcef/browser/views/window_impl.cc b/libcef/browser/views/window_impl.cc index 7f8092536..e7da97228 100644 --- a/libcef/browser/views/window_impl.cc +++ b/libcef/browser/views/window_impl.cc @@ -4,6 +4,8 @@ #include "libcef/browser/views/window_impl.h" +#include + #include "libcef/browser/browser_util.h" #include "libcef/browser/chrome/views/chrome_browser_frame.h" #include "libcef/browser/thread_util.h" @@ -538,11 +540,11 @@ void CefWindowImpl::ShowMenu(views::MenuButton* menu_button, // We'll send the MenuClosed notification manually for better accuracy. menu_model_->set_auto_notify_menu_closed(false); - menu_runner_.reset(new views::MenuRunner( + menu_runner_ = std::make_unique( menu_model_impl->model(), menu_button ? views::MenuRunner::HAS_MNEMONICS : views::MenuRunner::CONTEXT_MENU, - base::BindRepeating(&CefWindowImpl::MenuClosed, this))); + base::BindRepeating(&CefWindowImpl::MenuClosed, this)); menu_runner_->RunMenuAt( widget_, menu_button ? menu_button->button_controller() : nullptr, diff --git a/libcef/browser/views/window_view.cc b/libcef/browser/views/window_view.cc index f3cb5972f..eb7e0fd64 100644 --- a/libcef/browser/views/window_view.cc +++ b/libcef/browser/views/window_view.cc @@ -4,6 +4,8 @@ #include "libcef/browser/views/window_view.h" +#include + #if BUILDFLAG(IS_LINUX) #include "ui/ozone/buildflags.h" #if BUILDFLAG(OZONE_PLATFORM_X11) @@ -36,6 +38,7 @@ #if BUILDFLAG(IS_WIN) #include + #include "base/win/windows_version.h" #include "ui/display/win/screen_win.h" #include "ui/views/win/hwnd_util.h" @@ -104,7 +107,7 @@ class NativeFrameViewEx : public views::NativeFrameView { const DWORD style = GetWindowLong(window, GWL_STYLE); const DWORD ex_style = GetWindowLong(window, GWL_EXSTYLE); - const bool has_menu = !(style & WS_CHILD) && (GetMenu(window) != NULL); + const bool has_menu = !(style & WS_CHILD) && (GetMenu(window) != nullptr); // Convert from DIP to pixel coordinates using a method that can handle // multiple displays with different DPI. @@ -850,7 +853,7 @@ void CefWindowView::SetDraggableRegions( return; } - draggable_region_.reset(new SkRegion); + draggable_region_ = std::make_unique(); for (const CefDraggableRegion& region : regions) { draggable_region_->op( {region.bounds.x, region.bounds.y, @@ -859,8 +862,8 @@ void CefWindowView::SetDraggableRegions( region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); if (region.draggable) { - draggable_rects_.push_back({region.bounds.x, region.bounds.y, - region.bounds.width, region.bounds.height}); + draggable_rects_.emplace_back(region.bounds.x, region.bounds.y, + region.bounds.width, region.bounds.height); } } } diff --git a/libcef/browser/views/window_view.h b/libcef/browser/views/window_view.h index 1689878a7..14d27c46f 100644 --- a/libcef/browser/views/window_view.h +++ b/libcef/browser/views/window_view.h @@ -42,7 +42,7 @@ class CefWindowView virtual void OnWindowViewDeleted() = 0; protected: - virtual ~Delegate() {} + virtual ~Delegate() = default; }; // |cef_delegate| may be nullptr. diff --git a/libcef/browser/xml_reader_impl.cc b/libcef/browser/xml_reader_impl.cc index 40f38a9ab..8ba9a089b 100644 --- a/libcef/browser/xml_reader_impl.cc +++ b/libcef/browser/xml_reader_impl.cc @@ -118,8 +118,7 @@ CefString xmlCharToString(const xmlChar* xmlStr, bool free) { } // namespace CefXmlReaderImpl::CefXmlReaderImpl() - : supported_thread_id_(base::PlatformThread::CurrentId()), - reader_(nullptr) {} + : supported_thread_id_(base::PlatformThread::CurrentId()) {} CefXmlReaderImpl::~CefXmlReaderImpl() { if (reader_ != nullptr) { diff --git a/libcef/browser/xml_reader_impl.h b/libcef/browser/xml_reader_impl.h index eafa63f73..cecda7326 100644 --- a/libcef/browser/xml_reader_impl.h +++ b/libcef/browser/xml_reader_impl.h @@ -65,7 +65,7 @@ class CefXmlReaderImpl : public CefXmlReader { protected: base::PlatformThreadId supported_thread_id_; CefRefPtr stream_; - xmlTextReaderPtr reader_; + xmlTextReaderPtr reader_ = nullptr; std::stringstream error_buf_; IMPLEMENT_REFCOUNTING(CefXmlReaderImpl); diff --git a/libcef/browser/zip_reader_impl.cc b/libcef/browser/zip_reader_impl.cc index 32a59a786..6b7e5e423 100644 --- a/libcef/browser/zip_reader_impl.cc +++ b/libcef/browser/zip_reader_impl.cc @@ -78,12 +78,7 @@ int ZCALLBACK zlib_error_callback OF((voidpf opaque, voidpf stream)) { } // namespace CefZipReaderImpl::CefZipReaderImpl() - : supported_thread_id_(base::PlatformThread::CurrentId()), - reader_(nullptr), - has_fileopen_(false), - has_fileinfo_(false), - filesize_(0), - filemodified_(0) {} + : supported_thread_id_(base::PlatformThread::CurrentId()) {} CefZipReaderImpl::~CefZipReaderImpl() { if (reader_ != nullptr) { @@ -270,7 +265,7 @@ bool CefZipReaderImpl::GetFileInfo() { memset(&file_info, 0, sizeof(file_info)); if (unzGetCurrentFileInfo(reader_, &file_info, file_name, sizeof(file_name), - NULL, 0, NULL, 0) != UNZ_OK) { + nullptr, 0, nullptr, 0) != UNZ_OK) { return false; } diff --git a/libcef/browser/zip_reader_impl.h b/libcef/browser/zip_reader_impl.h index a50959d08..fd63ff818 100644 --- a/libcef/browser/zip_reader_impl.h +++ b/libcef/browser/zip_reader_impl.h @@ -42,12 +42,12 @@ class CefZipReaderImpl : public CefZipReader { protected: base::PlatformThreadId supported_thread_id_; - unzFile reader_; - bool has_fileopen_; - bool has_fileinfo_; + unzFile reader_ = nullptr; + bool has_fileopen_ = false; + bool has_fileinfo_ = false; CefString filename_; - int64_t filesize_; - time_t filemodified_; + int64_t filesize_ = 0; + time_t filemodified_ = 0; IMPLEMENT_REFCOUNTING(CefZipReaderImpl); }; diff --git a/libcef/common/alloy/alloy_main_delegate.cc b/libcef/common/alloy/alloy_main_delegate.cc index 57e1de932..9f397b94a 100644 --- a/libcef/common/alloy/alloy_main_delegate.cc +++ b/libcef/common/alloy/alloy_main_delegate.cc @@ -4,6 +4,7 @@ #include "libcef/common/alloy/alloy_main_delegate.h" +#include #include #include "libcef/browser/alloy/alloy_browser_context.h" @@ -128,7 +129,7 @@ AlloyMainDelegate::AlloyMainDelegate(CefMainRunnerHandler* runner, #endif } -AlloyMainDelegate::~AlloyMainDelegate() {} +AlloyMainDelegate::~AlloyMainDelegate() = default; std::optional AlloyMainDelegate::PreBrowserMain() { runner_->PreBrowserMain(); @@ -298,18 +299,16 @@ std::optional AlloyMainDelegate::BasicStartupComplete() { } else { std::vector added_items; if (settings_->log_items & LOG_ITEMS_FLAG_PROCESS_ID) { - added_items.push_back(base::StringPiece(switches::kLogItems_PId)); + added_items.emplace_back(switches::kLogItems_PId); } if (settings_->log_items & LOG_ITEMS_FLAG_THREAD_ID) { - added_items.push_back(base::StringPiece(switches::kLogItems_TId)); + added_items.emplace_back(switches::kLogItems_TId); } if (settings_->log_items & LOG_ITEMS_FLAG_TIME_STAMP) { - added_items.push_back( - base::StringPiece(switches::kLogItems_TimeStamp)); + added_items.emplace_back(switches::kLogItems_TimeStamp); } if (settings_->log_items & LOG_ITEMS_FLAG_TICK_COUNT) { - added_items.push_back( - base::StringPiece(switches::kLogItems_TickCount)); + added_items.emplace_back(switches::kLogItems_TickCount); } if (!added_items.empty()) { log_items_str = base::JoinString(added_items, ","); @@ -574,18 +573,18 @@ void AlloyMainDelegate::ZygoteForked() { #endif content::ContentBrowserClient* AlloyMainDelegate::CreateContentBrowserClient() { - browser_client_.reset(new AlloyContentBrowserClient); + browser_client_ = std::make_unique(); return browser_client_.get(); } content::ContentRendererClient* AlloyMainDelegate::CreateContentRendererClient() { - renderer_client_.reset(new AlloyContentRendererClient); + renderer_client_ = std::make_unique(); return renderer_client_.get(); } content::ContentUtilityClient* AlloyMainDelegate::CreateContentUtilityClient() { - utility_client_.reset(new ChromeContentUtilityClient); + utility_client_ = std::make_unique(); return utility_client_.get(); } @@ -692,7 +691,7 @@ void AlloyMainDelegate::InitializeResourceBundle() { auto module_handle = ::GetModuleHandle(CefAppManager::Get()->GetResourceDllName()); if (!module_handle) { - module_handle = ::GetModuleHandle(NULL); + module_handle = ::GetModuleHandle(nullptr); } ui::SetResourcesDataDLL(module_handle); diff --git a/libcef/common/cef_crash_report_upload_thread.cc b/libcef/common/cef_crash_report_upload_thread.cc index 1557ada35..36b94e7fe 100644 --- a/libcef/common/cef_crash_report_upload_thread.cc +++ b/libcef/common/cef_crash_report_upload_thread.cc @@ -19,7 +19,7 @@ CefCrashReportUploadThread::CefCrashReportUploadThread( : CrashReportUploadThread(database, url, options, std::move(callback)), max_uploads_(max_uploads) {} -CefCrashReportUploadThread::~CefCrashReportUploadThread() {} +CefCrashReportUploadThread::~CefCrashReportUploadThread() = default; void CefCrashReportUploadThread::ProcessPendingReports() { if (BackoffPending()) { diff --git a/libcef/common/cef_crash_report_upload_thread.h b/libcef/common/cef_crash_report_upload_thread.h index d0921ac08..4f4db673c 100644 --- a/libcef/common/cef_crash_report_upload_thread.h +++ b/libcef/common/cef_crash_report_upload_thread.h @@ -19,7 +19,7 @@ class CefCrashReportUploadThread : public crashpad::CrashReportUploadThread { CefCrashReportUploadThread& operator=(const CefCrashReportUploadThread&) = delete; - ~CefCrashReportUploadThread(); + ~CefCrashReportUploadThread() override; private: void ProcessPendingReports() override; diff --git a/libcef/common/crash_reporter_client.cc b/libcef/common/crash_reporter_client.cc index da8712804..c6cdf52c5 100644 --- a/libcef/common/crash_reporter_client.cc +++ b/libcef/common/crash_reporter_client.cc @@ -112,8 +112,8 @@ bool isInvalidFileCharacter(unsigned char c) { if (c < ' ' || c == 0x7F) { return true; } - for (size_t i = 0; i < sizeof(kInvalidFileChars); ++i) { - if (c == kInvalidFileChars[i]) { + for (char kInvalidFileChar : kInvalidFileChars) { + if (c == kInvalidFileChar) { return true; } } @@ -201,8 +201,7 @@ std::string sanitizePath(const std::string& s) { std::vector parts = base::SplitString(path, std::string() + kPathSep, base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); - for (size_t i = 0; i < parts.size(); ++i) { - std::string part = parts[i]; + for (auto part : parts) { if (part != "." && part != "..") { part = sanitizePathComponent(part); } @@ -371,8 +370,8 @@ bool GetDefaultCrashDumpLocation(std::wstring* crash_dir, #endif // OS_WIN -CefCrashReporterClient::CefCrashReporterClient() {} -CefCrashReporterClient::~CefCrashReporterClient() {} +CefCrashReporterClient::CefCrashReporterClient() = default; +CefCrashReporterClient::~CefCrashReporterClient() = default; // Be aware that logging is not initialized at the time this method is called. bool CefCrashReporterClient::ReadCrashConfigFile() { @@ -535,10 +534,10 @@ bool CefCrashReporterClient::ReadCrashConfigFile() { "Not enough storage for key map"); size_t offset = 0; - for (size_t i = 0; i < std::size(ids); ++i) { + for (auto& id : ids) { size_t length = std::min(map_keys.size() - offset, crashpad::Annotation::kValueMaxSize); - ids[i].Set(base::StringPiece(map_keys.data() + offset, length)); + id.Set(base::StringPiece(map_keys.data() + offset, length)); offset += length; if (offset >= map_keys.size()) { break; @@ -690,7 +689,7 @@ std::string CefCrashReporterClient::GetUploadUrl() { void CefCrashReporterClient::GetCrashOptionalArguments( std::vector* arguments) { if (!rate_limit_) { - arguments->push_back(std::string("--no-rate-limit")); + arguments->emplace_back("--no-rate-limit"); } if (max_uploads_ > 0) { diff --git a/libcef/common/crash_reporting.cc b/libcef/common/crash_reporting.cc index 927505804..e18fede70 100644 --- a/libcef/common/crash_reporting.cc +++ b/libcef/common/crash_reporting.cc @@ -162,8 +162,8 @@ bool IsBoringCEFSwitch(const std::string& flag) { size_t end = flag.find("="); size_t len = (end == std::string::npos) ? flag.length() - 2 : end - 2; - for (size_t i = 0; i < std::size(kIgnoreSwitches); ++i) { - if (flag.compare(2, len, kIgnoreSwitches[i]) == 0) { + for (auto kIgnoreSwitche : kIgnoreSwitches) { + if (flag.compare(2, len, kIgnoreSwitche) == 0) { return true; } } diff --git a/libcef/common/drag_data_impl.cc b/libcef/common/drag_data_impl.cc index f29474929..f07702498 100644 --- a/libcef/common/drag_data_impl.cc +++ b/libcef/common/drag_data_impl.cc @@ -198,8 +198,8 @@ void CefDragDataImpl::AddFile(const CefString& path, const CefString& display_name) { base::AutoLock lock_scope(lock_); CHECK_READONLY_RETURN_VOID(); - data_.filenames.push_back( - ui::FileInfo(base::FilePath(path), base::FilePath(display_name))); + data_.filenames.emplace_back(base::FilePath(path), + base::FilePath(display_name)); } void CefDragDataImpl::ClearFilenames() { diff --git a/libcef/common/extensions/chrome_generated_schemas.cc b/libcef/common/extensions/chrome_generated_schemas.cc index a89519ce5..b7b04055f 100644 --- a/libcef/common/extensions/chrome_generated_schemas.cc +++ b/libcef/common/extensions/chrome_generated_schemas.cc @@ -8,9 +8,7 @@ #include "chrome/common/extensions/api/generated_schemas.h" -namespace extensions { -namespace api { -namespace cef { +namespace extensions::api::cef { // static base::StringPiece ChromeGeneratedSchemas::Get(const std::string& name) { @@ -28,6 +26,4 @@ bool ChromeGeneratedSchemas::IsGenerated(std::string name) { return extensions::api::ChromeGeneratedSchemas::IsGenerated(name); } -} // namespace cef -} // namespace api -} // namespace extensions +} // namespace extensions::api::cef diff --git a/libcef/common/extensions/chrome_generated_schemas.h b/libcef/common/extensions/chrome_generated_schemas.h index dbb6bd727..cd8ea9d1b 100644 --- a/libcef/common/extensions/chrome_generated_schemas.h +++ b/libcef/common/extensions/chrome_generated_schemas.h @@ -14,9 +14,7 @@ #include "base/strings/string_piece.h" -namespace extensions { -namespace api { -namespace cef { +namespace extensions::api::cef { class ChromeGeneratedSchemas { public: @@ -27,8 +25,6 @@ class ChromeGeneratedSchemas { static base::StringPiece Get(const std::string& name); }; -} // namespace cef -} // namespace api -} // namespace extensions +} // namespace extensions::api::cef #endif // CEF_LIBCEF_COMMON_EXTENSIONS_CHROME_GENERATED_SCHEMAS_H_ diff --git a/libcef/common/extensions/extensions_api_provider.cc b/libcef/common/extensions/extensions_api_provider.cc index eb3767314..f977dbf4c 100644 --- a/libcef/common/extensions/extensions_api_provider.cc +++ b/libcef/common/extensions/extensions_api_provider.cc @@ -18,7 +18,7 @@ namespace extensions { -CefExtensionsAPIProvider::CefExtensionsAPIProvider() {} +CefExtensionsAPIProvider::CefExtensionsAPIProvider() = default; void CefExtensionsAPIProvider::AddAPIFeatures(FeatureProvider* provider) { AddCEFAPIFeatures(provider); diff --git a/libcef/common/extensions/extensions_client.cc b/libcef/common/extensions/extensions_client.cc index dfac52255..151cbcfb1 100644 --- a/libcef/common/extensions/extensions_client.cc +++ b/libcef/common/extensions/extensions_client.cc @@ -36,7 +36,7 @@ CefExtensionsClient::CefExtensionsClient() AddAPIProvider(std::make_unique()); } -CefExtensionsClient::~CefExtensionsClient() {} +CefExtensionsClient::~CefExtensionsClient() = default; void CefExtensionsClient::Initialize() {} diff --git a/libcef/common/main_runner_delegate.h b/libcef/common/main_runner_delegate.h index 2a433394c..9a3a0c83d 100644 --- a/libcef/common/main_runner_delegate.h +++ b/libcef/common/main_runner_delegate.h @@ -33,7 +33,7 @@ class CefMainRunnerDelegate { virtual void BeforeExecuteProcess(const CefMainArgs& args) {} virtual void AfterExecuteProcess() {} - virtual ~CefMainRunnerDelegate() {} + virtual ~CefMainRunnerDelegate() = default; }; #endif // CEF_LIBCEF_COMMON_MAIN_RUNNER_DELEGATE_H_ diff --git a/libcef/common/main_runner_handler.h b/libcef/common/main_runner_handler.h index 1314c72e5..fcb6a66c2 100644 --- a/libcef/common/main_runner_handler.h +++ b/libcef/common/main_runner_handler.h @@ -18,7 +18,7 @@ class CefMainRunnerHandler { content::MainFunctionParams main_function_params) = 0; protected: - virtual ~CefMainRunnerHandler() {} + virtual ~CefMainRunnerHandler() = default; }; #endif // CEF_LIBCEF_COMMON_MAIN_RUNNER_HANDLER_H_ diff --git a/libcef/common/net/http_header_utils.cc b/libcef/common/net/http_header_utils.cc index 60a7085de..498fc6e0b 100644 --- a/libcef/common/net/http_header_utils.cc +++ b/libcef/common/net/http_header_utils.cc @@ -17,10 +17,9 @@ namespace HttpHeaderUtils { std::string GenerateHeaders(const HeaderMap& map) { std::string headers; - for (HeaderMap::const_iterator header = map.begin(); header != map.end(); - ++header) { - const CefString& key = header->first; - const CefString& value = header->second; + for (const auto& header : map) { + const CefString& key = header.first; + const CefString& value = header.second; if (!key.empty()) { // Delimit with "\r\n". diff --git a/libcef/common/net/scheme_registration.cc b/libcef/common/net/scheme_registration.cc index 60f78fa54..f923acf5f 100644 --- a/libcef/common/net/scheme_registration.cc +++ b/libcef/common/net/scheme_registration.cc @@ -38,9 +38,7 @@ void AddInternalSchemes(content::ContentClient::Schemes* schemes) { // The |is_display_isolated| value is excluded here because it's registered // with Blink only. - for (size_t i = 0; i < sizeof(internal_schemes) / sizeof(internal_schemes[0]); - ++i) { - const auto& scheme = internal_schemes[i]; + for (const auto& scheme : internal_schemes) { if (scheme.is_standard) { schemes->standard_schemes.push_back(scheme.scheme_name); if (!scheme.is_local && !scheme.is_display_isolated) { @@ -81,8 +79,8 @@ bool IsInternalHandledScheme(const std::string& scheme) { url::kWssScheme, }; - for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) { - if (scheme == schemes[i]) { + for (auto& i : schemes) { + if (scheme == i) { return true; } } diff --git a/libcef/common/process_message_smr_impl.cc b/libcef/common/process_message_smr_impl.cc index 922b272d1..2cfe11473 100644 --- a/libcef/common/process_message_smr_impl.cc +++ b/libcef/common/process_message_smr_impl.cc @@ -12,7 +12,8 @@ namespace { class CefSharedMemoryRegionImpl final : public CefSharedMemoryRegion { public: - CefSharedMemoryRegionImpl(base::WritableSharedMemoryMapping&& mapping) + explicit CefSharedMemoryRegionImpl( + base::WritableSharedMemoryMapping&& mapping) : mapping_(std::move(mapping)) {} CefSharedMemoryRegionImpl(const CefSharedMemoryRegionImpl&) = delete; CefSharedMemoryRegionImpl& operator=(const CefSharedMemoryRegionImpl&) = @@ -91,4 +92,4 @@ CefRefPtr CefSharedProcessMessageBuilderImpl::Build() { // Invalidate mappping mapping_ = base::WritableSharedMemoryMapping(); return new CefProcessMessageSMRImpl(name_, std::move(region_)); -} \ No newline at end of file +} diff --git a/libcef/common/request_impl.cc b/libcef/common/request_impl.cc index 0244180be..b0c939b68 100644 --- a/libcef/common/request_impl.cc +++ b/libcef/common/request_impl.cc @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -790,7 +791,7 @@ void CefRequestImpl::Changed(uint8_t changes) { if (backup_on_change_) { if (!backup_) { - backup_.reset(new Backup()); + backup_ = std::make_unique(); } // Set the backup values if not already set. @@ -815,7 +816,7 @@ void CefRequestImpl::Changed(uint8_t changes) { } if ((changes & kChangedHeaderMap) && !(backup_->backups_ & kChangedHeaderMap)) { - backup_->headermap_.reset(new HeaderMap()); + backup_->headermap_ = std::make_unique(); if (!headermap_.empty()) { backup_->headermap_->insert(headermap_.begin(), headermap_.end()); } @@ -893,11 +894,7 @@ CefRefPtr CefPostData::Create() { // CefPostDataImpl ------------------------------------------------------------ -CefPostDataImpl::CefPostDataImpl() - : read_only_(false), - has_excluded_elements_(false), - track_changes_(false), - has_changes_(false) {} +CefPostDataImpl::CefPostDataImpl() = default; bool CefPostDataImpl::IsReadOnly() { base::AutoLock lock_scope(lock_); @@ -1054,11 +1051,7 @@ CefRefPtr CefPostDataElement::Create() { // CefPostDataElementImpl ----------------------------------------------------- -CefPostDataElementImpl::CefPostDataElementImpl() - : type_(PDE_TYPE_EMPTY), - read_only_(false), - track_changes_(false), - has_changes_(false) { +CefPostDataElementImpl::CefPostDataElementImpl() { memset(&data_, 0, sizeof(data_)); } diff --git a/libcef/common/request_impl.h b/libcef/common/request_impl.h index dadbfdef2..7d4753b58 100644 --- a/libcef/common/request_impl.h +++ b/libcef/common/request_impl.h @@ -211,16 +211,16 @@ class CefPostDataImpl : public CefPostData { ElementVector elements_; // True if this object is read-only. - bool read_only_; + bool read_only_ = false; // True if this object has excluded elements. - bool has_excluded_elements_; + bool has_excluded_elements_ = false; // True if this object should track changes. - bool track_changes_; + bool track_changes_ = false; // True if this object has changes. - bool has_changes_; + bool has_changes_ = false; mutable base::Lock lock_; @@ -256,7 +256,7 @@ class CefPostDataElementImpl : public CefPostDataElement { void Changed(); void Cleanup(); - Type type_; + Type type_ = PDE_TYPE_EMPTY; union { struct { void* bytes; @@ -266,13 +266,13 @@ class CefPostDataElementImpl : public CefPostDataElement { } data_; // True if this object is read-only. - bool read_only_; + bool read_only_ = false; // True if this object should track changes. - bool track_changes_; + bool track_changes_ = false; // True if this object has changes. - bool has_changes_; + bool has_changes_ = false; mutable base::Lock lock_; diff --git a/libcef/common/resource_bundle_delegate.h b/libcef/common/resource_bundle_delegate.h index 7c8acefba..1b91b5189 100644 --- a/libcef/common/resource_bundle_delegate.h +++ b/libcef/common/resource_bundle_delegate.h @@ -13,7 +13,7 @@ class AlloyContentClient; class CefResourceBundleDelegate : public ui::ResourceBundle::Delegate { public: - CefResourceBundleDelegate() {} + CefResourceBundleDelegate() = default; void set_pack_loading_disabled(bool val) { pack_loading_disabled_ = val; } bool pack_loading_disabled() const { return pack_loading_disabled_; } diff --git a/libcef/common/resource_bundle_impl.cc b/libcef/common/resource_bundle_impl.cc index 7af873b46..87c36f5b3 100644 --- a/libcef/common/resource_bundle_impl.cc +++ b/libcef/common/resource_bundle_impl.cc @@ -7,7 +7,7 @@ #include "base/memory/ref_counted_memory.h" #include "ui/base/resource/resource_bundle.h" -CefResourceBundleImpl::CefResourceBundleImpl() {} +CefResourceBundleImpl::CefResourceBundleImpl() = default; CefString CefResourceBundleImpl::GetLocalizedString(int string_id) { if (!ui::ResourceBundle::HasSharedInstance()) { diff --git a/libcef/common/response_impl.cc b/libcef/common/response_impl.cc index 2127045e6..8e4926148 100644 --- a/libcef/common/response_impl.cc +++ b/libcef/common/response_impl.cc @@ -34,8 +34,7 @@ CefRefPtr CefResponse::Create() { // CefResponseImpl ------------------------------------------------------------ -CefResponseImpl::CefResponseImpl() - : error_code_(ERR_NONE), status_code_(0), read_only_(false) {} +CefResponseImpl::CefResponseImpl() = default; bool CefResponseImpl::IsReadOnly() { base::AutoLock lock_scope(lock_); diff --git a/libcef/common/response_impl.h b/libcef/common/response_impl.h index 5dab4519b..7b4af61b3 100644 --- a/libcef/common/response_impl.h +++ b/libcef/common/response_impl.h @@ -52,14 +52,14 @@ class CefResponseImpl : public CefResponse { void SetReadOnly(bool read_only); protected: - cef_errorcode_t error_code_; - int status_code_; + cef_errorcode_t error_code_ = ERR_NONE; + int status_code_ = 0; CefString status_text_; CefString mime_type_; CefString charset_; CefString url_; HeaderMap header_map_; - bool read_only_; + bool read_only_ = false; base::Lock lock_; diff --git a/libcef/common/scheme_registrar_impl.cc b/libcef/common/scheme_registrar_impl.cc index e33e5020d..285373ad2 100644 --- a/libcef/common/scheme_registrar_impl.cc +++ b/libcef/common/scheme_registrar_impl.cc @@ -25,7 +25,7 @@ void AppendArray(const std::vector& source, } } // namespace -CefSchemeRegistrarImpl::CefSchemeRegistrarImpl() {} +CefSchemeRegistrarImpl::CefSchemeRegistrarImpl() = default; bool CefSchemeRegistrarImpl::AddCustomScheme(const CefString& scheme_name, int options) { diff --git a/libcef/common/string_list_impl.cc b/libcef/common/string_list_impl.cc index 5d6044d5e..1a3c01da6 100644 --- a/libcef/common/string_list_impl.cc +++ b/libcef/common/string_list_impl.cc @@ -40,7 +40,11 @@ CEF_EXPORT void cef_string_list_append(cef_string_list_t list, const cef_string_t* value) { DCHECK(list); StringList* impl = reinterpret_cast(list); - impl->push_back(CefString(value)); + if (value) { + impl->emplace_back(value->str, value->length, /*copy=*/true); + } else { + impl->emplace_back(); + } } CEF_EXPORT void cef_string_list_clear(cef_string_list_t list) { diff --git a/libcef/common/test/translator_test_impl.cc b/libcef/common/test/translator_test_impl.cc index 93a8d5e9b..0e4545a46 100644 --- a/libcef/common/test/translator_test_impl.cc +++ b/libcef/common/test/translator_test_impl.cc @@ -390,8 +390,8 @@ class CefTranslatorTestImpl : public CefTranslatorTest { return false; } val.clear(); - val.push_back(CefPoint(TEST_X_VAL, TEST_Y_VAL)); - val.push_back(CefPoint(TEST_X_VAL2, TEST_Y_VAL2)); + val.emplace_back(TEST_X_VAL, TEST_Y_VAL); + val.emplace_back(TEST_X_VAL2, TEST_Y_VAL2); return true; } diff --git a/libcef/common/thread_impl.cc b/libcef/common/thread_impl.cc index b08a64716..ef5ff5eb4 100644 --- a/libcef/common/thread_impl.cc +++ b/libcef/common/thread_impl.cc @@ -4,6 +4,8 @@ #include "libcef/common/thread_impl.h" +#include + #include "libcef/common/task_runner_impl.h" #include "base/functional/bind.h" @@ -41,7 +43,7 @@ CefRefPtr CefThread::CreateThread( return thread_impl; } -CefThreadImpl::CefThreadImpl() : thread_id_(kInvalidPlatformThreadId) {} +CefThreadImpl::CefThreadImpl() = default; CefThreadImpl::~CefThreadImpl() { if (thread_.get()) { @@ -67,7 +69,7 @@ bool CefThreadImpl::Create(const CefString& display_name, return false; } - thread_.reset(new base::Thread(display_name)); + thread_ = std::make_unique(display_name); base::Thread::Options options; diff --git a/libcef/common/thread_impl.h b/libcef/common/thread_impl.h index 49e0380e2..007d52455 100644 --- a/libcef/common/thread_impl.h +++ b/libcef/common/thread_impl.h @@ -17,7 +17,7 @@ class CefThreadImpl : public CefThread { CefThreadImpl(const CefThreadImpl&) = delete; CefThreadImpl& operator=(const CefThreadImpl&) = delete; - ~CefThreadImpl(); + ~CefThreadImpl() override; bool Create(const CefString& display_name, cef_thread_priority_t priority, @@ -33,7 +33,7 @@ class CefThreadImpl : public CefThread { private: std::unique_ptr thread_; - cef_platform_thread_id_t thread_id_; + cef_platform_thread_id_t thread_id_ = kInvalidPlatformThreadId; CefRefPtr thread_task_runner_; // TaskRunner for the owner thread. diff --git a/libcef/common/tracker.cc b/libcef/common/tracker.cc index 499f6d8bd..bb69a080b 100644 --- a/libcef/common/tracker.cc +++ b/libcef/common/tracker.cc @@ -6,9 +6,9 @@ // CefTrackNode implementation. -CefTrackNode::CefTrackNode() : track_next_(nullptr), track_prev_(nullptr) {} +CefTrackNode::CefTrackNode() = default; -CefTrackNode::~CefTrackNode() {} +CefTrackNode::~CefTrackNode() = default; void CefTrackNode::InsertTrackPrev(CefTrackNode* object) { if (track_prev_) { @@ -41,7 +41,7 @@ void CefTrackNode::RemoveTracking() { // CefTrackManager implementation. -CefTrackManager::CefTrackManager() : object_count_(0) {} +CefTrackManager::CefTrackManager() = default; CefTrackManager::~CefTrackManager() { DeleteAll(); diff --git a/libcef/common/tracker.h b/libcef/common/tracker.h index 84aad6286..1a01d9218 100644 --- a/libcef/common/tracker.h +++ b/libcef/common/tracker.h @@ -36,8 +36,8 @@ class CefTrackNode { void RemoveTracking(); private: - CefTrackNode* track_next_; - CefTrackNode* track_prev_; + CefTrackNode* track_next_ = nullptr; + CefTrackNode* track_prev_ = nullptr; friend class CefTrackManager; }; @@ -67,7 +67,7 @@ class CefTrackManager : public CefBaseRefCounted { private: CefTrackNode tracker_; - int object_count_; + int object_count_ = 0; base::Lock lock_; diff --git a/libcef/common/value_base.cc b/libcef/common/value_base.cc index 55989be0a..1e23f52e6 100644 --- a/libcef/common/value_base.cc +++ b/libcef/common/value_base.cc @@ -4,8 +4,7 @@ #include "libcef/common/value_base.h" -CefValueController::CefValueController() - : owner_value_(nullptr), owner_object_(nullptr) {} +CefValueController::CefValueController() = default; CefValueController::~CefValueController() { // Everything should already have been removed. diff --git a/libcef/common/value_base.h b/libcef/common/value_base.h index c860563d3..ce791ec43 100644 --- a/libcef/common/value_base.h +++ b/libcef/common/value_base.h @@ -24,7 +24,7 @@ class CefValueController // Implemented by a class controlled using the access controller. class Object { public: - virtual ~Object() {} + virtual ~Object() = default; // Called when the value has been removed. virtual void OnControlRemoved() = 0; @@ -128,8 +128,8 @@ class CefValueController private: // Owner object. - void* owner_value_; - Object* owner_object_; + void* owner_value_ = nullptr; + Object* owner_object_ = nullptr; // Map of reference objects. using ReferenceMap = std::map; @@ -144,7 +144,7 @@ class CefValueController // Thread-safe access control implementation. class CefValueControllerThreadSafe : public CefValueController { public: - explicit CefValueControllerThreadSafe() : locked_thread_id_(0) {} + explicit CefValueControllerThreadSafe() = default; CefValueControllerThreadSafe(const CefValueControllerThreadSafe&) = delete; CefValueControllerThreadSafe& operator=(const CefValueControllerThreadSafe&) = @@ -168,7 +168,7 @@ class CefValueControllerThreadSafe : public CefValueController { private: base::Lock lock_; - base::PlatformThreadId locked_thread_id_; + base::PlatformThreadId locked_thread_id_ = 0; }; // Non-thread-safe access control implementation. diff --git a/libcef/common/values_impl.cc b/libcef/common/values_impl.cc index a95d8f563..3efe8c97b 100644 --- a/libcef/common/values_impl.cc +++ b/libcef/common/values_impl.cc @@ -66,7 +66,7 @@ CefRefPtr CefValueImpl::GetOrCreateRefOrCopy( return new CefValueImpl(value->Clone()); } -CefValueImpl::CefValueImpl() {} +CefValueImpl::CefValueImpl() = default; CefValueImpl::CefValueImpl(base::Value value) { SetValue(std::move(value)); @@ -81,7 +81,7 @@ CefValueImpl::CefValueImpl(CefRefPtr value) CefValueImpl::CefValueImpl(CefRefPtr value) : list_value_(value) {} -CefValueImpl::~CefValueImpl() {} +CefValueImpl::~CefValueImpl() = default; void CefValueImpl::SetValue(base::Value value) { base::AutoLock lock_scope(lock_); diff --git a/libcef/renderer/alloy/alloy_content_renderer_client.cc b/libcef/renderer/alloy/alloy_content_renderer_client.cc index 308ac6da7..c04c085a8 100644 --- a/libcef/renderer/alloy/alloy_content_renderer_client.cc +++ b/libcef/renderer/alloy/alloy_content_renderer_client.cc @@ -5,6 +5,7 @@ #include "libcef/renderer/alloy/alloy_content_renderer_client.h" +#include #include #include "build/build_config.h" @@ -110,7 +111,7 @@ AlloyContentRendererClient::AlloyContentRendererClient() : main_entry_time_(base::TimeTicks::Now()), render_manager_(new CefRenderManager) { if (extensions::ExtensionsEnabled()) { - extensions_client_.reset(new extensions::CefExtensionsClient); + extensions_client_ = std::make_unique(); extensions::ExtensionsClient::Set(extensions_client_.get()); extensions_renderer_client_ = std::make_unique(this); @@ -119,7 +120,7 @@ AlloyContentRendererClient::AlloyContentRendererClient() } } -AlloyContentRendererClient::~AlloyContentRendererClient() {} +AlloyContentRendererClient::~AlloyContentRendererClient() = default; // static AlloyContentRendererClient* AlloyContentRendererClient::Get() { diff --git a/libcef/renderer/alloy/alloy_render_thread_observer.cc b/libcef/renderer/alloy/alloy_render_thread_observer.cc index 4828c826e..f8ecd431e 100644 --- a/libcef/renderer/alloy/alloy_render_thread_observer.cc +++ b/libcef/renderer/alloy/alloy_render_thread_observer.cc @@ -17,7 +17,7 @@ AlloyRenderThreadObserver::AlloyRenderThreadObserver() { net::NetModule::SetResourceProvider(NetResourceProvider); } -AlloyRenderThreadObserver::~AlloyRenderThreadObserver() {} +AlloyRenderThreadObserver::~AlloyRenderThreadObserver() = default; chrome::mojom::DynamicParamsPtr AlloyRenderThreadObserver::GetDynamicParams() const { diff --git a/libcef/renderer/blink_glue.cc b/libcef/renderer/blink_glue.cc index 632c98042..85dd25540 100644 --- a/libcef/renderer/blink_glue.cc +++ b/libcef/renderer/blink_glue.cc @@ -269,7 +269,8 @@ RegisterExecutionContextLifecycleStateObserver( class Registration : public CefObserverRegistration { public: - Registration(blink::Persistent observer) : observer_(observer) {} + explicit Registration(blink::Persistent observer) + : observer_(observer) {} private: blink::Persistent observer_; @@ -289,7 +290,7 @@ struct CefScriptForbiddenScope::Impl { CefScriptForbiddenScope::CefScriptForbiddenScope() : impl_(new Impl()) {} -CefScriptForbiddenScope::~CefScriptForbiddenScope() {} +CefScriptForbiddenScope::~CefScriptForbiddenScope() = default; bool ResponseWasCached(const blink::WebURLResponse& response) { return response.ToResourceResponse().WasCached(); diff --git a/libcef/renderer/browser_impl.cc b/libcef/renderer/browser_impl.cc index 94cbb0e1c..c393391db 100644 --- a/libcef/renderer/browser_impl.cc +++ b/libcef/renderer/browser_impl.cc @@ -5,6 +5,7 @@ #include "libcef/renderer/browser_impl.h" +#include #include #include @@ -281,7 +282,7 @@ CefBrowserImpl::CefBrowserImpl(blink::WebView* web_view, is_popup_(is_popup), is_windowless_(is_windowless) {} -CefBrowserImpl::~CefBrowserImpl() {} +CefBrowserImpl::~CefBrowserImpl() = default; CefRefPtr CefBrowserImpl::GetWebFrameImpl( blink::WebLocalFrame* frame) { @@ -419,8 +420,8 @@ void CefBrowserImpl::OnLoadingStateChange(bool isLoading) { load_handler->OnLoadingStateChange(this, isLoading, canGoBack, canGoForward); - last_loading_state_.reset( - new LoadingState(isLoading, canGoBack, canGoForward)); + last_loading_state_ = + std::make_unique(isLoading, canGoBack, canGoForward); } } } diff --git a/libcef/renderer/extensions/extensions_dispatcher_delegate.cc b/libcef/renderer/extensions/extensions_dispatcher_delegate.cc index 51d3751ef..e1e208a9f 100644 --- a/libcef/renderer/extensions/extensions_dispatcher_delegate.cc +++ b/libcef/renderer/extensions/extensions_dispatcher_delegate.cc @@ -11,9 +11,9 @@ namespace extensions { -CefExtensionsDispatcherDelegate::CefExtensionsDispatcherDelegate() {} +CefExtensionsDispatcherDelegate::CefExtensionsDispatcherDelegate() = default; -CefExtensionsDispatcherDelegate::~CefExtensionsDispatcherDelegate() {} +CefExtensionsDispatcherDelegate::~CefExtensionsDispatcherDelegate() = default; void CefExtensionsDispatcherDelegate::PopulateSourceMap( extensions::ResourceBundleSourceMap* source_map) {} diff --git a/libcef/renderer/extensions/extensions_renderer_client.cc b/libcef/renderer/extensions/extensions_renderer_client.cc index fb72409de..ec36d3ffa 100644 --- a/libcef/renderer/extensions/extensions_renderer_client.cc +++ b/libcef/renderer/extensions/extensions_renderer_client.cc @@ -43,7 +43,7 @@ CefExtensionsRendererClient::CefExtensionsRendererClient( AlloyContentRendererClient* alloy_content_renderer_client) : alloy_content_renderer_client_(alloy_content_renderer_client) {} -CefExtensionsRendererClient::~CefExtensionsRendererClient() {} +CefExtensionsRendererClient::~CefExtensionsRendererClient() = default; bool CefExtensionsRendererClient::IsIncognitoProcess() const { return alloy_content_renderer_client_->GetAlloyObserver() diff --git a/libcef/renderer/frame_impl.cc b/libcef/renderer/frame_impl.cc index cea76fa65..6f1d2ded0 100644 --- a/libcef/renderer/frame_impl.cc +++ b/libcef/renderer/frame_impl.cc @@ -68,7 +68,7 @@ CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser, int64_t frame_id) : browser_(browser), frame_(frame), frame_id_(frame_id) {} -CefFrameImpl::~CefFrameImpl() {} +CefFrameImpl::~CefFrameImpl() = default; bool CefFrameImpl::IsValid() { CEF_REQUIRE_RT_RETURN(false); @@ -436,8 +436,7 @@ void CefFrameImpl::ExecuteOnLocalFrame(const std::string& function_name, CEF_REQUIRE_RT_RETURN_VOID(); if (!context_created_) { - queued_context_actions_.push( - std::make_pair(function_name, std::move(action))); + queued_context_actions_.emplace(function_name, std::move(action)); MaybeInitializeScriptContext(); return; } @@ -623,8 +622,7 @@ void CefFrameImpl::SendToBrowserFrame(const std::string& function_name, if (browser_connection_state_ != ConnectionState::CONNECTION_ACKED) { // Queue actions until we're notified by the browser that it's ready to // handle them. - queued_browser_actions_.push( - std::make_pair(function_name, std::move(action))); + queued_browser_actions_.emplace(function_name, std::move(action)); return; } diff --git a/libcef/renderer/render_manager.h b/libcef/renderer/render_manager.h index 754ad2a82..83526f3ca 100644 --- a/libcef/renderer/render_manager.h +++ b/libcef/renderer/render_manager.h @@ -43,7 +43,7 @@ class CefRenderManager : public cef::mojom::RenderManager { CefRenderManager(const CefRenderManager&) = delete; CefRenderManager& operator=(const CefRenderManager&) = delete; - ~CefRenderManager(); + ~CefRenderManager() override; // Returns this singleton instance of this class. static CefRenderManager* Get(); diff --git a/libcef/renderer/v8_impl.cc b/libcef/renderer/v8_impl.cc index 29ded9b95..eed3f8f0f 100644 --- a/libcef/renderer/v8_impl.cc +++ b/libcef/renderer/v8_impl.cc @@ -7,6 +7,7 @@ #define _USE_MATH_DEFINES #include +#include #include #include "base/command_line.h" @@ -98,9 +99,7 @@ class CefV8IsolateManager { CefV8IsolateManager() : resetter_(&g_isolate_manager, this), isolate_(v8::Isolate::GetCurrent()), - task_runner_(CEF_RENDER_TASK_RUNNER()), - message_listener_registered_(false), - worker_id_(0) { + task_runner_(CEF_RENDER_TASK_RUNNER()) { DCHECK(isolate_); DCHECK(task_runner_.get()); } @@ -203,22 +202,21 @@ class CefV8IsolateManager { CefTrackManager global_manager_; // True if the message listener has been registered. - bool message_listener_registered_; + bool message_listener_registered_ = false; // Attributes associated with WebWorker threads. - int worker_id_; + int worker_id_ = 0; GURL worker_url_; }; class V8TrackObject : public CefTrackNode { public: - explicit V8TrackObject(v8::Isolate* isolate) - : isolate_(isolate), external_memory_(0) { + explicit V8TrackObject(v8::Isolate* isolate) : isolate_(isolate) { DCHECK(isolate_); isolate_->AdjustAmountOfExternalAllocatedMemory( static_cast(sizeof(V8TrackObject))); } - ~V8TrackObject() { + ~V8TrackObject() override { isolate_->AdjustAmountOfExternalAllocatedMemory( -static_cast(sizeof(V8TrackObject)) - external_memory_); } @@ -289,7 +287,7 @@ class V8TrackObject : public CefTrackNode { CefRefPtr interceptor_; CefRefPtr handler_; CefRefPtr user_data_; - int external_memory_; + int external_memory_ = 0; }; class V8TrackString : public CefTrackNode { @@ -312,7 +310,7 @@ class V8TrackArrayBuffer : public CefTrackNode { static_cast(sizeof(V8TrackArrayBuffer))); } - ~V8TrackArrayBuffer() { + ~V8TrackArrayBuffer() override { isolate_->AdjustAmountOfExternalAllocatedMemory( -static_cast(sizeof(V8TrackArrayBuffer))); } @@ -721,12 +719,7 @@ class ExtensionWrapper : public v8::Extension { class CefV8ExceptionImpl : public CefV8Exception { public: CefV8ExceptionImpl(v8::Local context, - v8::Local message) - : line_number_(0), - start_position_(0), - end_position_(0), - start_column_(0), - end_column_(0) { + v8::Local message) { if (message.IsEmpty()) { return; } @@ -768,11 +761,11 @@ class CefV8ExceptionImpl : public CefV8Exception { CefString message_; CefString source_line_; CefString script_; - int line_number_; - int start_position_; - int end_position_; - int start_column_; - int end_column_; + int line_number_ = 0; + int start_position_ = 0; + int end_position_ = 0; + int start_column_ = 0; + int end_column_ = 0; IMPLEMENT_REFCOUNTING(CefV8ExceptionImpl); }; @@ -1025,8 +1018,8 @@ bool CefV8ContextImpl::Enter() { if (!microtasks_scope_) { // Increment the MicrotasksScope recursion level. - microtasks_scope_.reset(new v8::MicrotasksScope( - isolate, microtask_queue_, v8::MicrotasksScope::kRunMicrotasks)); + microtasks_scope_ = std::make_unique( + isolate, microtask_queue_, v8::MicrotasksScope::kRunMicrotasks); } ++enter_count_; @@ -1144,9 +1137,7 @@ CefV8ValueImpl::Handle::Handle(v8::Isolate* isolate, CefTrackNode* tracker) : CefV8HandleBase(isolate, context), handle_(isolate, v), - tracker_(tracker), - should_persist_(false), - is_set_weak_(false) {} + tracker_(tracker) {} CefV8ValueImpl::Handle::~Handle() { DCHECK(BelongsToCurrentThread()); @@ -2688,7 +2679,7 @@ CefV8StackTraceImpl::CefV8StackTraceImpl(v8::Isolate* isolate, } } -CefV8StackTraceImpl::~CefV8StackTraceImpl() {} +CefV8StackTraceImpl::~CefV8StackTraceImpl() = default; bool CefV8StackTraceImpl::IsValid() { return true; @@ -2708,8 +2699,7 @@ CefRefPtr CefV8StackTraceImpl::GetFrame(int index) { // CefV8StackFrameImpl CefV8StackFrameImpl::CefV8StackFrameImpl(v8::Isolate* isolate, - v8::Local handle) - : line_number_(0), column_(0), is_eval_(false), is_constructor_(false) { + v8::Local handle) { if (handle.IsEmpty()) { return; } @@ -2723,7 +2713,7 @@ CefV8StackFrameImpl::CefV8StackFrameImpl(v8::Isolate* isolate, is_constructor_ = handle->IsConstructor(); } -CefV8StackFrameImpl::~CefV8StackFrameImpl() {} +CefV8StackFrameImpl::~CefV8StackFrameImpl() = default; bool CefV8StackFrameImpl::IsValid() { return true; diff --git a/libcef/renderer/v8_impl.h b/libcef/renderer/v8_impl.h index 11ff77aaf..1d4157a0a 100644 --- a/libcef/renderer/v8_impl.h +++ b/libcef/renderer/v8_impl.h @@ -42,7 +42,7 @@ void CefV8SetWorkerAttributes(int worker_id, const GURL& worker_url); // Used to detach handles when the associated context is released. class CefV8ContextState : public base::RefCounted { public: - CefV8ContextState() : valid_(true) {} + CefV8ContextState() = default; bool IsValid() { return valid_; } void Detach() { @@ -64,9 +64,9 @@ class CefV8ContextState : public base::RefCounted { private: friend class base::RefCounted; - ~CefV8ContextState() {} + ~CefV8ContextState() = default; - bool valid_; + bool valid_ = true; CefTrackManager track_manager_; }; @@ -327,10 +327,10 @@ class CefV8ValueImpl : public CefV8Value { CefTrackNode* tracker_; // True if the handle needs to persist due to it being passed into V8. - bool should_persist_; + bool should_persist_ = false; // True if the handle has been set as weak. - bool is_set_weak_; + bool is_set_weak_ = false; }; v8::Isolate* isolate_; @@ -407,10 +407,10 @@ class CefV8StackFrameImpl : public CefV8StackFrame { CefString script_name_; CefString script_name_or_source_url_; CefString function_name_; - int line_number_; - int column_; - bool is_eval_; - bool is_constructor_; + int line_number_ = 0; + int column_ = 0; + bool is_eval_ = false; + bool is_constructor_ = false; IMPLEMENT_REFCOUNTING(CefV8StackFrameImpl); };