From 6f91af93433df4e9c0e7fb592e5b2dcb0b1c7888 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Mon, 25 Jun 2018 22:30:00 +0200 Subject: [PATCH] chore: fix various chromium-style errors in windows (#13394) These errors weren't previously picked up because the GN build wasn't running on Windows. --- atom/browser/api/atom_api_top_level_window.cc | 2 +- atom/browser/api/atom_api_web_contents.cc | 2 +- atom/browser/browser.h | 4 ++ atom/browser/browser_win.cc | 4 ++ atom/browser/native_window_views_win.cc | 8 ++- atom/browser/ui/certificate_trust_win.cc | 6 +- atom/browser/ui/file_dialog.h | 1 + atom/browser/ui/file_dialog_win.cc | 1 + atom/browser/ui/message_box_win.cc | 2 + atom/browser/ui/views/menu_bar.cc | 6 +- atom/browser/ui/views/win_frame_view.cc | 6 +- atom/browser/ui/views/win_frame_view.h | 3 +- atom/browser/ui/win/jump_list.cc | 9 +++ atom/browser/ui/win/jump_list.h | 9 +++ atom/browser/ui/win/notify_icon.h | 2 +- atom/browser/ui/win/taskbar_host.cc | 5 ++ atom/browser/ui/win/taskbar_host.h | 4 ++ atom/common/api/atom_api_native_image.cc | 5 +- .../crash_reporter/crash_reporter_win.h | 2 +- .../crash_reporter/win/crash_service.cc | 3 +- atom/common/node_bindings_win.h | 2 +- atom/common/platform_util_win.cc | 57 +++++++++++-------- .../extensions/global_shortcut_listener_win.h | 12 ++-- .../chrome/utility/printing_handler_win.h | 2 +- 24 files changed, 100 insertions(+), 57 deletions(-) diff --git a/atom/browser/api/atom_api_top_level_window.cc b/atom/browser/api/atom_api_top_level_window.cc index 145b6b2e98b..dda8bb6ca0b 100644 --- a/atom/browser/api/atom_api_top_level_window.cc +++ b/atom/browser/api/atom_api_top_level_window.cc @@ -810,7 +810,7 @@ bool TopLevelWindow::SetThumbarButtons(mate::Arguments* args) { args->ThrowError(); return false; } - auto window = static_cast(window_.get()); + auto* window = static_cast(window_.get()); return window->taskbar_host().SetThumbarButtons( window_->GetAcceleratedWidget(), buttons); #else diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 170e1d7cedd..548ea394436 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1119,7 +1119,7 @@ int WebContents::GetProcessID() const { } base::ProcessId WebContents::GetOSProcessID() const { - auto process_handle = + base::ProcessHandle process_handle = web_contents()->GetMainFrame()->GetProcess()->GetHandle(); return base::GetProcId(process_handle); } diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 39cc0f9812a..45da7b962fb 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -191,6 +191,10 @@ class Browser : public WindowListObserver { base::string16 description; base::FilePath icon_path; int icon_index; + + UserTask(); + UserTask(const UserTask&); + ~UserTask(); }; // Add a custom task to jump list. diff --git a/atom/browser/browser_win.cc b/atom/browser/browser_win.cc index d109129afbb..fc3b9f330a4 100644 --- a/atom/browser/browser_win.cc +++ b/atom/browser/browser_win.cc @@ -84,6 +84,10 @@ bool FormatCommandLineString(base::string16* exe, } // namespace +Browser::UserTask::UserTask() = default; +Browser::UserTask::UserTask(const UserTask&) = default; +Browser::UserTask::~UserTask() = default; + void Browser::Focus() { // On Windows we just focus on the first window found for this process. DWORD pid = GetCurrentProcessId(); diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index c9802b2e0a8..0d2c9b8c713 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -164,7 +164,7 @@ bool NativeWindowViews::PreHandleMSG(UINT message, const DWORD obj_id = static_cast(l_param); - if (obj_id != OBJID_CLIENT) { + if (obj_id != static_cast(OBJID_CLIENT)) { return false; } @@ -174,7 +174,7 @@ bool NativeWindowViews::PreHandleMSG(UINT message, checked_for_a11y_support_ = true; - const auto axState = content::BrowserAccessibilityState::GetInstance(); + auto* const axState = content::BrowserAccessibilityState::GetInstance(); if (axState && !axState->IsAccessibleBrowser()) { axState->OnScreenReaderDetected(); Browser::Get()->OnAccessibilitySupportChanged(); @@ -278,6 +278,8 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { NotifyWindowRestore(); } break; + default: + break; } } break; @@ -350,7 +352,7 @@ LRESULT CALLBACK NativeWindowViews::MouseHookProc(int n_code, // the cursor since they are in a state where they would otherwise ignore all // mouse input. if (w_param == WM_MOUSEMOVE) { - for (auto window : forwarding_windows_) { + for (auto* window : forwarding_windows_) { // At first I considered enumerating windows to check whether the cursor // was directly above the window, but since nothing bad seems to happen // if we post the message even if some other window occludes it I have diff --git a/atom/browser/ui/certificate_trust_win.cc b/atom/browser/ui/certificate_trust_win.cc index 6179b086070..f3dc0e0cc6a 100644 --- a/atom/browser/ui/certificate_trust_win.cc +++ b/atom/browser/ui/certificate_trust_win.cc @@ -20,8 +20,8 @@ namespace certificate_trust { // This requires prompting the user to confirm they trust the certificate. BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context, const scoped_refptr& cert) { - auto root_cert_store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, - CERT_SYSTEM_STORE_CURRENT_USER, L"Root"); + auto* root_cert_store = CertOpenStore( + CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER, L"Root"); if (root_cert_store == NULL) { return false; @@ -32,7 +32,7 @@ BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context, if (result) { // force Chromium to reload it's database for this certificate - auto cert_db = net::CertDatabase::GetInstance(); + auto* cert_db = net::CertDatabase::GetInstance(); cert_db->NotifyObserversCertDBChanged(); } diff --git a/atom/browser/ui/file_dialog.h b/atom/browser/ui/file_dialog.h index efa50062bb8..becc1806610 100644 --- a/atom/browser/ui/file_dialog.h +++ b/atom/browser/ui/file_dialog.h @@ -66,6 +66,7 @@ struct DialogSettings { bool security_scoped_bookmarks = false; DialogSettings(); + DialogSettings(const DialogSettings&); ~DialogSettings(); }; diff --git a/atom/browser/ui/file_dialog_win.cc b/atom/browser/ui/file_dialog_win.cc index 2d708086bfd..31958ee1fab 100644 --- a/atom/browser/ui/file_dialog_win.cc +++ b/atom/browser/ui/file_dialog_win.cc @@ -26,6 +26,7 @@ namespace file_dialog { DialogSettings::DialogSettings() = default; +DialogSettings::DialogSettings(const DialogSettings&) = default; DialogSettings::~DialogSettings() = default; namespace { diff --git a/atom/browser/ui/message_box_win.cc b/atom/browser/ui/message_box_win.cc index e5a0e61379d..b0e73f550e1 100644 --- a/atom/browser/ui/message_box_win.cc +++ b/atom/browser/ui/message_box_win.cc @@ -128,6 +128,8 @@ int ShowTaskDialogUTF16(NativeWindow* parent, case MESSAGE_BOX_TYPE_ERROR: config.pszMainIcon = TD_ERROR_ICON; break; + case MESSAGE_BOX_TYPE_NONE: + break; } } diff --git a/atom/browser/ui/views/menu_bar.cc b/atom/browser/ui/views/menu_bar.cc index 535af8f2803..e838d3cc217 100644 --- a/atom/browser/ui/views/menu_bar.cc +++ b/atom/browser/ui/views/menu_bar.cc @@ -29,8 +29,8 @@ MenuBar::MenuBar(views::View* window) : background_color_(kDefaultColor), window_(window) { RefreshColorCache(); UpdateViewColors(); - SetLayoutManager(std::make_unique( - views::BoxLayout::kHorizontal)); + SetLayoutManager( + std::make_unique(views::BoxLayout::kHorizontal)); window_->GetFocusManager()->AddFocusChangeListener(this); } @@ -178,7 +178,7 @@ void MenuBar::UpdateViewColors() { } #elif defined(OS_WIN) for (auto* child : GetChildrenInZOrder()) { - auto button = static_cast(child); + auto* button = static_cast(child); button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_MENUTEXT)); } #endif diff --git a/atom/browser/ui/views/win_frame_view.cc b/atom/browser/ui/views/win_frame_view.cc index 91fdb8a9668..8f2139cb90f 100644 --- a/atom/browser/ui/views/win_frame_view.cc +++ b/atom/browser/ui/views/win_frame_view.cc @@ -10,11 +10,7 @@ namespace atom { -namespace { - -const char kViewClassName[] = "WinFrameView"; - -} // namespace +const char WinFrameView::kViewClassName[] = "WinFrameView"; WinFrameView::WinFrameView() {} diff --git a/atom/browser/ui/views/win_frame_view.h b/atom/browser/ui/views/win_frame_view.h index b2c1ef3a15d..a6ffd7f3633 100644 --- a/atom/browser/ui/views/win_frame_view.h +++ b/atom/browser/ui/views/win_frame_view.h @@ -11,8 +11,9 @@ namespace atom { class WinFrameView : public FramelessView { public: + static const char kViewClassName[]; WinFrameView(); - virtual ~WinFrameView(); + ~WinFrameView() override; // views::NonClientFrameView: gfx::Rect GetWindowBoundsForClientBounds( diff --git a/atom/browser/ui/win/jump_list.cc b/atom/browser/ui/win/jump_list.cc index 6af235e756c..fbbd267cf15 100644 --- a/atom/browser/ui/win/jump_list.cc +++ b/atom/browser/ui/win/jump_list.cc @@ -144,10 +144,19 @@ void ConvertRemovedJumpListItems(IObjectArray* in, namespace atom { +JumpListItem::JumpListItem() = default; +JumpListItem::JumpListItem(const JumpListItem&) = default; +JumpListItem::~JumpListItem() = default; +JumpListCategory::JumpListCategory() = default; +JumpListCategory::JumpListCategory(const JumpListCategory&) = default; +JumpListCategory::~JumpListCategory() = default; + JumpList::JumpList(const base::string16& app_id) : app_id_(app_id) { destinations_.CoCreateInstance(CLSID_DestinationList); } +JumpList::~JumpList() = default; + bool JumpList::Begin(int* min_items, std::vector* removed_items) { DCHECK(destinations_); if (!destinations_) diff --git a/atom/browser/ui/win/jump_list.h b/atom/browser/ui/win/jump_list.h index fc4ab085fc0..59d9a21a6c3 100644 --- a/atom/browser/ui/win/jump_list.h +++ b/atom/browser/ui/win/jump_list.h @@ -51,6 +51,10 @@ struct JumpListItem { base::string16 description; base::FilePath icon_path; int icon_index = 0; + + JumpListItem(); + JumpListItem(const JumpListItem&); + ~JumpListItem(); }; struct JumpListCategory { @@ -70,6 +74,10 @@ struct JumpListCategory { Type type = Type::TASKS; base::string16 name; std::vector items; + + JumpListCategory(); + JumpListCategory(const JumpListCategory&); + ~JumpListCategory(); }; // Creates or removes a custom Jump List for an app. @@ -80,6 +88,7 @@ class JumpList { // custom Jump List should be created/removed, it's usually obtained by // calling GetCurrentProcessExplicitAppUserModelID(). explicit JumpList(const base::string16& app_id); + ~JumpList(); // Starts a new transaction, must be called before appending any categories, // aborting or committing. After the method returns |min_items| will indicate diff --git a/atom/browser/ui/win/notify_icon.h b/atom/browser/ui/win/notify_icon.h index aed548ecb61..bd4c17d2fce 100644 --- a/atom/browser/ui/win/notify_icon.h +++ b/atom/browser/ui/win/notify_icon.h @@ -32,7 +32,7 @@ class NotifyIcon : public TrayIcon { public: // Constructor which provides this icon's unique ID and messaging window. NotifyIcon(NotifyIconHost* host, UINT id, HWND window, UINT message); - virtual ~NotifyIcon(); + ~NotifyIcon() override; // Handles a click event from the user - if |left_button_click| is true and // there is a registered observer, passes the click event to the observer, diff --git a/atom/browser/ui/win/taskbar_host.cc b/atom/browser/ui/win/taskbar_host.cc index e023fdc8c83..c4b92a24aef 100644 --- a/atom/browser/ui/win/taskbar_host.cc +++ b/atom/browser/ui/win/taskbar_host.cc @@ -50,6 +50,11 @@ bool GetThumbarButtonFlags(const std::vector& flags, } // namespace +TaskbarHost::ThumbarButton::ThumbarButton() = default; +TaskbarHost::ThumbarButton::ThumbarButton(const TaskbarHost::ThumbarButton&) = + default; +TaskbarHost::ThumbarButton::~ThumbarButton() = default; + TaskbarHost::TaskbarHost() {} TaskbarHost::~TaskbarHost() {} diff --git a/atom/browser/ui/win/taskbar_host.h b/atom/browser/ui/win/taskbar_host.h index 31199cf2283..2182d377a77 100644 --- a/atom/browser/ui/win/taskbar_host.h +++ b/atom/browser/ui/win/taskbar_host.h @@ -26,6 +26,10 @@ class TaskbarHost { gfx::Image icon; std::vector flags; base::Closure clicked_callback; + + ThumbarButton(); + ThumbarButton(const ThumbarButton&); + ~ThumbarButton(); }; TaskbarHost(); diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index 7b274b38cae..09edfdaac91 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -245,15 +245,14 @@ HICON NativeImage::GetHICON(int size) { // First try loading the icon with specified size. if (!hicon_path_.empty()) { - hicons_[size] = std::move(ReadICOFromPath(size, hicon_path_)); + hicons_[size] = ReadICOFromPath(size, hicon_path_); return hicons_[size].get(); } // Then convert the image to ICO. if (image_.IsEmpty()) return NULL; - hicons_[size] = - std::move(IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap())); + hicons_[size] = IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap()); return hicons_[size].get(); } #endif diff --git a/atom/common/crash_reporter/crash_reporter_win.h b/atom/common/crash_reporter/crash_reporter_win.h index f7f1c6b2845..3509ebbd371 100644 --- a/atom/common/crash_reporter/crash_reporter_win.h +++ b/atom/common/crash_reporter/crash_reporter_win.h @@ -40,7 +40,7 @@ class CrashReporterWin : public CrashReporter { friend struct base::DefaultSingletonTraits; CrashReporterWin(); - virtual ~CrashReporterWin(); + ~CrashReporterWin() override; static bool FilterCallback(void* context, EXCEPTION_POINTERS* exinfo, diff --git a/atom/common/crash_reporter/win/crash_service.cc b/atom/common/crash_reporter/win/crash_service.cc index a1a6ab6d790..aade5951aba 100644 --- a/atom/common/crash_reporter/win/crash_service.cc +++ b/atom/common/crash_reporter/win/crash_service.cc @@ -132,7 +132,7 @@ bool CreateTopWindow(HINSTANCE instance, wcx.lpfnWndProc = CrashSvcWndProc; wcx.hInstance = instance; wcx.lpszClassName = class_name.c_str(); - ATOM atom = ::RegisterClassExW(&wcx); + ::RegisterClassExW(&wcx); DWORD style = visible ? WS_POPUPWINDOW | WS_VISIBLE : WS_OVERLAPPED; // The window size is zero but being a popup window still shows in the @@ -487,7 +487,6 @@ PSECURITY_DESCRIPTOR CrashService::GetSecurityDescriptorForLowIntegrity() { // Build the SDDL string for the label. std::wstring sddl = L"S:(ML;;NW;;;S-1-16-4096)"; - DWORD error = ERROR_SUCCESS; PSECURITY_DESCRIPTOR sec_desc = NULL; PACL sacl = NULL; diff --git a/atom/common/node_bindings_win.h b/atom/common/node_bindings_win.h index 793586d88da..77fe5f43b54 100644 --- a/atom/common/node_bindings_win.h +++ b/atom/common/node_bindings_win.h @@ -13,7 +13,7 @@ namespace atom { class NodeBindingsWin : public NodeBindings { public: explicit NodeBindingsWin(BrowserEnvironment browser_env); - virtual ~NodeBindingsWin(); + ~NodeBindingsWin() override; private: void PollEvents() override; diff --git a/atom/common/platform_util_win.cc b/atom/common/platform_util_win.cc index 193e2ece004..e92926b6cf1 100644 --- a/atom/common/platform_util_win.cc +++ b/atom/common/platform_util_win.cc @@ -53,45 +53,55 @@ bool ValidateShellCommandForScheme(const std::string& scheme) { class DeleteFileProgressSink : public IFileOperationProgressSink { public: DeleteFileProgressSink(); + virtual ~DeleteFileProgressSink() = default; private: - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID* ppvObj); - HRESULT STDMETHODCALLTYPE StartOperations(void); - HRESULT STDMETHODCALLTYPE FinishOperations(HRESULT); - HRESULT STDMETHODCALLTYPE PreRenameItem(DWORD, IShellItem*, LPCWSTR); + ULONG STDMETHODCALLTYPE AddRef(void) override; + ULONG STDMETHODCALLTYPE Release(void) override; + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, + LPVOID* ppvObj) override; + HRESULT STDMETHODCALLTYPE StartOperations(void) override; + HRESULT STDMETHODCALLTYPE FinishOperations(HRESULT) override; + HRESULT STDMETHODCALLTYPE PreRenameItem(DWORD, IShellItem*, LPCWSTR) override; HRESULT STDMETHODCALLTYPE - PostRenameItem(DWORD, IShellItem*, LPCWSTR, HRESULT, IShellItem*); + PostRenameItem(DWORD, IShellItem*, LPCWSTR, HRESULT, IShellItem*) override; HRESULT STDMETHODCALLTYPE PreMoveItem(DWORD, IShellItem*, IShellItem*, - LPCWSTR); - HRESULT STDMETHODCALLTYPE - PostMoveItem(DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*); + LPCWSTR) override; + HRESULT STDMETHODCALLTYPE PostMoveItem(DWORD, + IShellItem*, + IShellItem*, + LPCWSTR, + HRESULT, + IShellItem*) override; HRESULT STDMETHODCALLTYPE PreCopyItem(DWORD, IShellItem*, IShellItem*, - LPCWSTR); - HRESULT STDMETHODCALLTYPE - PostCopyItem(DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*); - HRESULT STDMETHODCALLTYPE PreDeleteItem(DWORD, IShellItem*); + LPCWSTR) override; + HRESULT STDMETHODCALLTYPE PostCopyItem(DWORD, + IShellItem*, + IShellItem*, + LPCWSTR, + HRESULT, + IShellItem*) override; + HRESULT STDMETHODCALLTYPE PreDeleteItem(DWORD, IShellItem*) override; HRESULT STDMETHODCALLTYPE PostDeleteItem(DWORD, IShellItem*, HRESULT, - IShellItem*); - HRESULT STDMETHODCALLTYPE PreNewItem(DWORD, IShellItem*, LPCWSTR); + IShellItem*) override; + HRESULT STDMETHODCALLTYPE PreNewItem(DWORD, IShellItem*, LPCWSTR) override; HRESULT STDMETHODCALLTYPE PostNewItem(DWORD, IShellItem*, LPCWSTR, LPCWSTR, DWORD, HRESULT, - IShellItem*); - HRESULT STDMETHODCALLTYPE UpdateProgress(UINT, UINT); - HRESULT STDMETHODCALLTYPE ResetTimer(void); - HRESULT STDMETHODCALLTYPE PauseTimer(void); - HRESULT STDMETHODCALLTYPE ResumeTimer(void); + IShellItem*) override; + HRESULT STDMETHODCALLTYPE UpdateProgress(UINT, UINT) override; + HRESULT STDMETHODCALLTYPE ResetTimer(void) override; + HRESULT STDMETHODCALLTYPE PauseTimer(void) override; + HRESULT STDMETHODCALLTYPE ResumeTimer(void) override; ULONG m_cRef; }; @@ -308,9 +318,8 @@ bool ShowItemInFolder(const base::FilePath& full_path) { return ui::win::OpenFolderViaShell(dir); } else { LPTSTR message = NULL; - DWORD message_length = FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, hr, 0, - reinterpret_cast(&message), 0, NULL); + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + 0, hr, 0, reinterpret_cast(&message), 0, NULL); LOG(WARNING) << " " << __FUNCTION__ << "(): Can't open full_path = \"" << full_path.value() << "\"" << " hr = " << hr << " " << reinterpret_cast(&message); diff --git a/chromium_src/chrome/browser/extensions/global_shortcut_listener_win.h b/chromium_src/chrome/browser/extensions/global_shortcut_listener_win.h index 83e9fdff283..1a8b6dddefd 100644 --- a/chromium_src/chrome/browser/extensions/global_shortcut_listener_win.h +++ b/chromium_src/chrome/browser/extensions/global_shortcut_listener_win.h @@ -21,19 +21,17 @@ namespace extensions { class GlobalShortcutListenerWin : public GlobalShortcutListener { public: GlobalShortcutListenerWin(); - virtual ~GlobalShortcutListenerWin(); + ~GlobalShortcutListenerWin() override; private: // The implementation of our Window Proc, called by SingletonHwndObserver. void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); // GlobalShortcutListener implementation. - virtual void StartListening() override; - virtual void StopListening() override; - virtual bool RegisterAcceleratorImpl( - const ui::Accelerator& accelerator) override; - virtual void UnregisterAcceleratorImpl( - const ui::Accelerator& accelerator) override; + void StartListening() override; + void StopListening() override; + bool RegisterAcceleratorImpl(const ui::Accelerator& accelerator) override; + void UnregisterAcceleratorImpl(const ui::Accelerator& accelerator) override; // Whether this object is listening for global shortcuts. bool is_listening_; diff --git a/chromium_src/chrome/utility/printing_handler_win.h b/chromium_src/chrome/utility/printing_handler_win.h index d058e7e5055..8744574f10a 100644 --- a/chromium_src/chrome/utility/printing_handler_win.h +++ b/chromium_src/chrome/utility/printing_handler_win.h @@ -13,7 +13,7 @@ namespace printing { -class PdfRenderSettings; +struct PdfRenderSettings; struct PwgRasterSettings; struct PageRange;