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.
This commit is contained in:
Jeremy Apthorp 2018-06-25 22:30:00 +02:00 committed by GitHub
parent 1c64ac8c41
commit 6f91af9343
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 100 additions and 57 deletions

View file

@ -810,7 +810,7 @@ bool TopLevelWindow::SetThumbarButtons(mate::Arguments* args) {
args->ThrowError(); args->ThrowError();
return false; return false;
} }
auto window = static_cast<NativeWindowViews*>(window_.get()); auto* window = static_cast<NativeWindowViews*>(window_.get());
return window->taskbar_host().SetThumbarButtons( return window->taskbar_host().SetThumbarButtons(
window_->GetAcceleratedWidget(), buttons); window_->GetAcceleratedWidget(), buttons);
#else #else

View file

@ -1119,7 +1119,7 @@ int WebContents::GetProcessID() const {
} }
base::ProcessId WebContents::GetOSProcessID() const { base::ProcessId WebContents::GetOSProcessID() const {
auto process_handle = base::ProcessHandle process_handle =
web_contents()->GetMainFrame()->GetProcess()->GetHandle(); web_contents()->GetMainFrame()->GetProcess()->GetHandle();
return base::GetProcId(process_handle); return base::GetProcId(process_handle);
} }

View file

@ -191,6 +191,10 @@ class Browser : public WindowListObserver {
base::string16 description; base::string16 description;
base::FilePath icon_path; base::FilePath icon_path;
int icon_index; int icon_index;
UserTask();
UserTask(const UserTask&);
~UserTask();
}; };
// Add a custom task to jump list. // Add a custom task to jump list.

View file

@ -84,6 +84,10 @@ bool FormatCommandLineString(base::string16* exe,
} // namespace } // namespace
Browser::UserTask::UserTask() = default;
Browser::UserTask::UserTask(const UserTask&) = default;
Browser::UserTask::~UserTask() = default;
void Browser::Focus() { void Browser::Focus() {
// On Windows we just focus on the first window found for this process. // On Windows we just focus on the first window found for this process.
DWORD pid = GetCurrentProcessId(); DWORD pid = GetCurrentProcessId();

View file

@ -164,7 +164,7 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
const DWORD obj_id = static_cast<DWORD>(l_param); const DWORD obj_id = static_cast<DWORD>(l_param);
if (obj_id != OBJID_CLIENT) { if (obj_id != static_cast<DWORD>(OBJID_CLIENT)) {
return false; return false;
} }
@ -174,7 +174,7 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
checked_for_a11y_support_ = true; checked_for_a11y_support_ = true;
const auto axState = content::BrowserAccessibilityState::GetInstance(); auto* const axState = content::BrowserAccessibilityState::GetInstance();
if (axState && !axState->IsAccessibleBrowser()) { if (axState && !axState->IsAccessibleBrowser()) {
axState->OnScreenReaderDetected(); axState->OnScreenReaderDetected();
Browser::Get()->OnAccessibilitySupportChanged(); Browser::Get()->OnAccessibilitySupportChanged();
@ -278,6 +278,8 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
NotifyWindowRestore(); NotifyWindowRestore();
} }
break; break;
default:
break;
} }
} }
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 // the cursor since they are in a state where they would otherwise ignore all
// mouse input. // mouse input.
if (w_param == WM_MOUSEMOVE) { 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 // At first I considered enumerating windows to check whether the cursor
// was directly above the window, but since nothing bad seems to happen // 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 // if we post the message even if some other window occludes it I have

View file

@ -20,8 +20,8 @@ namespace certificate_trust {
// This requires prompting the user to confirm they trust the certificate. // This requires prompting the user to confirm they trust the certificate.
BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context, BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
const scoped_refptr<net::X509Certificate>& cert) { const scoped_refptr<net::X509Certificate>& cert) {
auto root_cert_store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, auto* root_cert_store = CertOpenStore(
CERT_SYSTEM_STORE_CURRENT_USER, L"Root"); CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER, L"Root");
if (root_cert_store == NULL) { if (root_cert_store == NULL) {
return false; return false;
@ -32,7 +32,7 @@ BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
if (result) { if (result) {
// force Chromium to reload it's database for this certificate // 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(); cert_db->NotifyObserversCertDBChanged();
} }

View file

@ -66,6 +66,7 @@ struct DialogSettings {
bool security_scoped_bookmarks = false; bool security_scoped_bookmarks = false;
DialogSettings(); DialogSettings();
DialogSettings(const DialogSettings&);
~DialogSettings(); ~DialogSettings();
}; };

View file

@ -26,6 +26,7 @@
namespace file_dialog { namespace file_dialog {
DialogSettings::DialogSettings() = default; DialogSettings::DialogSettings() = default;
DialogSettings::DialogSettings(const DialogSettings&) = default;
DialogSettings::~DialogSettings() = default; DialogSettings::~DialogSettings() = default;
namespace { namespace {

View file

@ -128,6 +128,8 @@ int ShowTaskDialogUTF16(NativeWindow* parent,
case MESSAGE_BOX_TYPE_ERROR: case MESSAGE_BOX_TYPE_ERROR:
config.pszMainIcon = TD_ERROR_ICON; config.pszMainIcon = TD_ERROR_ICON;
break; break;
case MESSAGE_BOX_TYPE_NONE:
break;
} }
} }

View file

@ -29,8 +29,8 @@ MenuBar::MenuBar(views::View* window)
: background_color_(kDefaultColor), window_(window) { : background_color_(kDefaultColor), window_(window) {
RefreshColorCache(); RefreshColorCache();
UpdateViewColors(); UpdateViewColors();
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(
views::BoxLayout::kHorizontal)); std::make_unique<views::BoxLayout>(views::BoxLayout::kHorizontal));
window_->GetFocusManager()->AddFocusChangeListener(this); window_->GetFocusManager()->AddFocusChangeListener(this);
} }
@ -178,7 +178,7 @@ void MenuBar::UpdateViewColors() {
} }
#elif defined(OS_WIN) #elif defined(OS_WIN)
for (auto* child : GetChildrenInZOrder()) { for (auto* child : GetChildrenInZOrder()) {
auto button = static_cast<SubmenuButton*>(child); auto* button = static_cast<SubmenuButton*>(child);
button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_MENUTEXT)); button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_MENUTEXT));
} }
#endif #endif

