Browse Source

chore: use auto to avoid repeating type (#26256)

David Sanders 4 years ago
parent
commit
a64a3e8aa9

+ 1 - 2
shell/browser/api/electron_api_debugger.cc

@@ -51,8 +51,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;

+ 1 - 1
shell/browser/api/electron_api_power_monitor_win.cc

@@ -57,7 +57,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);

+ 1 - 1
shell/browser/api/electron_api_system_preferences_win.cc

@@ -217,7 +217,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);

+ 1 - 1
shell/browser/api/process_metric.cc

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

+ 4 - 6
shell/browser/electron_download_manager_delegate.cc

@@ -159,9 +159,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());
 
@@ -220,9 +219,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);
 

+ 2 - 3
shell/browser/native_window_views.cc

@@ -1329,8 +1329,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);
     }
@@ -1398,7 +1397,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;
   }

+ 1 - 1
shell/browser/native_window_views_win.cc

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

+ 1 - 2
shell/browser/notifications/platform_notification_service.cc

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

+ 1 - 2
shell/browser/osr/osr_render_widget_host_view.cc

@@ -385,8 +385,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(

+ 5 - 7
shell/browser/osr/osr_web_contents_view.cc

@@ -127,15 +127,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_,

+ 1 - 1
shell/browser/ui/views/autofill_popup_view.cc

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

+ 1 - 1
shell/browser/ui/views/inspectable_web_contents_view_views.cc

@@ -91,7 +91,7 @@ InspectableWebContentsViewViews::InspectableWebContentsViewViews(
 
   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;

+ 1 - 1
shell/browser/ui/views/menu_bar.cc

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

+ 1 - 1
shell/browser/ui/views/menu_delegate.cc

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

+ 5 - 5
shell/browser/ui/win/notify_icon_host.cc

@@ -87,7 +87,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.";
@@ -95,7 +95,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);
 
@@ -119,7 +119,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);
@@ -135,7 +135,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;
@@ -145,7 +145,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;

+ 1 - 1
shell/common/api/electron_bindings.cc

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

+ 1 - 1
shell/common/gin_helper/callback.cc

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

+ 2 - 4
shell/common/gin_helper/wrappable.cc

@@ -63,8 +63,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);
@@ -74,8 +73,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;
 }

+ 1 - 1
shell/common/node_bindings.cc

@@ -462,7 +462,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.

+ 1 - 1
shell/common/skia_util.cc

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