chore: use auto to avoid repeating type (#26113)
This commit is contained in:
parent
f714556a12
commit
4be10523e8
25 changed files with 38 additions and 48 deletions
|
@ -54,8 +54,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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,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);
|
||||
|
|
|
@ -1044,7 +1044,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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -3081,7 +3081,7 @@ gin::Handle<WebContents> WebContents::CreateAndTake(
|
|||
WebContents* WebContents::From(content::WebContents* web_contents) {
|
||||
if (!web_contents)
|
||||
return nullptr;
|
||||
UserDataLink* data = static_cast<UserDataLink*>(
|
||||
auto* data = static_cast<UserDataLink*>(
|
||||
web_contents->GetUserData(kElectronApiWebContentsKey));
|
||||
return data ? data->web_contents.get() : nullptr;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,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)) {
|
||||
|
|
|
@ -922,7 +922,7 @@ ElectronBrowserClient::CreateWindowForPictureInPicture(
|
|||
#if defined(OS_WIN)
|
||||
base::string16 app_user_model_id = Browser::Get()->GetAppUserModelID();
|
||||
if (!app_user_model_id.empty()) {
|
||||
OverlayWindowViews* overlay_window_view =
|
||||
auto* overlay_window_view =
|
||||
static_cast<OverlayWindowViews*>(overlay_window.get());
|
||||
ui::win::SetAppIdForWindow(app_user_model_id,
|
||||
overlay_window_view->GetNativeWindow()
|
||||
|
|
|
@ -153,9 +153,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());
|
||||
|
||||
|
@ -211,9 +210,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);
|
||||
|
||||
|
|
|
@ -1384,8 +1384,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);
|
||||
}
|
||||
|
@ -1453,7 +1452,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;
|
||||
}
|
||||
|
|
|
@ -397,7 +397,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.
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -382,8 +382,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(
|
||||
|
|
|
@ -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_,
|
||||
|
|
|
@ -44,7 +44,7 @@ base::UnguessableToken DecodeToken(base::StringPiece input) {
|
|||
return base::UnguessableToken();
|
||||
}
|
||||
|
||||
const uint64_t* data = reinterpret_cast<const uint64_t*>(buffer.data());
|
||||
const auto* data = reinterpret_cast<const uint64_t*>(buffer.data());
|
||||
return base::UnguessableToken::Deserialize(data[0], data[1]);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>(
|
||||
|
|
|
@ -89,7 +89,7 @@ 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.";
|
||||
|
@ -97,7 +97,7 @@ NotifyIcon* NotifyIconHost::CreateNotifyIcon(base::Optional<UUID> guid) {
|
|||
}
|
||||
}
|
||||
|
||||
NotifyIcon* notify_icon =
|
||||
auto* notify_icon =
|
||||
new NotifyIcon(this, NextIconId(), window_, kNotifyIconMessage,
|
||||
guid.has_value() ? guid.value() : GUID_DEFAULT);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
|
|
@ -108,7 +108,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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -560,7 +560,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.
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue