Skip to content

Commit 4be1052

Browse files
authored
chore: use auto to avoid repeating type (electron#26113)
1 parent f714556 commit 4be1052

25 files changed

Lines changed: 38 additions & 48 deletions

shell/browser/api/electron_api_debugger.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
5454
base::JSON_REPLACE_INVALID_CHARACTERS);
5555
if (!parsed_message || !parsed_message->is_dict())
5656
return;
57-
base::DictionaryValue* dict =
58-
static_cast<base::DictionaryValue*>(parsed_message.get());
57+
auto* dict = static_cast<base::DictionaryValue*>(parsed_message.get());
5958
int id;
6059
if (!dict->GetInteger("id", &id)) {
6160
std::string method;

shell/browser/api/electron_api_download_item.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ gin::WrapperInfo DownloadItem::kWrapperInfo = {gin::kEmbedderNativeGin};
7777
DownloadItem* DownloadItem::FromDownloadItem(
7878
download::DownloadItem* download_item) {
7979
// ^- say that 7 times fast in a row
80-
UserDataLink* data = static_cast<UserDataLink*>(
80+
auto* data = static_cast<UserDataLink*>(
8181
download_item->GetUserData(kElectronApiDownloadItemKey));
8282
return data ? data->download_item.get() : nullptr;
8383
}

shell/browser/api/electron_api_power_monitor_win.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ LRESULT CALLBACK PowerMonitor::WndProcStatic(HWND hwnd,
5858
UINT message,
5959
WPARAM wparam,
6060
LPARAM lparam) {
61-
PowerMonitor* msg_wnd =
61+
auto* msg_wnd =
6262
reinterpret_cast<PowerMonitor*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
6363
if (msg_wnd)
6464
return msg_wnd->WndProc(hwnd, message, wparam, lparam);

shell/browser/api/electron_api_session.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ bool Session::RemoveWordFromSpellCheckerDictionary(const std::string& word) {
10441044

10451045
// static
10461046
Session* Session::FromBrowserContext(content::BrowserContext* context) {
1047-
UserDataLink* data =
1047+
auto* data =
10481048
static_cast<UserDataLink*>(context->GetUserData(kElectronApiSessionKey));
10491049
return data ? data->session : nullptr;
10501050
}

shell/browser/api/electron_api_system_preferences_win.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ LRESULT CALLBACK SystemPreferences::WndProcStatic(HWND hwnd,
218218
UINT message,
219219
WPARAM wparam,
220220
LPARAM lparam) {
221-
SystemPreferences* msg_wnd = reinterpret_cast<SystemPreferences*>(
221+
auto* msg_wnd = reinterpret_cast<SystemPreferences*>(
222222
GetWindowLongPtr(hwnd, GWLP_USERDATA));
223223
if (msg_wnd)
224224
return msg_wnd->WndProc(hwnd, message, wparam, lparam);

shell/browser/api/electron_api_web_contents.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3081,7 +3081,7 @@ gin::Handle<WebContents> WebContents::CreateAndTake(
30813081
WebContents* WebContents::From(content::WebContents* web_contents) {
30823082
if (!web_contents)
30833083
return nullptr;
3084-
UserDataLink* data = static_cast<UserDataLink*>(
3084+
auto* data = static_cast<UserDataLink*>(
30853085
web_contents->GetUserData(kElectronApiWebContentsKey));
30863086
return data ? data->web_contents.get() : nullptr;
30873087
}

shell/browser/api/process_metric.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ ProcessIntegrityLevel ProcessMetric::GetIntegrityLevel() const {
105105
}
106106

107107
auto token_label_bytes = std::make_unique<char[]>(token_info_length);
108-
TOKEN_MANDATORY_LABEL* token_label =
108+
auto* token_label =
109109
reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_label_bytes.get());
110110
if (!::GetTokenInformation(token, TokenIntegrityLevel, token_label,
111111
token_info_length, &token_info_length)) {

shell/browser/electron_browser_client.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ ElectronBrowserClient::CreateWindowForPictureInPicture(
922922
#if defined(OS_WIN)
923923
base::string16 app_user_model_id = Browser::Get()->GetAppUserModelID();
924924
if (!app_user_model_id.empty()) {
925-
OverlayWindowViews* overlay_window_view =
925+
auto* overlay_window_view =
926926
static_cast<OverlayWindowViews*>(overlay_window.get());
927927
ui::win::SetAppIdForWindow(app_user_model_id,
928928
overlay_window_view->GetNativeWindow()

shell/browser/electron_download_manager_delegate.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ void ElectronDownloadManagerDelegate::OnDownloadSaveDialogDone(
153153
if (!canceled) {
154154
if (result.Get("filePath", &path)) {
155155
// Remember the last selected download directory.
156-
ElectronBrowserContext* browser_context =
157-
static_cast<ElectronBrowserContext*>(
158-
download_manager_->GetBrowserContext());
156+
auto* browser_context = static_cast<ElectronBrowserContext*>(
157+
download_manager_->GetBrowserContext());
159158
browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
160159
path.DirName());
161160

@@ -211,9 +210,8 @@ bool ElectronDownloadManagerDelegate::DetermineDownloadTarget(
211210
return true;
212211
}
213212

214-
ElectronBrowserContext* browser_context =
215-
static_cast<ElectronBrowserContext*>(
216-
download_manager_->GetBrowserContext());
213+
auto* browser_context = static_cast<ElectronBrowserContext*>(
214+
download_manager_->GetBrowserContext());
217215
base::FilePath default_download_path =
218216
browser_context->prefs()->GetFilePath(prefs::kDownloadDefaultDirectory);
219217

shell/browser/native_window_views.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,8 +1384,7 @@ void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* changed_widget,
13841384
int width_delta = new_bounds.width() - widget_size_.width();
13851385
int height_delta = new_bounds.height() - widget_size_.height();
13861386
for (NativeBrowserView* item : browser_views()) {
1387-
NativeBrowserViewViews* native_view =
1388-
static_cast<NativeBrowserViewViews*>(item);
1387+
auto* native_view = static_cast<NativeBrowserViewViews*>(item);
13891388
native_view->SetAutoResizeProportions(widget_size_);
13901389
native_view->AutoResize(new_bounds, width_delta, height_delta);
13911390
}
@@ -1453,7 +1452,7 @@ bool NativeWindowViews::ShouldDescendIntoChildForEventHandling(
14531452

14541453
// And the events on border for dragging resizable frameless window.
14551454
if (!has_frame() && CanResize()) {
1456-
FramelessView* frame =
1455+
auto* frame =
14571456
static_cast<FramelessView*>(widget()->non_client_view()->frame_view());
14581457
return frame->ResizingBorderHitTest(location) == HTNOWHERE;
14591458
}

0 commit comments

Comments
 (0)