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();
return false;
}
auto window = static_cast<NativeWindowViews*>(window_.get());
auto* window = static_cast<NativeWindowViews*>(window_.get());
return window->taskbar_host().SetThumbarButtons(
window_->GetAcceleratedWidget(), buttons);
#else

View file

@ -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);
}

View file

@ -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.

View file

@ -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();

View file

@ -164,7 +164,7 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
const DWORD obj_id = static_cast<DWORD>(l_param);
if (obj_id != OBJID_CLIENT) {
if (obj_id != static_cast<DWORD>(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

View file

@ -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<net::X509Certificate>& 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();
}

View file

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

View file

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

View file

@ -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;
}
}

View file

@ -29,8 +29,8 @@ MenuBar::MenuBar(views::View* window)
: background_color_(kDefaultColor), window_(window) {
RefreshColorCache();
UpdateViewColors();
SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::kHorizontal));
SetLayoutManager(
std::make_unique<views::BoxLayout>(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<SubmenuButton*>(child);
auto* button = static_cast<SubmenuButton*>(child);
button->SetUnderlineColor(color_utils::GetSysSkColor(COLOR_MENUTEXT));
}
#endif

View file

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

View file

@ -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(

View file

@ -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<JumpListItem>* removed_items) {
DCHECK(destinations_);
if (!destinations_)

View file

@ -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<JumpListItem> 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

View file

@ -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,

View file

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

View file

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

View file

@ -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

View file

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

View file

@ -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;

View file

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

View file

@ -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<LPTSTR>(&message), 0, NULL);
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
0, hr, 0, reinterpret_cast<LPTSTR>(&message), 0, NULL);
LOG(WARNING) << " " << __FUNCTION__ << "(): Can't open full_path = \""
<< full_path.value() << "\""
<< " hr = " << hr << " " << reinterpret_cast<LPTSTR>(&message);

View file

@ -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_;

View file

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