View file

@ -10,11 +10,7 @@
namespace atom { namespace atom {
namespace { const char WinFrameView::kViewClassName[] = "WinFrameView";
const char kViewClassName[] = "WinFrameView";
} // namespace
WinFrameView::WinFrameView() {} WinFrameView::WinFrameView() {}

View file

@ -11,8 +11,9 @@ namespace atom {
class WinFrameView : public FramelessView { class WinFrameView : public FramelessView {
public: public:
static const char kViewClassName[];
WinFrameView(); WinFrameView();
virtual ~WinFrameView(); ~WinFrameView() override;
// views::NonClientFrameView: // views::NonClientFrameView:
gfx::Rect GetWindowBoundsForClientBounds( gfx::Rect GetWindowBoundsForClientBounds(

View file

@ -144,10 +144,19 @@ void ConvertRemovedJumpListItems(IObjectArray* in,
namespace atom { 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) { JumpList::JumpList(const base::string16& app_id) : app_id_(app_id) {
destinations_.CoCreateInstance(CLSID_DestinationList); destinations_.CoCreateInstance(CLSID_DestinationList);
} }
JumpList::~JumpList() = default;
bool JumpList::Begin(int* min_items, std::vector<JumpListItem>* removed_items) { bool JumpList::Begin(int* min_items, std::vector<JumpListItem>* removed_items) {
DCHECK(destinations_); DCHECK(destinations_);
if (!destinations_) if (!destinations_)

View file

@ -51,6 +51,10 @@ struct JumpListItem {
base::string16 description; base::string16 description;
base::FilePath icon_path; base::FilePath icon_path;
int icon_index = 0; int icon_index = 0;
JumpListItem();
JumpListItem(const JumpListItem&);
~JumpListItem();
}; };
struct JumpListCategory { struct JumpListCategory {
@ -70,6 +74,10 @@ struct JumpListCategory {
Type type = Type::TASKS; Type type = Type::TASKS;
base::string16 name; base::string16 name;
std::vector<JumpListItem> items; std::vector<JumpListItem> items;
JumpListCategory();
JumpListCategory(const JumpListCategory&);
~JumpListCategory();
}; };
// Creates or removes a custom Jump List for an app. // 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 // custom Jump List should be created/removed, it's usually obtained by
// calling GetCurrentProcessExplicitAppUserModelID(). // calling GetCurrentProcessExplicitAppUserModelID().
explicit JumpList(const base::string16& app_id); explicit JumpList(const base::string16& app_id);
~JumpList();
// Starts a new transaction, must be called before appending any categories, // Starts a new transaction, must be called before appending any categories,
// aborting or committing. After the method returns |min_items| will indicate // aborting or committing. After the method returns |min_items| will indicate

View file

@ -32,7 +32,7 @@ class NotifyIcon : public TrayIcon {
public: public:
// Constructor which provides this icon's unique ID and messaging window. // Constructor which provides this icon's unique ID and messaging window.
NotifyIcon(NotifyIconHost* host, UINT id, HWND window, UINT message); 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 // 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, // there is a registered observer, passes the click event to the observer,

View file

@ -50,6 +50,11 @@ bool GetThumbarButtonFlags(const std::vector<std::string>& flags,
} // namespace } // namespace
TaskbarHost::ThumbarButton::ThumbarButton() = default;
TaskbarHost::ThumbarButton::ThumbarButton(const TaskbarHost::ThumbarButton&) =
default;
TaskbarHost::ThumbarButton::~ThumbarButton() = default;
TaskbarHost::TaskbarHost() {} TaskbarHost::TaskbarHost() {}
TaskbarHost::~TaskbarHost() {} TaskbarHost::~TaskbarHost() {}

View file

@ -26,6 +26,10 @@ class TaskbarHost {
gfx::Image icon; gfx::Image icon;
std::vector<std::string> flags; std::vector<std::string> flags;
base::Closure clicked_callback; base::Closure clicked_callback;
ThumbarButton();
ThumbarButton(const ThumbarButton&);
~ThumbarButton();
}; };
TaskbarHost(); TaskbarHost();

View file

@ -245,15 +245,14 @@ HICON NativeImage::GetHICON(int size) {
// First try loading the icon with specified size. // First try loading the icon with specified size.
if (!hicon_path_.empty()) { if (!hicon_path_.empty()) {
hicons_[size] = std::move(ReadICOFromPath(size, hicon_path_)); hicons_[size] = ReadICOFromPath(size, hicon_path_);
return hicons_[size].get(); return hicons_[size].get();
} }
// Then convert the image to ICO. // Then convert the image to ICO.
if (image_.IsEmpty()) if (image_.IsEmpty())
return NULL; return NULL;
hicons_[size] = hicons_[size] = IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap());
std::move(IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap()));
return hicons_[size].get(); return hicons_[size].get();
} }
#endif #endif

View file

@ -40,7 +40,7 @@ class CrashReporterWin : public CrashReporter {
friend struct base::DefaultSingletonTraits<CrashReporterWin>; friend struct base::DefaultSingletonTraits<CrashReporterWin>;
CrashReporterWin(); CrashReporterWin();
virtual ~CrashReporterWin(); ~CrashReporterWin() override;
static bool FilterCallback(void* context, static bool FilterCallback(void* context,
EXCEPTION_POINTERS* exinfo, EXCEPTION_POINTERS* exinfo,

View file

@ -132,7 +132,7 @@ bool CreateTopWindow(HINSTANCE instance,
wcx.lpfnWndProc = CrashSvcWndProc; wcx.lpfnWndProc = CrashSvcWndProc;
wcx.hInstance = instance; wcx.hInstance = instance;
wcx.lpszClassName = class_name.c_str(); wcx.lpszClassName = class_name.c_str();
ATOM atom = ::RegisterClassExW(&wcx); ::RegisterClassExW(&wcx);
DWORD style = visible ? WS_POPUPWINDOW | WS_VISIBLE : WS_OVERLAPPED; DWORD style = visible ? WS_POPUPWINDOW | WS_VISIBLE : WS_OVERLAPPED;
// The window size is zero but being a popup window still shows in the // 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. // Build the SDDL string for the label.
std::wstring sddl = L"S:(ML;;NW;;;S-1-16-4096)"; std::wstring sddl = L"S:(ML;;NW;;;S-1-16-4096)";
DWORD error = ERROR_SUCCESS;
PSECURITY_DESCRIPTOR sec_desc = NULL; PSECURITY_DESCRIPTOR sec_desc = NULL;
PACL sacl = NULL; PACL sacl = NULL;

View file

@ -13,7 +13,7 @@ namespace atom {
class NodeBindingsWin : public NodeBindings { class NodeBindingsWin : public NodeBindings {
public: public:
explicit NodeBindingsWin(BrowserEnvironment browser_env); explicit NodeBindingsWin(BrowserEnvironment browser_env);
virtual ~NodeBindingsWin(); ~NodeBindingsWin() override;
private: private:
void PollEvents() override; void PollEvents() override;

View file

@ -53,45 +53,55 @@ bool ValidateShellCommandForScheme(const std::string& scheme) {
class DeleteFileProgressSink : public IFileOperationProgressSink { class DeleteFileProgressSink : public IFileOperationProgressSink {
public: public:
DeleteFileProgressSink(); DeleteFileProgressSink();
virtual ~DeleteFileProgressSink() = default;
private: private:
ULONG STDMETHODCALLTYPE AddRef(void); ULONG STDMETHODCALLTYPE AddRef(void) override;
ULONG STDMETHODCALLTYPE Release(void); ULONG STDMETHODCALLTYPE Release(void) override;
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID* ppvObj); HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid,
HRESULT STDMETHODCALLTYPE StartOperations(void); LPVOID* ppvObj) override;
HRESULT STDMETHODCALLTYPE FinishOperations(HRESULT); HRESULT STDMETHODCALLTYPE StartOperations(void) override;
HRESULT STDMETHODCALLTYPE PreRenameItem(DWORD, IShellItem*, LPCWSTR); HRESULT STDMETHODCALLTYPE FinishOperations(HRESULT) override;
HRESULT STDMETHODCALLTYPE PreRenameItem(DWORD, IShellItem*, LPCWSTR) override;
HRESULT STDMETHODCALLTYPE HRESULT STDMETHODCALLTYPE
PostRenameItem(DWORD, IShellItem*, LPCWSTR, HRESULT, IShellItem*); PostRenameItem(DWORD, IShellItem*, LPCWSTR, HRESULT, IShellItem*) override;
HRESULT STDMETHODCALLTYPE PreMoveItem(DWORD, HRESULT STDMETHODCALLTYPE PreMoveItem(DWORD,
IShellItem*, IShellItem*,
IShellItem*, IShellItem*,
LPCWSTR); LPCWSTR) override;
HRESULT STDMETHODCALLTYPE HRESULT STDMETHODCALLTYPE PostMoveItem(DWORD,
PostMoveItem(DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*); IShellItem*,
IShellItem*,
LPCWSTR,
HRESULT,
IShellItem*) override;
HRESULT STDMETHODCALLTYPE PreCopyItem(DWORD, HRESULT STDMETHODCALLTYPE PreCopyItem(DWORD,
IShellItem*, IShellItem*,
IShellItem*, IShellItem*,
LPCWSTR); LPCWSTR) override;
HRESULT STDMETHODCALLTYPE HRESULT STDMETHODCALLTYPE PostCopyItem(DWORD,
PostCopyItem(DWORD, IShellItem*, IShellItem*, LPCWSTR, HRESULT, IShellItem*); IShellItem*,
HRESULT STDMETHODCALLTYPE PreDeleteItem(DWORD, IShellItem*); IShellItem*,
LPCWSTR,
HRESULT,
IShellItem*) override;
HRESULT STDMETHODCALLTYPE PreDeleteItem(DWORD, IShellItem*) override;
HRESULT STDMETHODCALLTYPE PostDeleteItem(DWORD, HRESULT STDMETHODCALLTYPE PostDeleteItem(DWORD,
IShellItem*, IShellItem*,
HRESULT, HRESULT,
IShellItem*); IShellItem*) override;
HRESULT STDMETHODCALLTYPE PreNewItem(DWORD, IShellItem*, LPCWSTR); HRESULT STDMETHODCALLTYPE PreNewItem(DWORD, IShellItem*, LPCWSTR) override;
HRESULT STDMETHODCALLTYPE PostNewItem(DWORD, HRESULT STDMETHODCALLTYPE PostNewItem(DWORD,
IShellItem*, IShellItem*,
LPCWSTR, LPCWSTR,
LPCWSTR, LPCWSTR,
DWORD, DWORD,
HRESULT, HRESULT,
IShellItem*); IShellItem*) override;
HRESULT STDMETHODCALLTYPE UpdateProgress(UINT, UINT); HRESULT STDMETHODCALLTYPE UpdateProgress(UINT, UINT) override;
HRESULT STDMETHODCALLTYPE ResetTimer(void); HRESULT STDMETHODCALLTYPE ResetTimer(void) override;
HRESULT STDMETHODCALLTYPE PauseTimer(void); HRESULT STDMETHODCALLTYPE PauseTimer(void) override;
HRESULT STDMETHODCALLTYPE ResumeTimer(void); HRESULT STDMETHODCALLTYPE ResumeTimer(void) override;
ULONG m_cRef; ULONG m_cRef;
}; };
@ -308,9 +318,8 @@ bool ShowItemInFolder(const base::FilePath& full_path) {
return ui::win::OpenFolderViaShell(dir); return ui::win::OpenFolderViaShell(dir);
} else { } else {
LPTSTR message = NULL; LPTSTR message = NULL;
DWORD message_length = FormatMessage( FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, hr, 0, 0, hr, 0, reinterpret_cast<LPTSTR>(&message), 0, NULL);
reinterpret_cast<LPTSTR>(&message), 0, NULL);
LOG(WARNING) << " " << __FUNCTION__ << "(): Can't open full_path = \"" LOG(WARNING) << " " << __FUNCTION__ << "(): Can't open full_path = \""
<< full_path.value() << "\"" << full_path.value() << "\""
<< " hr = " << hr << " " << reinterpret_cast<LPTSTR>(&message); << " hr = " << hr << " " << reinterpret_cast<LPTSTR>(&message);

View file

@ -21,19 +21,17 @@ namespace extensions {
class GlobalShortcutListenerWin : public GlobalShortcutListener { class GlobalShortcutListenerWin : public GlobalShortcutListener {
public: public:
GlobalShortcutListenerWin(); GlobalShortcutListenerWin();
virtual ~GlobalShortcutListenerWin(); ~GlobalShortcutListenerWin() override;
private: private:
// The implementation of our Window Proc, called by SingletonHwndObserver. // The implementation of our Window Proc, called by SingletonHwndObserver.
void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
// GlobalShortcutListener implementation. // GlobalShortcutListener implementation.
virtual void StartListening() override; void StartListening() override;
virtual void StopListening() override; void StopListening() override;
virtual bool RegisterAcceleratorImpl( bool RegisterAcceleratorImpl(const ui::Accelerator& accelerator) override;
const ui::Accelerator& accelerator) override; void UnregisterAcceleratorImpl(const ui::Accelerator& accelerator) override;
virtual void UnregisterAcceleratorImpl(
const ui::Accelerator& accelerator) override;
// Whether this object is listening for global shortcuts. // Whether this object is listening for global shortcuts.
bool is_listening_; bool is_listening_;

View file

@ -13,7 +13,7 @@
namespace printing { namespace printing {
class PdfRenderSettings; struct PdfRenderSettings;
struct PwgRasterSettings; struct PwgRasterSettings;
struct PageRange; struct PageRange;