Skip to content

Commit

Permalink
chore: use auto to avoid repeating type (#26255)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 committed Oct 29, 2020
1 parent ffd1e9b commit 6147bd7
Show file tree
Hide file tree
Showing 22 changed files with 35 additions and 45 deletions.
3 changes: 1 addition & 2 deletions shell/browser/api/electron_api_debugger.cc
Expand Up @@ -53,8 +53,7 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
base::JSON_REPLACE_INVALID_CHARACTERS);
if (!parsed_message || !parsed_message->is_dict())
return;
base::DictionaryValue* dict =
static_cast<base::DictionaryValue*>(parsed_message.get());
auto* dict = static_cast<base::DictionaryValue*>(parsed_message.get());
int id;
if (!dict->GetInteger("id", &id)) {
std::string method;
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_download_item.cc
Expand Up @@ -77,7 +77,7 @@ gin::WrapperInfo DownloadItem::kWrapperInfo = {gin::kEmbedderNativeGin};
DownloadItem* DownloadItem::FromDownloadItem(
download::DownloadItem* download_item) {
// ^- say that 7 times fast in a row
UserDataLink* data = static_cast<UserDataLink*>(
auto* data = static_cast<UserDataLink*>(
download_item->GetUserData(kElectronApiDownloadItemKey));
return data ? data->download_item.get() : nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_power_monitor_win.cc
Expand Up @@ -59,7 +59,7 @@ LRESULT CALLBACK PowerMonitor::WndProcStatic(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
PowerMonitor* msg_wnd =
auto* msg_wnd =
reinterpret_cast<PowerMonitor*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (msg_wnd)
return msg_wnd->WndProc(hwnd, message, wparam, lparam);
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_session.cc
Expand Up @@ -930,7 +930,7 @@ bool Session::RemoveWordFromSpellCheckerDictionary(const std::string& word) {

// static
Session* Session::FromBrowserContext(content::BrowserContext* context) {
UserDataLink* data =
auto* data =
static_cast<UserDataLink*>(context->GetUserData(kElectronApiSessionKey));
return data ? data->session : nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_system_preferences_win.cc
Expand Up @@ -218,7 +218,7 @@ LRESULT CALLBACK SystemPreferences::WndProcStatic(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
SystemPreferences* msg_wnd = reinterpret_cast<SystemPreferences*>(
auto* msg_wnd = reinterpret_cast<SystemPreferences*>(
GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (msg_wnd)
return msg_wnd->WndProc(hwnd, message, wparam, lparam);
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/process_metric.cc
Expand Up @@ -101,7 +101,7 @@ ProcessIntegrityLevel ProcessMetric::GetIntegrityLevel() const {
}

auto token_label_bytes = std::make_unique<char[]>(token_info_length);
TOKEN_MANDATORY_LABEL* token_label =
auto* token_label =
reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_label_bytes.get());
if (!::GetTokenInformation(token, TokenIntegrityLevel, token_label,
token_info_length, &token_info_length)) {
Expand Down
10 changes: 4 additions & 6 deletions shell/browser/electron_download_manager_delegate.cc
Expand Up @@ -152,9 +152,8 @@ void ElectronDownloadManagerDelegate::OnDownloadSaveDialogDone(
if (!canceled) {
if (result.Get("filePath", &path)) {
// Remember the last selected download directory.
ElectronBrowserContext* browser_context =
static_cast<ElectronBrowserContext*>(
download_manager_->GetBrowserContext());
auto* browser_context = static_cast<ElectronBrowserContext*>(
download_manager_->GetBrowserContext());
browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
path.DirName());

Expand Down Expand Up @@ -210,9 +209,8 @@ bool ElectronDownloadManagerDelegate::DetermineDownloadTarget(
return true;
}

ElectronBrowserContext* browser_context =
static_cast<ElectronBrowserContext*>(
download_manager_->GetBrowserContext());
auto* browser_context = static_cast<ElectronBrowserContext*>(
download_manager_->GetBrowserContext());
base::FilePath default_download_path =
browser_context->prefs()->GetFilePath(prefs::kDownloadDefaultDirectory);

Expand Down
5 changes: 2 additions & 3 deletions shell/browser/native_window_views.cc
Expand Up @@ -1335,8 +1335,7 @@ void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* changed_widget,
int width_delta = new_bounds.width() - widget_size_.width();
int height_delta = new_bounds.height() - widget_size_.height();
for (NativeBrowserView* item : browser_views()) {
NativeBrowserViewViews* native_view =
static_cast<NativeBrowserViewViews*>(item);
auto* native_view = static_cast<NativeBrowserViewViews*>(item);
native_view->SetAutoResizeProportions(widget_size_);
native_view->AutoResize(new_bounds, width_delta, height_delta);
}
Expand Down Expand Up @@ -1404,7 +1403,7 @@ bool NativeWindowViews::ShouldDescendIntoChildForEventHandling(

// And the events on border for dragging resizable frameless window.
if (!has_frame() && CanResize()) {
FramelessView* frame =
auto* frame =
static_cast<FramelessView*>(widget()->non_client_view()->frame_view());
return frame->ResizingBorderHitTest(location) == HTNOWHERE;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/native_window_views_win.cc
Expand Up @@ -391,7 +391,7 @@ LRESULT CALLBACK NativeWindowViews::SubclassProc(HWND hwnd,
LPARAM l_param,
UINT_PTR subclass_id,
DWORD_PTR ref_data) {
NativeWindowViews* window = reinterpret_cast<NativeWindowViews*>(ref_data);
auto* window = reinterpret_cast<NativeWindowViews*>(ref_data);
switch (msg) {
case WM_MOUSELEAVE: {
// When input is forwarded to underlying windows, this message is posted.
Expand Down
3 changes: 1 addition & 2 deletions shell/browser/notifications/platform_notification_service.cc
Expand Up @@ -96,8 +96,7 @@ void PlatformNotificationService::DisplayNotification(
// See: https://notifications.spec.whatwg.org/#showing-a-notification
presenter->CloseNotificationWithId(notification_id);

NotificationDelegateImpl* delegate =
new NotificationDelegateImpl(notification_id);
auto* delegate = new NotificationDelegateImpl(notification_id);

auto notification = presenter->CreateNotification(delegate, notification_id);
if (notification) {
Expand Down
3 changes: 1 addition & 2 deletions shell/browser/osr/osr_render_widget_host_view.cc
Expand Up @@ -386,8 +386,7 @@ void OffScreenRenderWidgetHostView::TakeFallbackContentFrom(
content::RenderWidgetHostView* view) {
DCHECK(!static_cast<content::RenderWidgetHostViewBase*>(view)
->IsRenderWidgetHostViewChildFrame());
OffScreenRenderWidgetHostView* view_osr =
static_cast<OffScreenRenderWidgetHostView*>(view);
auto* view_osr = static_cast<OffScreenRenderWidgetHostView*>(view);
SetBackgroundColor(view_osr->background_color_);
if (GetDelegatedFrameHost() && view_osr->GetDelegatedFrameHost()) {
GetDelegatedFrameHost()->TakeFallbackContentFrom(
Expand Down
12 changes: 5 additions & 7 deletions shell/browser/osr/osr_web_contents_view.cc
Expand Up @@ -126,15 +126,13 @@ OffScreenWebContentsView::CreateViewForWidget(
content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForChildWidget(
content::RenderWidgetHost* render_widget_host) {
content::WebContentsImpl* web_contents_impl =
auto* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);

OffScreenRenderWidgetHostView* view =
static_cast<OffScreenRenderWidgetHostView*>(
web_contents_impl->GetOuterWebContents()
? web_contents_impl->GetOuterWebContents()
->GetRenderWidgetHostView()
: web_contents_impl->GetRenderWidgetHostView());
auto* view = static_cast<OffScreenRenderWidgetHostView*>(
web_contents_impl->GetOuterWebContents()
? web_contents_impl->GetOuterWebContents()->GetRenderWidgetHostView()
: web_contents_impl->GetRenderWidgetHostView());

return new OffScreenRenderWidgetHostView(transparent_, painting_,
view->GetFrameRate(), callback_,
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/ui/views/autofill_popup_view.cc
Expand Up @@ -72,7 +72,7 @@ void AutofillPopupView::Show() {
// The widget is destroyed by the corresponding NativeWidget, so we use
// a weak pointer to hold the reference and don't have to worry about
// deletion.
views::Widget* widget = new views::Widget;
auto* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.delegate = this;
params.parent = parent_widget_->GetNativeView();
Expand Down
Expand Up @@ -89,7 +89,7 @@ InspectableWebContentsViewViews::InspectableWebContentsViewViews(
title_(base::ASCIIToUTF16("Developer Tools")) {
if (!inspectable_web_contents_->IsGuest() &&
inspectable_web_contents_->GetWebContents()->GetNativeView()) {
views::WebView* contents_web_view = new views::WebView(nullptr);
auto* contents_web_view = new views::WebView(nullptr);
contents_web_view->SetWebContents(
inspectable_web_contents_->GetWebContents());
contents_web_view_ = contents_web_view;
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/ui/views/menu_bar.cc
Expand Up @@ -272,7 +272,7 @@ void MenuBar::ButtonPressed(views::Button* source, const ui::Event& event) {
}

// Deleted in MenuDelegate::OnMenuClosed
MenuDelegate* menu_delegate = new MenuDelegate(this);
auto* menu_delegate = new MenuDelegate(this);
menu_delegate->RunMenu(
menu_model_->GetSubmenuModelAt(id), source,
event.IsKeyEvent() ? ui::MENU_SOURCE_KEYBOARD : ui::MENU_SOURCE_MOUSE);
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/ui/views/menu_delegate.cc
Expand Up @@ -39,7 +39,7 @@ void MenuDelegate::RunMenu(ElectronMenuModel* model,
id_ = button->tag();
adapter_ = std::make_unique<MenuModelAdapter>(model);

views::MenuItemView* item = new views::MenuItemView(this);
auto* item = new views::MenuItemView(this);
static_cast<MenuModelAdapter*>(adapter_.get())->BuildMenu(item);

menu_runner_ = std::make_unique<views::MenuRunner>(
Expand Down
10 changes: 5 additions & 5 deletions shell/browser/ui/win/notify_icon_host.cc
Expand Up @@ -89,15 +89,15 @@ NotifyIcon* NotifyIconHost::CreateNotifyIcon(base::Optional<UUID> guid) {
if (guid.has_value()) {
for (NotifyIcons::const_iterator i(notify_icons_.begin());
i != notify_icons_.end(); ++i) {
NotifyIcon* current_win_icon = static_cast<NotifyIcon*>(*i);
auto* current_win_icon = static_cast<NotifyIcon*>(*i);
if (current_win_icon->guid() == guid.value()) {
LOG(WARNING)
<< "Guid already in use. Existing tray entry will be replaced.";
}
}
}

NotifyIcon* notify_icon =
auto* notify_icon =
new NotifyIcon(this, NextIconId(), window_, kNotifyIconMessage,
guid.has_value() ? guid.value() : GUID_DEFAULT);

Expand All @@ -121,7 +121,7 @@ LRESULT CALLBACK NotifyIconHost::WndProcStatic(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
NotifyIconHost* msg_wnd =
auto* msg_wnd =
reinterpret_cast<NotifyIconHost*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (msg_wnd)
return msg_wnd->WndProc(hwnd, message, wparam, lparam);
Expand All @@ -137,7 +137,7 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
// We need to reset all of our icons because the taskbar went away.
for (NotifyIcons::const_iterator i(notify_icons_.begin());
i != notify_icons_.end(); ++i) {
NotifyIcon* win_icon = static_cast<NotifyIcon*>(*i);
auto* win_icon = static_cast<NotifyIcon*>(*i);
win_icon->ResetIcon();
}
return TRUE;
Expand All @@ -147,7 +147,7 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
// Find the selected status icon.
for (NotifyIcons::const_iterator i(notify_icons_.begin());
i != notify_icons_.end(); ++i) {
NotifyIcon* current_win_icon = static_cast<NotifyIcon*>(*i);
auto* current_win_icon = static_cast<NotifyIcon*>(*i);
if (current_win_icon->icon_id() == wparam) {
win_icon = current_win_icon;
break;
Expand Down
2 changes: 1 addition & 1 deletion shell/common/api/electron_bindings.cc
Expand Up @@ -134,7 +134,7 @@ void ElectronBindings::ActivateUVLoop(v8::Isolate* isolate) {

// static
void ElectronBindings::OnCallNextTick(uv_async_t* handle) {
ElectronBindings* self = static_cast<ElectronBindings*>(handle->data);
auto* self = static_cast<ElectronBindings*>(handle->data);
for (std::list<node::Environment*>::const_iterator it =
self->pending_next_ticks_.begin();
it != self->pending_next_ticks_.end(); ++it) {
Expand Down
2 changes: 1 addition & 1 deletion shell/common/gin_helper/callback.cc
Expand Up @@ -55,7 +55,7 @@ void CallTranslater(v8::Local<v8::External> external,
}
}

TranslaterHolder* holder = static_cast<TranslaterHolder*>(external->Value());
auto* holder = static_cast<TranslaterHolder*>(external->Value());
holder->translater.Run(args);

// Free immediately for one-time callback.
Expand Down
6 changes: 2 additions & 4 deletions shell/common/gin_helper/wrappable.cc
Expand Up @@ -64,8 +64,7 @@ void WrappableBase::InitWith(v8::Isolate* isolate,
// static
void WrappableBase::FirstWeakCallback(
const v8::WeakCallbackInfo<WrappableBase>& data) {
WrappableBase* wrappable =
static_cast<WrappableBase*>(data.GetInternalField(0));
auto* wrappable = static_cast<WrappableBase*>(data.GetInternalField(0));
if (wrappable) {
wrappable->wrapper_.Reset();
data.SetSecondPassCallback(SecondWeakCallback);
Expand All @@ -75,8 +74,7 @@ void WrappableBase::FirstWeakCallback(
// static
void WrappableBase::SecondWeakCallback(
const v8::WeakCallbackInfo<WrappableBase>& data) {
WrappableBase* wrappable =
static_cast<WrappableBase*>(data.GetInternalField(0));
auto* wrappable = static_cast<WrappableBase*>(data.GetInternalField(0));
if (wrappable)
delete wrappable;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/common/node_bindings.cc
Expand Up @@ -534,7 +534,7 @@ void NodeBindings::WakeupEmbedThread() {

// static
void NodeBindings::EmbedThreadRunner(void* arg) {
NodeBindings* self = static_cast<NodeBindings*>(arg);
auto* self = static_cast<NodeBindings*>(arg);

while (true) {
// Wait for the main loop to deal with events.
Expand Down
2 changes: 1 addition & 1 deletion shell/common/skia_util.cc
Expand Up @@ -128,7 +128,7 @@ bool AddImageSkiaRepFromPath(gfx::ImageSkia* image,
return false;
}

const unsigned char* data =
const auto* data =
reinterpret_cast<const unsigned char*>(file_contents.data());
size_t size = file_contents.size();

Expand Down

0 comments on commit 6147bd7

Please sign in to comment.