diff --git a/chromium_src/chrome/browser/process_singleton.h b/chromium_src/chrome/browser/process_singleton.h index 2e1436846421..5f2f38dc1276 100644 --- a/chromium_src/chrome/browser/process_singleton.h +++ b/chromium_src/chrome/browser/process_singleton.h @@ -127,10 +127,11 @@ class ProcessSingleton { NotificationCallback notification_callback_; // Handler for notifications. #if defined(OS_WIN) - HWND remote_window_; // The HWND_MESSAGE of another browser. + HWND remote_window_ = nullptr; // The HWND_MESSAGE of another browser. base::win::MessageWindow window_; // The message-only window. - bool is_virtualized_; // Stuck inside Microsoft Softricity VM environment. - HANDLE lock_file_; + bool is_virtualized_ = + false; // Stuck inside Microsoft Softricity VM environment. + HANDLE lock_file_ = INVALID_HANDLE_VALUE; base::FilePath user_data_dir_; ShouldKillRemoteProcessCallback should_kill_remote_process_callback_; #elif defined(OS_POSIX) && !defined(OS_ANDROID) @@ -175,7 +176,7 @@ class ProcessSingleton { // because it posts messages between threads. class LinuxWatcher; scoped_refptr watcher_; - int sock_; + int sock_ = -1; bool listen_on_ready_ = false; #endif diff --git a/chromium_src/chrome/browser/process_singleton_posix.cc b/chromium_src/chrome/browser/process_singleton_posix.cc index ab74dcc6e198..6933d51e33ab 100644 --- a/chromium_src/chrome/browser/process_singleton_posix.cc +++ b/chromium_src/chrome/browser/process_singleton_posix.cc @@ -333,7 +333,7 @@ bool IsChromeProcess(pid_t pid) { // A helper class to hold onto a socket. class ScopedSocket { public: - ScopedSocket() : fd_(-1) { Reset(); } + ScopedSocket() { Reset(); } ~ScopedSocket() { Close(); } int fd() { return fd_; } void Reset() { @@ -347,7 +347,7 @@ class ScopedSocket { } private: - int fd_; + int fd_ = -1; }; // Returns a random string for uniquifying profile connections. @@ -473,10 +473,7 @@ class ProcessSingleton::LinuxWatcher SocketReader(ProcessSingleton::LinuxWatcher* parent, scoped_refptr ui_task_runner, int fd) - : parent_(parent), - ui_task_runner_(ui_task_runner), - fd_(fd), - bytes_read_(0) { + : parent_(parent), ui_task_runner_(ui_task_runner), fd_(fd) { DCHECK_CURRENTLY_ON(BrowserThread::IO); // Wait for reads. fd_watch_controller_ = base::FileDescriptorWatcher::WatchReadable( @@ -508,20 +505,20 @@ class ProcessSingleton::LinuxWatcher fd_watch_controller_; // The ProcessSingleton::LinuxWatcher that owns us. - ProcessSingleton::LinuxWatcher* const parent_; + ProcessSingleton::LinuxWatcher* const parent_ = nullptr; // A reference to the UI task runner. scoped_refptr ui_task_runner_; // The file descriptor we're reading. - const int fd_; + const int fd_ = -1; // Store the message in this buffer. char buf_[kMaxMessageLength]; // Tracks the number of bytes we've read in case we're getting partial // reads. - size_t bytes_read_; + size_t bytes_read_ = 0; base::OneShotTimer timer_; diff --git a/chromium_src/chrome/browser/process_singleton_win.cc b/chromium_src/chrome/browser/process_singleton_win.cc index 62bc6136665e..d1e115945c40 100644 --- a/chromium_src/chrome/browser/process_singleton_win.cc +++ b/chromium_src/chrome/browser/process_singleton_win.cc @@ -172,8 +172,6 @@ ProcessSingleton::ProcessSingleton( const base::FilePath& user_data_dir, const NotificationCallback& notification_callback) : notification_callback_(notification_callback), - is_virtualized_(false), - lock_file_(INVALID_HANDLE_VALUE), user_data_dir_(user_data_dir), should_kill_remote_process_callback_( base::BindRepeating(&TerminateAppWithError)) { diff --git a/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc b/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc index 0c419e06f6de..8a07829b2e2c 100644 --- a/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc +++ b/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc @@ -38,8 +38,7 @@ void GlobalMenuBarRegistrarX11::OnWindowUnmapped(x11::Window window) { live_windows_.erase(window); } -GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11() - : registrar_proxy_(nullptr) { +GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11() { // libdbusmenu uses the gio version of dbus; I tried using the code in dbus/, // but it looks like that's isn't sharing the bus name with the gio version, // even when |connection_type| is set to SHARED. diff --git a/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h b/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h index e04bf0bb2b9c..58990429028a 100644 --- a/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h +++ b/chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h @@ -48,7 +48,7 @@ class GlobalMenuBarRegistrarX11 { GObject*, GParamSpec*); - GDBusProxy* registrar_proxy_; + GDBusProxy* registrar_proxy_ = nullptr; // x11::Window which want to be registered, but haven't yet been because // we're waiting for the proxy to become available. diff --git a/shell/app/electron_crash_reporter_client.h b/shell/app/electron_crash_reporter_client.h index 354625508eb9..287a38ab942c 100644 --- a/shell/app/electron_crash_reporter_client.h +++ b/shell/app/electron_crash_reporter_client.h @@ -82,7 +82,7 @@ class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient { friend class base::NoDestructor; std::string upload_url_; - bool collect_stats_consent_; + bool collect_stats_consent_ = false; bool rate_limit_ = false; bool compress_uploads_ = false; std::map global_annotations_; diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index 4fd3f3c011ff..4540e50239c5 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -76,8 +76,7 @@ v8::Local ToBuffer(v8::Isolate* isolate, void* val, int size) { } // namespace BaseWindow::BaseWindow(v8::Isolate* isolate, - const gin_helper::Dictionary& options) - : weak_factory_(this) { + const gin_helper::Dictionary& options) { // The parent window. gin::Handle parent; if (options.Get("parent", &parent) && !parent.IsEmpty()) diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h index 0e05d7cd2c32..1876cc8137c7 100644 --- a/shell/browser/api/electron_api_base_window.h +++ b/shell/browser/api/electron_api_base_window.h @@ -274,7 +274,7 @@ class BaseWindow : public gin_helper::TrackableObject, // Reference to JS wrapper to prevent garbage collection. v8::Global self_ref_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; }; } // namespace api diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc index 6a6566facad0..587bfcfe0e59 100644 --- a/shell/browser/api/electron_api_browser_window.cc +++ b/shell/browser/api/electron_api_browser_window.cc @@ -32,7 +32,7 @@ namespace api { BrowserWindow::BrowserWindow(gin::Arguments* args, const gin_helper::Dictionary& options) - : BaseWindow(args->isolate(), options), weak_factory_(this) { + : BaseWindow(args->isolate(), options) { // Use options.webPreferences in WebContents. v8::Isolate* isolate = args->isolate(); gin_helper::Dictionary web_preferences = diff --git a/shell/browser/api/electron_api_browser_window.h b/shell/browser/api/electron_api_browser_window.h index a76badcfc992..495d582e1dd5 100644 --- a/shell/browser/api/electron_api_browser_window.h +++ b/shell/browser/api/electron_api_browser_window.h @@ -126,7 +126,7 @@ class BrowserWindow : public BaseWindow, v8::Global web_contents_; base::WeakPtr api_web_contents_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(BrowserWindow); }; diff --git a/shell/browser/api/electron_api_menu_mac.h b/shell/browser/api/electron_api_menu_mac.h index e09eba500695..5a1802563b28 100644 --- a/shell/browser/api/electron_api_menu_mac.h +++ b/shell/browser/api/electron_api_menu_mac.h @@ -47,7 +47,7 @@ class MenuMac : public Menu { // window ID -> open context menu std::map> popup_controllers_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(MenuMac); }; diff --git a/shell/browser/api/electron_api_menu_mac.mm b/shell/browser/api/electron_api_menu_mac.mm index a17462c0ee8d..bab36f6a6544 100644 --- a/shell/browser/api/electron_api_menu_mac.mm +++ b/shell/browser/api/electron_api_menu_mac.mm @@ -30,7 +30,7 @@ namespace electron { namespace api { -MenuMac::MenuMac(gin::Arguments* args) : Menu(args), weak_factory_(this) {} +MenuMac::MenuMac(gin::Arguments* args) : Menu(args) {} MenuMac::~MenuMac() = default; diff --git a/shell/browser/api/electron_api_menu_views.cc b/shell/browser/api/electron_api_menu_views.cc index 37da0bb5482b..447a6fbb96a5 100644 --- a/shell/browser/api/electron_api_menu_views.cc +++ b/shell/browser/api/electron_api_menu_views.cc @@ -17,7 +17,7 @@ namespace electron { namespace api { -MenuViews::MenuViews(gin::Arguments* args) : Menu(args), weak_factory_(this) {} +MenuViews::MenuViews(gin::Arguments* args) : Menu(args) {} MenuViews::~MenuViews() = default; diff --git a/shell/browser/api/electron_api_menu_views.h b/shell/browser/api/electron_api_menu_views.h index d323bdca9209..1637af2c8c41 100644 --- a/shell/browser/api/electron_api_menu_views.h +++ b/shell/browser/api/electron_api_menu_views.h @@ -36,7 +36,7 @@ class MenuViews : public Menu { // window ID -> open context menu std::map> menu_runners_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(MenuViews); }; diff --git a/shell/browser/api/electron_api_net_log.cc b/shell/browser/api/electron_api_net_log.cc index 68b04106e93b..f3fd006c861e 100644 --- a/shell/browser/api/electron_api_net_log.cc +++ b/shell/browser/api/electron_api_net_log.cc @@ -79,7 +79,7 @@ namespace api { gin::WrapperInfo NetLog::kWrapperInfo = {gin::kEmbedderNativeGin}; NetLog::NetLog(v8::Isolate* isolate, ElectronBrowserContext* browser_context) - : browser_context_(browser_context), weak_ptr_factory_(this) { + : browser_context_(browser_context) { file_task_runner_ = CreateFileTaskRunner(); } diff --git a/shell/browser/api/electron_api_net_log.h b/shell/browser/api/electron_api_net_log.h index 943eaf51268d..dddea7c20420 100644 --- a/shell/browser/api/electron_api_net_log.h +++ b/shell/browser/api/electron_api_net_log.h @@ -65,7 +65,7 @@ class NetLog : public gin::Wrappable { scoped_refptr file_task_runner_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(NetLog); }; diff --git a/shell/browser/api/electron_api_power_save_blocker.cc b/shell/browser/api/electron_api_power_save_blocker.cc index b94a52f78a57..34a11086d50d 100644 --- a/shell/browser/api/electron_api_power_save_blocker.cc +++ b/shell/browser/api/electron_api_power_save_blocker.cc @@ -45,8 +45,7 @@ namespace api { gin::WrapperInfo PowerSaveBlocker::kWrapperInfo = {gin::kEmbedderNativeGin}; PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate) - : current_lock_type_(device::mojom::WakeLockType::kPreventAppSuspension), - is_wake_lock_active_(false) {} + : current_lock_type_(device::mojom::WakeLockType::kPreventAppSuspension) {} PowerSaveBlocker::~PowerSaveBlocker() = default; diff --git a/shell/browser/api/electron_api_power_save_blocker.h b/shell/browser/api/electron_api_power_save_blocker.h index 2a5ad80afe94..055f6f12b044 100644 --- a/shell/browser/api/electron_api_power_save_blocker.h +++ b/shell/browser/api/electron_api_power_save_blocker.h @@ -44,7 +44,7 @@ class PowerSaveBlocker : public gin::Wrappable { device::mojom::WakeLockType current_lock_type_; // Whether the wake lock is currently active. - bool is_wake_lock_active_; + bool is_wake_lock_active_ = false; // Map from id to the corresponding blocker type for each request. using WakeLockTypeMap = std::map; diff --git a/shell/browser/api/electron_api_service_worker_context.cc b/shell/browser/api/electron_api_service_worker_context.cc index 28d244f41a4c..edf90f5a87f5 100644 --- a/shell/browser/api/electron_api_service_worker_context.cc +++ b/shell/browser/api/electron_api_service_worker_context.cc @@ -74,7 +74,7 @@ gin::WrapperInfo ServiceWorkerContext::kWrapperInfo = {gin::kEmbedderNativeGin}; ServiceWorkerContext::ServiceWorkerContext( v8::Isolate* isolate, ElectronBrowserContext* browser_context) - : browser_context_(browser_context), weak_ptr_factory_(this) { + : browser_context_(browser_context) { service_worker_context_ = content::BrowserContext::GetDefaultStoragePartition(browser_context_) ->GetServiceWorkerContext(); diff --git a/shell/browser/api/electron_api_service_worker_context.h b/shell/browser/api/electron_api_service_worker_context.h index e490627f6223..108073eafffb 100644 --- a/shell/browser/api/electron_api_service_worker_context.h +++ b/shell/browser/api/electron_api_service_worker_context.h @@ -52,7 +52,7 @@ class ServiceWorkerContext content::ServiceWorkerContext* service_worker_context_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContext); }; diff --git a/shell/browser/api/electron_api_system_preferences.h b/shell/browser/api/electron_api_system_preferences.h index cd73a51f1d6a..6f556ab71153 100644 --- a/shell/browser/api/electron_api_system_preferences.h +++ b/shell/browser/api/electron_api_system_preferences.h @@ -156,9 +156,9 @@ class SystemPreferences std::string current_color_; - bool invertered_color_scheme_; + bool invertered_color_scheme_ = false; - bool high_contrast_color_scheme_; + bool high_contrast_color_scheme_ = false; std::unique_ptr color_change_listener_; #endif diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 88d533a323ee..58f94e536a0f 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -617,11 +617,12 @@ WebContents::WebContents(v8::Isolate* isolate, id_(GetAllWebContents().Add(this)), devtools_file_system_indexer_(new DevToolsFileSystemIndexer), file_task_runner_( - base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})), + base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})) #if BUILDFLAG(ENABLE_PRINTING) - print_task_runner_(CreatePrinterHandlerTaskRunner()), + , + print_task_runner_(CreatePrinterHandlerTaskRunner()) #endif - weak_factory_(this) { +{ #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) // WebContents created by extension host will have valid ViewType set. extensions::ViewType view_type = extensions::GetViewType(web_contents); @@ -653,11 +654,12 @@ WebContents::WebContents(v8::Isolate* isolate, id_(GetAllWebContents().Add(this)), devtools_file_system_indexer_(new DevToolsFileSystemIndexer), file_task_runner_( - base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})), + base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})) #if BUILDFLAG(ENABLE_PRINTING) - print_task_runner_(CreatePrinterHandlerTaskRunner()), + , + print_task_runner_(CreatePrinterHandlerTaskRunner()) #endif - weak_factory_(this) { +{ DCHECK(type != Type::kRemote) << "Can't take ownership of a remote WebContents"; auto session = Session::CreateFrom(isolate, GetBrowserContext()); @@ -671,11 +673,12 @@ WebContents::WebContents(v8::Isolate* isolate, : id_(GetAllWebContents().Add(this)), devtools_file_system_indexer_(new DevToolsFileSystemIndexer), file_task_runner_( - base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})), + base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()})) #if BUILDFLAG(ENABLE_PRINTING) - print_task_runner_(CreatePrinterHandlerTaskRunner()), + , + print_task_runner_(CreatePrinterHandlerTaskRunner()) #endif - weak_factory_(this) { +{ // Read options. options.Get("backgroundThrottling", &background_throttling_); diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index 7a2bb4f4839a..e9cd064f66ca 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -787,7 +787,7 @@ class WebContents : public gin::Wrappable, service_manager::BinderRegistryWithArgs registry_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(WebContents); }; diff --git a/shell/browser/api/frame_subscriber.cc b/shell/browser/api/frame_subscriber.cc index 1eede1493251..3524a9ea4e07 100644 --- a/shell/browser/api/frame_subscriber.cc +++ b/shell/browser/api/frame_subscriber.cc @@ -26,8 +26,7 @@ FrameSubscriber::FrameSubscriber(content::WebContents* web_contents, bool only_dirty) : content::WebContentsObserver(web_contents), callback_(callback), - only_dirty_(only_dirty), - weak_ptr_factory_(this) { + only_dirty_(only_dirty) { content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); if (rvh) AttachToHost(rvh->GetWidget()); diff --git a/shell/browser/api/frame_subscriber.h b/shell/browser/api/frame_subscriber.h index 283b08aa55f3..8ab1cc756bad 100644 --- a/shell/browser/api/frame_subscriber.h +++ b/shell/browser/api/frame_subscriber.h @@ -67,7 +67,7 @@ class FrameSubscriber : public content::WebContentsObserver, content::RenderWidgetHost* host_; std::unique_ptr video_capturer_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(FrameSubscriber); }; diff --git a/shell/browser/electron_browser_context.cc b/shell/browser/electron_browser_context.cc index 4e8d65d0b654..b63d112000a5 100644 --- a/shell/browser/electron_browser_context.cc +++ b/shell/browser/electron_browser_context.cc @@ -102,12 +102,10 @@ ElectronBrowserContext::browser_context_map() { ElectronBrowserContext::ElectronBrowserContext(const std::string& partition, bool in_memory, base::DictionaryValue options) - : in_memory_pref_store_(nullptr), - storage_policy_(new SpecialStoragePolicy), + : storage_policy_(new SpecialStoragePolicy), protocol_registry_(new ProtocolRegistry), in_memory_(in_memory), - ssl_config_(network::mojom::SSLConfig::New()), - weak_factory_(this) { + ssl_config_(network::mojom::SSLConfig::New()) { user_agent_ = ElectronBrowserClient::Get()->GetUserAgent(); // Read options. diff --git a/shell/browser/electron_browser_context.h b/shell/browser/electron_browser_context.h index b2520a2734aa..ee7568573a05 100644 --- a/shell/browser/electron_browser_context.h +++ b/shell/browser/electron_browser_context.h @@ -165,7 +165,7 @@ class ElectronBrowserContext // Initialize pref registry. void InitPrefs(); - ValueMapPrefStore* in_memory_pref_store_; + ValueMapPrefStore* in_memory_pref_store_ = nullptr; std::unique_ptr resource_context_; std::unique_ptr cookie_change_notifier_; @@ -197,7 +197,7 @@ class ElectronBrowserContext network::mojom::SSLConfigPtr ssl_config_; mojo::Remote ssl_config_client_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(ElectronBrowserContext); }; diff --git a/shell/browser/electron_browser_handler_impl.cc b/shell/browser/electron_browser_handler_impl.cc index 1e8ac8f8f856..6da92ea41676 100644 --- a/shell/browser/electron_browser_handler_impl.cc +++ b/shell/browser/electron_browser_handler_impl.cc @@ -17,8 +17,7 @@ ElectronBrowserHandlerImpl::ElectronBrowserHandlerImpl( content::RenderFrameHost* frame_host, mojo::PendingReceiver receiver) : render_process_id_(frame_host->GetProcess()->GetID()), - render_frame_id_(frame_host->GetRoutingID()), - weak_factory_(this) { + render_frame_id_(frame_host->GetRoutingID()) { content::WebContents* web_contents = content::WebContents::FromRenderFrameHost(frame_host); DCHECK(web_contents); diff --git a/shell/browser/electron_browser_handler_impl.h b/shell/browser/electron_browser_handler_impl.h index d41513696dc3..4f8b9c0fa845 100644 --- a/shell/browser/electron_browser_handler_impl.h +++ b/shell/browser/electron_browser_handler_impl.h @@ -74,7 +74,7 @@ class ElectronBrowserHandlerImpl : public mojom::ElectronBrowser, mojo::Receiver receiver_{this}; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(ElectronBrowserHandlerImpl); }; diff --git a/shell/browser/electron_download_manager_delegate.cc b/shell/browser/electron_download_manager_delegate.cc index 58ee5f3c6029..4de6a6834540 100644 --- a/shell/browser/electron_download_manager_delegate.cc +++ b/shell/browser/electron_download_manager_delegate.cc @@ -52,7 +52,7 @@ base::FilePath CreateDownloadPath(const GURL& url, ElectronDownloadManagerDelegate::ElectronDownloadManagerDelegate( content::DownloadManager* manager) - : download_manager_(manager), weak_ptr_factory_(this) {} + : download_manager_(manager) {} ElectronDownloadManagerDelegate::~ElectronDownloadManagerDelegate() { if (download_manager_) { diff --git a/shell/browser/electron_download_manager_delegate.h b/shell/browser/electron_download_manager_delegate.h index 11c25ab464c8..09fbc8f62db9 100644 --- a/shell/browser/electron_download_manager_delegate.h +++ b/shell/browser/electron_download_manager_delegate.h @@ -53,7 +53,7 @@ class ElectronDownloadManagerDelegate gin_helper::Dictionary result); content::DownloadManager* download_manager_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(ElectronDownloadManagerDelegate); }; diff --git a/shell/browser/extensions/electron_extension_loader.cc b/shell/browser/extensions/electron_extension_loader.cc index b77d061ae499..3ef18839bb37 100644 --- a/shell/browser/extensions/electron_extension_loader.cc +++ b/shell/browser/extensions/electron_extension_loader.cc @@ -69,8 +69,7 @@ std::pair, std::string> LoadUnpacked( ElectronExtensionLoader::ElectronExtensionLoader( content::BrowserContext* browser_context) : browser_context_(browser_context), - extension_registrar_(browser_context, this), - weak_factory_(this) {} + extension_registrar_(browser_context, this) {} ElectronExtensionLoader::~ElectronExtensionLoader() = default; diff --git a/shell/browser/extensions/electron_extension_loader.h b/shell/browser/extensions/electron_extension_loader.h index 713eb0ae4c06..ed78d37015f6 100644 --- a/shell/browser/extensions/electron_extension_loader.h +++ b/shell/browser/extensions/electron_extension_loader.h @@ -90,7 +90,7 @@ class ElectronExtensionLoader : public ExtensionRegistrar::Delegate { // LoadExtensionForReload(). bool did_schedule_reload_ = false; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(ElectronExtensionLoader); }; diff --git a/shell/browser/extensions/electron_extension_system.cc b/shell/browser/extensions/electron_extension_system.cc index 911ff382ad9a..df64d0970022 100644 --- a/shell/browser/extensions/electron_extension_system.cc +++ b/shell/browser/extensions/electron_extension_system.cc @@ -49,8 +49,7 @@ namespace extensions { ElectronExtensionSystem::ElectronExtensionSystem( BrowserContext* browser_context) : browser_context_(browser_context), - store_factory_(new ValueStoreFactoryImpl(browser_context->GetPath())), - weak_factory_(this) {} + store_factory_(new ValueStoreFactoryImpl(browser_context->GetPath())) {} ElectronExtensionSystem::~ElectronExtensionSystem() = default; diff --git a/shell/browser/extensions/electron_extension_system.h b/shell/browser/extensions/electron_extension_system.h index e1f0d767be19..39f65dbee92c 100644 --- a/shell/browser/extensions/electron_extension_system.h +++ b/shell/browser/extensions/electron_extension_system.h @@ -113,7 +113,7 @@ class ElectronExtensionSystem : public ExtensionSystem { // Signaled when the extension system has completed its startup tasks. base::OneShotEvent ready_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(ElectronExtensionSystem); }; diff --git a/shell/browser/mac/in_app_purchase_observer.h b/shell/browser/mac/in_app_purchase_observer.h index 20130ae0723a..7e92bdebda43 100644 --- a/shell/browser/mac/in_app_purchase_observer.h +++ b/shell/browser/mac/in_app_purchase_observer.h @@ -53,7 +53,7 @@ class TransactionObserver { private: InAppTransactionObserver* observer_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(TransactionObserver); }; diff --git a/shell/browser/mac/in_app_purchase_observer.mm b/shell/browser/mac/in_app_purchase_observer.mm index fb9273313142..88875ace26be 100644 --- a/shell/browser/mac/in_app_purchase_observer.mm +++ b/shell/browser/mac/in_app_purchase_observer.mm @@ -182,7 +182,7 @@ Transaction::Transaction() = default; Transaction::Transaction(const Transaction&) = default; Transaction::~Transaction() = default; -TransactionObserver::TransactionObserver() : weak_ptr_factory_(this) { +TransactionObserver::TransactionObserver() { observer_ = [[InAppTransactionObserver alloc] initWithCallback:base::BindRepeating( &TransactionObserver::OnTransactionsUpdated, diff --git a/shell/browser/media/media_capture_devices_dispatcher.cc b/shell/browser/media/media_capture_devices_dispatcher.cc index e4d2ae084865..84a2ad677551 100644 --- a/shell/browser/media/media_capture_devices_dispatcher.cc +++ b/shell/browser/media/media_capture_devices_dispatcher.cc @@ -33,8 +33,7 @@ MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { return base::Singleton::get(); } -MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() - : is_device_enumeration_disabled_(false) { +MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() { // MediaCaptureDevicesDispatcher is a singleton. It should be created on // UI thread. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); diff --git a/shell/browser/media/media_capture_devices_dispatcher.h b/shell/browser/media/media_capture_devices_dispatcher.h index 8f0d827c5aa8..771a0a558102 100644 --- a/shell/browser/media/media_capture_devices_dispatcher.h +++ b/shell/browser/media/media_capture_devices_dispatcher.h @@ -80,7 +80,7 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { blink::MediaStreamDevices test_video_devices_; // Flag used by unittests to disable device enumeration. - bool is_device_enumeration_disabled_; + bool is_device_enumeration_disabled_ = false; DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); }; diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index 76b367d370ea..3b1d65b9b3e5 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -48,7 +48,7 @@ gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) { NativeWindow::NativeWindow(const gin_helper::Dictionary& options, NativeWindow* parent) - : widget_(new views::Widget), parent_(parent), weak_factory_(this) { + : widget_(new views::Widget), parent_(parent) { ++next_id_; options.Get(options::kFrame, &has_frame_); diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index bedc6437c614..b9ab07472bd9 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -382,7 +382,7 @@ class NativeWindow : public base::SupportsUserData, // Accessible title. base::string16 accessible_title_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(NativeWindow); }; diff --git a/shell/browser/net/node_stream_loader.cc b/shell/browser/net/node_stream_loader.cc index 5800485438b8..0c5c3343fe11 100644 --- a/shell/browser/net/node_stream_loader.cc +++ b/shell/browser/net/node_stream_loader.cc @@ -21,8 +21,7 @@ NodeStreamLoader::NodeStreamLoader( : binding_(this, std::move(loader)), client_(std::move(client)), isolate_(isolate), - emitter_(isolate, emitter), - weak_factory_(this) { + emitter_(isolate, emitter) { binding_.set_connection_error_handler( base::BindOnce(&NodeStreamLoader::NotifyComplete, weak_factory_.GetWeakPtr(), net::ERR_FAILED)); diff --git a/shell/browser/net/node_stream_loader.h b/shell/browser/net/node_stream_loader.h index a14ba0a6c804..118bf017eb12 100644 --- a/shell/browser/net/node_stream_loader.h +++ b/shell/browser/net/node_stream_loader.h @@ -95,7 +95,7 @@ class NodeStreamLoader : public network::mojom::URLLoader { // Store the V8 callbacks to unsubscribe them later. std::map> handlers_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(NodeStreamLoader); }; diff --git a/shell/browser/net/url_pipe_loader.cc b/shell/browser/net/url_pipe_loader.cc index 12bf6563da1f..a7ff48cdb812 100644 --- a/shell/browser/net/url_pipe_loader.cc +++ b/shell/browser/net/url_pipe_loader.cc @@ -19,9 +19,7 @@ URLPipeLoader::URLPipeLoader( mojo::PendingRemote client, const net::NetworkTrafficAnnotationTag& annotation, base::DictionaryValue upload_data) - : binding_(this, std::move(loader)), - client_(std::move(client)), - weak_factory_(this) { + : binding_(this, std::move(loader)), client_(std::move(client)) { binding_.set_connection_error_handler(base::BindOnce( &URLPipeLoader::NotifyComplete, base::Unretained(this), net::ERR_FAILED)); diff --git a/shell/browser/net/url_pipe_loader.h b/shell/browser/net/url_pipe_loader.h index 8101497c9ea3..79c1a4179d70 100644 --- a/shell/browser/net/url_pipe_loader.h +++ b/shell/browser/net/url_pipe_loader.h @@ -75,7 +75,7 @@ class URLPipeLoader : public network::mojom::URLLoader, std::unique_ptr producer_; std::unique_ptr loader_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(URLPipeLoader); }; diff --git a/shell/browser/notifications/linux/libnotify_notification.cc b/shell/browser/notifications/linux/libnotify_notification.cc index 27f7b43059e4..beaa8fecc4d1 100644 --- a/shell/browser/notifications/linux/libnotify_notification.cc +++ b/shell/browser/notifications/linux/libnotify_notification.cc @@ -75,7 +75,7 @@ bool LibnotifyNotification::Initialize() { LibnotifyNotification::LibnotifyNotification(NotificationDelegate* delegate, NotificationPresenter* presenter) - : Notification(delegate, presenter), notification_(nullptr) {} + : Notification(delegate, presenter) {} LibnotifyNotification::~LibnotifyNotification() { if (notification_) { diff --git a/shell/browser/notifications/linux/libnotify_notification.h b/shell/browser/notifications/linux/libnotify_notification.h index f3aa6ec6ff2b..b00c5bf60d1a 100644 --- a/shell/browser/notifications/linux/libnotify_notification.h +++ b/shell/browser/notifications/linux/libnotify_notification.h @@ -37,7 +37,7 @@ class LibnotifyNotification : public Notification { NotifyNotification*, char*); - NotifyNotification* notification_; + NotifyNotification* notification_ = nullptr; DISALLOW_COPY_AND_ASSIGN(LibnotifyNotification); }; diff --git a/shell/browser/notifications/notification.cc b/shell/browser/notifications/notification.cc index a7e9a3b44be6..0b8a3407e5e6 100644 --- a/shell/browser/notifications/notification.cc +++ b/shell/browser/notifications/notification.cc @@ -14,7 +14,7 @@ NotificationOptions::~NotificationOptions() = default; Notification::Notification(NotificationDelegate* delegate, NotificationPresenter* presenter) - : delegate_(delegate), presenter_(presenter), weak_factory_(this) {} + : delegate_(delegate), presenter_(presenter) {} Notification::~Notification() { if (delegate()) diff --git a/shell/browser/notifications/notification.h b/shell/browser/notifications/notification.h index e75ca2f4da75..28355cb46490 100644 --- a/shell/browser/notifications/notification.h +++ b/shell/browser/notifications/notification.h @@ -82,7 +82,7 @@ class Notification { NotificationPresenter* presenter_; std::string notification_id_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(Notification); }; diff --git a/shell/browser/osr/osr_render_widget_host_view.cc b/shell/browser/osr/osr_render_widget_host_view.cc index e2b4fdf4cb14..7c5651cd4663 100644 --- a/shell/browser/osr/osr_render_widget_host_view.cc +++ b/shell/browser/osr/osr_render_widget_host_view.cc @@ -182,11 +182,9 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( frame_rate_(frame_rate), size_(initial_size), painting_(painting), - is_showing_(false), cursor_manager_(new content::CursorManager(this)), mouse_wheel_phase_handler_(this), - backing_(new SkBitmap), - weak_ptr_factory_(this) { + backing_(new SkBitmap) { DCHECK(render_widget_host_); DCHECK(!render_widget_host_->GetView()); diff --git a/shell/browser/osr/osr_render_widget_host_view.h b/shell/browser/osr/osr_render_widget_host_view.h index 999a162a4069..ff7aa1eee787 100644 --- a/shell/browser/osr/osr_render_widget_host_view.h +++ b/shell/browser/osr/osr_render_widget_host_view.h @@ -280,7 +280,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, std::unique_ptr backing_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(OffScreenRenderWidgetHostView); }; diff --git a/shell/browser/osr/osr_video_consumer.cc b/shell/browser/osr/osr_video_consumer.cc index ab4487a91250..b87ef4a96620 100644 --- a/shell/browser/osr/osr_video_consumer.cc +++ b/shell/browser/osr/osr_video_consumer.cc @@ -18,8 +18,7 @@ OffScreenVideoConsumer::OffScreenVideoConsumer( OnPaintCallback callback) : callback_(callback), view_(view), - video_capturer_(view->CreateVideoCapturer()), - weak_ptr_factory_(this) { + video_capturer_(view->CreateVideoCapturer()) { video_capturer_->SetResolutionConstraints(view_->SizeInPixels(), view_->SizeInPixels(), true); video_capturer_->SetAutoThrottlingEnabled(false); diff --git a/shell/browser/osr/osr_video_consumer.h b/shell/browser/osr/osr_video_consumer.h index d275d3518382..bb9eab0e4414 100644 --- a/shell/browser/osr/osr_video_consumer.h +++ b/shell/browser/osr/osr_video_consumer.h @@ -48,7 +48,7 @@ class OffScreenVideoConsumer : public viz::mojom::FrameSinkVideoConsumer { OffScreenRenderWidgetHostView* view_; std::unique_ptr video_capturer_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(OffScreenVideoConsumer); }; diff --git a/shell/browser/osr/osr_web_contents_view.cc b/shell/browser/osr/osr_web_contents_view.cc index 1f089115d8c5..8c20818f911d 100644 --- a/shell/browser/osr/osr_web_contents_view.cc +++ b/shell/browser/osr/osr_web_contents_view.cc @@ -14,7 +14,7 @@ namespace electron { OffScreenWebContentsView::OffScreenWebContentsView( bool transparent, const OnPaintCallback& callback) - : native_window_(nullptr), transparent_(transparent), callback_(callback) { + : transparent_(transparent), callback_(callback) { #if defined(OS_MAC) PlatformCreate(); #endif diff --git a/shell/browser/osr/osr_web_contents_view.h b/shell/browser/osr/osr_web_contents_view.h index c1023b75f476..193080aacdb3 100644 --- a/shell/browser/osr/osr_web_contents_view.h +++ b/shell/browser/osr/osr_web_contents_view.h @@ -88,7 +88,7 @@ class OffScreenWebContentsView : public content::WebContentsView, OffScreenRenderWidgetHostView* GetView() const; - NativeWindow* native_window_; + NativeWindow* native_window_ = nullptr; const bool transparent_; bool painting_ = true; diff --git a/shell/browser/printing/print_preview_message_handler.cc b/shell/browser/printing/print_preview_message_handler.cc index f1728d1734b0..8f55e05f8b4b 100644 --- a/shell/browser/printing/print_preview_message_handler.cc +++ b/shell/browser/printing/print_preview_message_handler.cc @@ -53,7 +53,7 @@ void StopWorker(int document_cookie) { PrintPreviewMessageHandler::PrintPreviewMessageHandler( content::WebContents* web_contents) - : content::WebContentsObserver(web_contents), weak_ptr_factory_(this) { + : content::WebContentsObserver(web_contents) { DCHECK(web_contents); } diff --git a/shell/browser/printing/print_preview_message_handler.h b/shell/browser/printing/print_preview_message_handler.h index eb052430a45a..9f696d4ed6ce 100644 --- a/shell/browser/printing/print_preview_message_handler.h +++ b/shell/browser/printing/print_preview_message_handler.h @@ -96,7 +96,7 @@ class PrintPreviewMessageHandler mojo::AssociatedReceiver receiver_{this}; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; WEB_CONTENTS_USER_DATA_KEY_DECL(); diff --git a/shell/browser/ui/gtk/app_indicator_icon.cc b/shell/browser/ui/gtk/app_indicator_icon.cc index 2f5db6f77005..7064c5b4ef0f 100644 --- a/shell/browser/ui/gtk/app_indicator_icon.cc +++ b/shell/browser/ui/gtk/app_indicator_icon.cc @@ -158,7 +158,7 @@ namespace gtkui { AppIndicatorIcon::AppIndicatorIcon(std::string id, const gfx::ImageSkia& image, const base::string16& tool_tip) - : id_(id), icon_(nullptr), menu_model_(nullptr), icon_change_count_(0) { + : id_(id) { std::unique_ptr env(base::Environment::Create()); desktop_env_ = base::nix::GetDesktopEnvironment(env.get()); diff --git a/shell/browser/ui/gtk/app_indicator_icon.h b/shell/browser/ui/gtk/app_indicator_icon.h index 4cf1951187c2..7aa023919342 100644 --- a/shell/browser/ui/gtk/app_indicator_icon.h +++ b/shell/browser/ui/gtk/app_indicator_icon.h @@ -96,13 +96,13 @@ class AppIndicatorIcon : public views::StatusIconLinux { base::nix::DesktopEnvironment desktop_env_; // Gtk status icon wrapper - AppIndicator* icon_; + AppIndicator* icon_ = nullptr; std::unique_ptr menu_; - ui::MenuModel* menu_model_; + ui::MenuModel* menu_model_ = nullptr; base::FilePath temp_dir_; - int icon_change_count_; + int icon_change_count_ = 0; base::WeakPtrFactory weak_factory_{this}; diff --git a/shell/browser/ui/gtk/app_indicator_icon_menu.cc b/shell/browser/ui/gtk/app_indicator_icon_menu.cc index e9f9ee3912d8..8f74749bddf9 100644 --- a/shell/browser/ui/gtk/app_indicator_icon_menu.cc +++ b/shell/browser/ui/gtk/app_indicator_icon_menu.cc @@ -16,10 +16,7 @@ namespace electron { namespace gtkui { AppIndicatorIconMenu::AppIndicatorIconMenu(ui::MenuModel* model) - : menu_model_(model), - click_action_replacement_menu_item_added_(false), - gtk_menu_(nullptr), - block_activation_(false) { + : menu_model_(model) { { ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/378770 gtk_menu_ = gtk_menu_new(); diff --git a/shell/browser/ui/gtk/app_indicator_icon_menu.h b/shell/browser/ui/gtk/app_indicator_icon_menu.h index 7c0146114f12..d7f25bf9dd09 100644 --- a/shell/browser/ui/gtk/app_indicator_icon_menu.h +++ b/shell/browser/ui/gtk/app_indicator_icon_menu.h @@ -54,16 +54,16 @@ class AppIndicatorIconMenu { ui::MenuModel* menu_model_; // Whether a "click action replacement" menu item has been added to the menu. - bool click_action_replacement_menu_item_added_; + bool click_action_replacement_menu_item_added_ = false; // Called when the click action replacement menu item is activated. When a // menu item from |menu_model_| is activated, MenuModel::ActivatedAt() is // invoked and is assumed to do any necessary processing. base::Closure click_action_replacement_callback_; - GtkWidget* gtk_menu_; + GtkWidget* gtk_menu_ = nullptr; - bool block_activation_; + bool block_activation_ = false; DISALLOW_COPY_AND_ASSIGN(AppIndicatorIconMenu); }; diff --git a/shell/browser/ui/inspectable_web_contents.cc b/shell/browser/ui/inspectable_web_contents.cc index 6a94bd8effcc..041de4ffe400 100644 --- a/shell/browser/ui/inspectable_web_contents.cc +++ b/shell/browser/ui/inspectable_web_contents.cc @@ -337,14 +337,10 @@ InspectableWebContents::InspectableWebContents( content::WebContents* web_contents, PrefService* pref_service, bool is_guest) - : frontend_loaded_(false), - can_dock_(true), - delegate_(nullptr), - pref_service_(pref_service), + : pref_service_(pref_service), web_contents_(web_contents), is_guest_(is_guest), - view_(CreateInspectableContentsView(this)), - weak_factory_(this) { + view_(CreateInspectableContentsView(this)) { const base::Value* bounds_dict = pref_service_->Get(kDevToolsBoundsPref); if (bounds_dict->is_dict()) { devtools_bounds_ = DictionaryToRect(bounds_dict); diff --git a/shell/browser/ui/inspectable_web_contents.h b/shell/browser/ui/inspectable_web_contents.h index fcf39b6d7c12..f49179815859 100644 --- a/shell/browser/ui/inspectable_web_contents.h +++ b/shell/browser/ui/inspectable_web_contents.h @@ -201,7 +201,7 @@ class InspectableWebContents void AddDevToolsExtensionsToClient(); #endif - bool frontend_loaded_; + bool frontend_loaded_ = false; scoped_refptr agent_host_; std::unique_ptr frontend_host_; std::unique_ptr @@ -209,11 +209,11 @@ class InspectableWebContents DevToolsContentsResizingStrategy contents_resizing_strategy_; gfx::Rect devtools_bounds_; - bool can_dock_; + bool can_dock_ = true; std::string dock_state_; bool activate_ = true; - InspectableWebContentsDelegate* delegate_; // weak references. + InspectableWebContentsDelegate* delegate_ = nullptr; // weak references. PrefService* pref_service_; // weak reference. @@ -235,7 +235,7 @@ class InspectableWebContents using ExtensionsAPIs = std::map; ExtensionsAPIs extensions_api_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(InspectableWebContents); }; diff --git a/shell/browser/ui/inspectable_web_contents_view.h b/shell/browser/ui/inspectable_web_contents_view.h index 3c2f44f22338..4fbd3d7fd849 100644 --- a/shell/browser/ui/inspectable_web_contents_view.h +++ b/shell/browser/ui/inspectable_web_contents_view.h @@ -23,7 +23,7 @@ class InspectableWebContentsViewDelegate; class InspectableWebContentsView { public: - InspectableWebContentsView() : delegate_(nullptr) {} + InspectableWebContentsView() {} virtual ~InspectableWebContentsView() {} // The delegate manages its own life. @@ -54,7 +54,7 @@ class InspectableWebContentsView { virtual void SetTitle(const base::string16& title) = 0; private: - InspectableWebContentsViewDelegate* delegate_; // weak references. + InspectableWebContentsViewDelegate* delegate_ = nullptr; // weak references. }; } // namespace electron diff --git a/shell/browser/ui/tray_icon_cocoa.h b/shell/browser/ui/tray_icon_cocoa.h index 5afe8277c9f7..a2540c9c0e9e 100644 --- a/shell/browser/ui/tray_icon_cocoa.h +++ b/shell/browser/ui/tray_icon_cocoa.h @@ -43,7 +43,7 @@ class TrayIconCocoa : public TrayIcon { // Status menu shown when right-clicking the system icon. base::scoped_nsobject menu_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa); }; diff --git a/shell/browser/ui/tray_icon_cocoa.mm b/shell/browser/ui/tray_icon_cocoa.mm index 589620efc622..21e2cb346554 100644 --- a/shell/browser/ui/tray_icon_cocoa.mm +++ b/shell/browser/ui/tray_icon_cocoa.mm @@ -315,7 +315,7 @@ namespace electron { -TrayIconCocoa::TrayIconCocoa() : weak_factory_(this) { +TrayIconCocoa::TrayIconCocoa() { status_item_view_.reset([[StatusItemView alloc] initWithIcon:this]); } diff --git a/shell/browser/ui/views/autofill_popup_view.cc b/shell/browser/ui/views/autofill_popup_view.cc index 4cbc3963287b..99ba0d9f9962 100644 --- a/shell/browser/ui/views/autofill_popup_view.cc +++ b/shell/browser/ui/views/autofill_popup_view.cc @@ -31,7 +31,7 @@ void AutofillPopupChildView::GetAccessibleNodeData(ui::AXNodeData* node_data) { AutofillPopupView::AutofillPopupView(AutofillPopup* popup, views::Widget* parent_widget) - : popup_(popup), parent_widget_(parent_widget), weak_ptr_factory_(this) { + : popup_(popup), parent_widget_(parent_widget) { CreateChildViews(); SetFocusBehavior(FocusBehavior::ALWAYS); set_drag_controller(this); diff --git a/shell/browser/ui/views/autofill_popup_view.h b/shell/browser/ui/views/autofill_popup_view.h index bdc8fbd81a5b..c6e0da1d457d 100644 --- a/shell/browser/ui/views/autofill_popup_view.h +++ b/shell/browser/ui/views/autofill_popup_view.h @@ -147,7 +147,7 @@ class AutofillPopupView : public views::WidgetDelegateView, // key presses content::RenderWidgetHost::KeyPressEventCallback keypress_callback_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; }; } // namespace electron diff --git a/shell/browser/ui/views/inspectable_web_contents_view_views.cc b/shell/browser/ui/views/inspectable_web_contents_view_views.cc index 381d425366cb..cbeab44decf7 100644 --- a/shell/browser/ui/views/inspectable_web_contents_view_views.cc +++ b/shell/browser/ui/views/inspectable_web_contents_view_views.cc @@ -81,11 +81,7 @@ InspectableWebContentsView* CreateInspectableContentsView( InspectableWebContentsViewViews::InspectableWebContentsViewViews( InspectableWebContents* inspectable_web_contents) : inspectable_web_contents_(inspectable_web_contents), - devtools_window_web_view_(nullptr), - contents_web_view_(nullptr), devtools_web_view_(new views::WebView(nullptr)), - devtools_visible_(false), - devtools_window_delegate_(nullptr), title_(base::ASCIIToUTF16("Developer Tools")) { if (!inspectable_web_contents_->IsGuest() && inspectable_web_contents_->GetWebContents()->GetNativeView()) { diff --git a/shell/browser/ui/views/inspectable_web_contents_view_views.h b/shell/browser/ui/views/inspectable_web_contents_view_views.h index 16a2fa8b1957..69864f96bb1c 100644 --- a/shell/browser/ui/views/inspectable_web_contents_view_views.h +++ b/shell/browser/ui/views/inspectable_web_contents_view_views.h @@ -55,13 +55,13 @@ class InspectableWebContentsViewViews : public InspectableWebContentsView, InspectableWebContents* inspectable_web_contents_; std::unique_ptr devtools_window_; - views::WebView* devtools_window_web_view_; - views::View* contents_web_view_; - views::WebView* devtools_web_view_; + views::WebView* devtools_window_web_view_ = nullptr; + views::View* contents_web_view_ = nullptr; + views::WebView* devtools_web_view_ = nullptr; DevToolsContentsResizingStrategy strategy_; - bool devtools_visible_; - views::WidgetDelegate* devtools_window_delegate_; + bool devtools_visible_ = false; + views::WidgetDelegate* devtools_window_delegate_ = nullptr; base::string16 title_; DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewViews); diff --git a/shell/browser/ui/views/menu_delegate.cc b/shell/browser/ui/views/menu_delegate.cc index b5a19de61828..e2988ec6f77a 100644 --- a/shell/browser/ui/views/menu_delegate.cc +++ b/shell/browser/ui/views/menu_delegate.cc @@ -18,8 +18,7 @@ namespace electron { -MenuDelegate::MenuDelegate(MenuBar* menu_bar) - : menu_bar_(menu_bar), id_(-1), hold_first_switch_(false) {} +MenuDelegate::MenuDelegate(MenuBar* menu_bar) : menu_bar_(menu_bar) {} MenuDelegate::~MenuDelegate() = default; diff --git a/shell/browser/ui/views/menu_delegate.h b/shell/browser/ui/views/menu_delegate.h index 73aafb486372..d961dbb68a42 100644 --- a/shell/browser/ui/views/menu_delegate.h +++ b/shell/browser/ui/views/menu_delegate.h @@ -62,13 +62,13 @@ class MenuDelegate : public views::MenuDelegate { private: MenuBar* menu_bar_; - int id_; + int id_ = -1; std::unique_ptr adapter_; std::unique_ptr menu_runner_; // The menu button to switch to. views::MenuButton* button_to_open_ = nullptr; - bool hold_first_switch_; + bool hold_first_switch_ = false; base::ObserverList::Unchecked observers_; diff --git a/shell/browser/web_dialog_helper.cc b/shell/browser/web_dialog_helper.cc index 03efd5015e91..47993cd4a482 100644 --- a/shell/browser/web_dialog_helper.cc +++ b/shell/browser/web_dialog_helper.cc @@ -105,7 +105,7 @@ file_dialog::Filters GetFileTypesFromAcceptType( namespace electron { WebDialogHelper::WebDialogHelper(NativeWindow* window, bool offscreen) - : window_(window), offscreen_(offscreen), weak_factory_(this) {} + : window_(window), offscreen_(offscreen) {} WebDialogHelper::~WebDialogHelper() = default; diff --git a/shell/browser/web_dialog_helper.h b/shell/browser/web_dialog_helper.h index eeabc8e1cfbc..3ef07327b7bb 100644 --- a/shell/browser/web_dialog_helper.h +++ b/shell/browser/web_dialog_helper.h @@ -41,7 +41,7 @@ class WebDialogHelper { NativeWindow* window_; bool offscreen_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(WebDialogHelper); }; diff --git a/shell/browser/win/scoped_hstring.cc b/shell/browser/win/scoped_hstring.cc index e174e0cd7ed9..0cf95d484ba1 100644 --- a/shell/browser/win/scoped_hstring.cc +++ b/shell/browser/win/scoped_hstring.cc @@ -8,15 +8,15 @@ namespace electron { -ScopedHString::ScopedHString(const wchar_t* source) : str_(nullptr) { +ScopedHString::ScopedHString(const wchar_t* source) { Reset(source); } -ScopedHString::ScopedHString(const std::wstring& source) : str_(nullptr) { +ScopedHString::ScopedHString(const std::wstring& source) { Reset(source); } -ScopedHString::ScopedHString() : str_(nullptr) {} +ScopedHString::ScopedHString() {} ScopedHString::~ScopedHString() { Reset(); diff --git a/shell/browser/win/scoped_hstring.h b/shell/browser/win/scoped_hstring.h index 6474154037ad..8ea659d31d8c 100644 --- a/shell/browser/win/scoped_hstring.h +++ b/shell/browser/win/scoped_hstring.h @@ -35,7 +35,7 @@ class ScopedHString { bool success() const { return str_; } private: - HSTRING str_; + HSTRING str_ = nullptr; DISALLOW_COPY_AND_ASSIGN(ScopedHString); }; diff --git a/shell/browser/zoom_level_delegate.cc b/shell/browser/zoom_level_delegate.cc index b850206222aa..c446b270aa97 100644 --- a/shell/browser/zoom_level_delegate.cc +++ b/shell/browser/zoom_level_delegate.cc @@ -45,7 +45,7 @@ void ZoomLevelDelegate::RegisterPrefs(PrefRegistrySimple* registry) { ZoomLevelDelegate::ZoomLevelDelegate(PrefService* pref_service, const base::FilePath& partition_path) - : pref_service_(pref_service), host_zoom_map_(nullptr) { + : pref_service_(pref_service) { DCHECK(pref_service_); partition_key_ = GetHash(partition_path); } diff --git a/shell/browser/zoom_level_delegate.h b/shell/browser/zoom_level_delegate.h index b8a3af172eb1..559094652747 100644 --- a/shell/browser/zoom_level_delegate.h +++ b/shell/browser/zoom_level_delegate.h @@ -52,7 +52,7 @@ class ZoomLevelDelegate : public content::ZoomLevelDelegate { void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); PrefService* pref_service_; - content::HostZoomMap* host_zoom_map_; + content::HostZoomMap* host_zoom_map_ = nullptr; base::CallbackListSubscription zoom_subscription_; std::string partition_key_; diff --git a/shell/common/api/object_life_monitor.cc b/shell/common/api/object_life_monitor.cc index e5373d345304..48320da5774b 100644 --- a/shell/common/api/object_life_monitor.cc +++ b/shell/common/api/object_life_monitor.cc @@ -11,7 +11,7 @@ namespace electron { ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate, v8::Local target) - : target_(isolate, target), weak_ptr_factory_(this) { + : target_(isolate, target) { target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter); } diff --git a/shell/common/api/object_life_monitor.h b/shell/common/api/object_life_monitor.h index 0b11d1cb9d71..cd4f8cddac50 100644 --- a/shell/common/api/object_life_monitor.h +++ b/shell/common/api/object_life_monitor.h @@ -24,7 +24,7 @@ class ObjectLifeMonitor { v8::Global target_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(ObjectLifeMonitor); }; diff --git a/shell/common/gin_helper/trackable_object.cc b/shell/common/gin_helper/trackable_object.cc index b1afef8c908b..17611bf14887 100644 --- a/shell/common/gin_helper/trackable_object.cc +++ b/shell/common/gin_helper/trackable_object.cc @@ -31,7 +31,7 @@ class IDUserData : public base::SupportsUserData::Data { } // namespace -TrackableObjectBase::TrackableObjectBase() : weak_factory_(this) { +TrackableObjectBase::TrackableObjectBase() { // TODO(zcbenz): Make TrackedObject work in renderer process. DCHECK(gin_helper::Locker::IsBrowserProcess()) << "This class only works for browser process"; diff --git a/shell/common/gin_helper/trackable_object.h b/shell/common/gin_helper/trackable_object.h index f9a56cf15135..5844ce425247 100644 --- a/shell/common/gin_helper/trackable_object.h +++ b/shell/common/gin_helper/trackable_object.h @@ -43,7 +43,7 @@ class TrackableObjectBase { private: void Destroy(); - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(TrackableObjectBase); }; diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 2f2f4451755c..99a6b4665343 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -302,7 +302,7 @@ base::FilePath GetResourcesPath() { } // namespace NodeBindings::NodeBindings(BrowserEnvironment browser_env) - : browser_env_(browser_env), weak_factory_(this) { + : browser_env_(browser_env) { if (browser_env == BrowserEnvironment::kWorker) { uv_loop_init(&worker_loop_); uv_loop_ = &worker_loop_; diff --git a/shell/common/node_bindings.h b/shell/common/node_bindings.h index 4accd37f0be4..cc61bc634d5b 100644 --- a/shell/common/node_bindings.h +++ b/shell/common/node_bindings.h @@ -159,7 +159,7 @@ class NodeBindings { // Isolate data used in creating the environment node::IsolateData* isolate_data_ = nullptr; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(NodeBindings); }; diff --git a/shell/renderer/api/electron_api_spell_check_client.cc b/shell/renderer/api/electron_api_spell_check_client.cc index 6adc795f4199..f978f5f1f7b1 100644 --- a/shell/renderer/api/electron_api_spell_check_client.cc +++ b/shell/renderer/api/electron_api_spell_check_client.cc @@ -73,8 +73,7 @@ class SpellCheckClient::SpellcheckRequest { SpellCheckClient::SpellCheckClient(const std::string& language, v8::Isolate* isolate, v8::Local provider) - : pending_request_param_(nullptr), - isolate_(isolate), + : isolate_(isolate), context_(isolate, isolate->GetCurrentContext()), provider_(isolate, provider) { DCHECK(!context_.IsEmpty()); diff --git a/shell/renderer/electron_api_service_impl.cc b/shell/renderer/electron_api_service_impl.cc index 0efc37a363c9..939b7dd9f6c8 100644 --- a/shell/renderer/electron_api_service_impl.cc +++ b/shell/renderer/electron_api_service_impl.cc @@ -104,8 +104,7 @@ ElectronApiServiceImpl::ElectronApiServiceImpl( content::RenderFrame* render_frame, RendererClientBase* renderer_client) : content::RenderFrameObserver(render_frame), - renderer_client_(renderer_client), - weak_factory_(this) {} + renderer_client_(renderer_client) {} void ElectronApiServiceImpl::BindTo( mojo::PendingAssociatedReceiver receiver) { diff --git a/shell/renderer/electron_api_service_impl.h b/shell/renderer/electron_api_service_impl.h index ef0c4c1a6b9c..19a65c8710b3 100644 --- a/shell/renderer/electron_api_service_impl.h +++ b/shell/renderer/electron_api_service_impl.h @@ -57,7 +57,7 @@ class ElectronApiServiceImpl : public mojom::ElectronRenderer, mojo::AssociatedReceiver receiver_{this}; RendererClientBase* renderer_client_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(ElectronApiServiceImpl); }; diff --git a/shell/renderer/electron_autofill_agent.cc b/shell/renderer/electron_autofill_agent.cc index ea083ed68412..8d060571aa53 100644 --- a/shell/renderer/electron_autofill_agent.cc +++ b/shell/renderer/electron_autofill_agent.cc @@ -51,7 +51,7 @@ void TrimStringVectorForIPC(std::vector* strings) { AutofillAgent::AutofillAgent(content::RenderFrame* frame, blink::AssociatedInterfaceRegistry* registry) - : content::RenderFrameObserver(frame), weak_ptr_factory_(this) { + : content::RenderFrameObserver(frame) { render_frame()->GetWebFrame()->SetAutofillClient(this); registry->AddInterface(base::BindRepeating(&AutofillAgent::BindReceiver, base::Unretained(this))); diff --git a/shell/renderer/electron_autofill_agent.h b/shell/renderer/electron_autofill_agent.h index 9d5a0fb98e57..91a0c8e0ff83 100644 --- a/shell/renderer/electron_autofill_agent.h +++ b/shell/renderer/electron_autofill_agent.h @@ -84,7 +84,7 @@ class AutofillAgent : public content::RenderFrameObserver, mojo::AssociatedReceiver receiver_{this}; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(AutofillAgent); }; diff --git a/shell/renderer/guest_view_container.cc b/shell/renderer/guest_view_container.cc index b8cf77cdf72d..770c37873459 100644 --- a/shell/renderer/guest_view_container.cc +++ b/shell/renderer/guest_view_container.cc @@ -22,8 +22,7 @@ static base::LazyInstance::DestructorAtExit } // namespace -GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame) - : weak_ptr_factory_(this) {} +GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame) {} GuestViewContainer::~GuestViewContainer() { if (element_instance_id_ > 0) diff --git a/shell/renderer/guest_view_container.h b/shell/renderer/guest_view_container.h index 6eea2c40d7fb..2bf4c9e48755 100644 --- a/shell/renderer/guest_view_container.h +++ b/shell/renderer/guest_view_container.h @@ -32,7 +32,7 @@ class GuestViewContainer { ResizeCallback element_resize_callback_; - base::WeakPtrFactory weak_ptr_factory_; + base::WeakPtrFactory weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(GuestViewContainer); }; diff --git a/shell/utility/electron_content_utility_client.cc b/shell/utility/electron_content_utility_client.cc index 771d18a2ef61..e114d9f9c22c 100644 --- a/shell/utility/electron_content_utility_client.cc +++ b/shell/utility/electron_content_utility_client.cc @@ -77,8 +77,7 @@ auto RunProxyResolver( } // namespace -ElectronContentUtilityClient::ElectronContentUtilityClient() - : utility_process_running_elevated_(false) { +ElectronContentUtilityClient::ElectronContentUtilityClient() { #if BUILDFLAG(ENABLE_PRINT_PREVIEW) && defined(OS_WIN) printing_handler_ = std::make_unique(); #endif diff --git a/shell/utility/electron_content_utility_client.h b/shell/utility/electron_content_utility_client.h index f4789001c06d..4177ca8c9216 100644 --- a/shell/utility/electron_content_utility_client.h +++ b/shell/utility/electron_content_utility_client.h @@ -40,7 +40,7 @@ class ElectronContentUtilityClient : public content::ContentUtilityClient { #endif // True if the utility process runs with elevated privileges. - bool utility_process_running_elevated_; + bool utility_process_running_elevated_ = false; DISALLOW_COPY_AND_ASSIGN(ElectronContentUtilityClient); };