chore: enable check raw ptr fields (#38167)

This commit is contained in:
John Kleinschmidt
2023-05-11 16:07:39 -04:00
committed by GitHub
parent 141175c723
commit 3dbc0a365f
120 changed files with 298 additions and 185 deletions

View File

@@ -8,6 +8,7 @@
#include <map>
#include <string>
#include "base/memory/raw_ptr.h"
#include "shell/browser/ui/electron_menu_model.h"
#include "ui/base/accelerators/accelerator.h"
@@ -15,7 +16,7 @@ namespace accelerator_util {
typedef struct {
size_t position;
electron::ElectronMenuModel* model;
raw_ptr<electron::ElectronMenuModel> model;
} MenuItem;
typedef std::map<ui::Accelerator, MenuItem> AcceleratorTable;

View File

@@ -7,6 +7,7 @@
#include <vector>
#include "base/memory/raw_ptr.h"
#include "content/public/browser/render_frame_host.h"
#include "shell/browser/ui/views/autofill_popup_view.h"
#include "ui/color/color_id.h"
@@ -79,13 +80,13 @@ class AutofillPopup : public views::ViewObserver {
// For sending the accepted suggestion to the render frame that
// asked to open the popup
content::RenderFrameHost* frame_host_ = nullptr;
raw_ptr<content::RenderFrameHost> frame_host_ = nullptr;
// The popup view. The lifetime is managed by the owning Widget
AutofillPopupView* view_ = nullptr;
raw_ptr<AutofillPopupView> view_ = nullptr;
// The parent view that the popup view shows on. Weak ref.
views::View* parent_ = nullptr;
raw_ptr<views::View> parent_ = nullptr;
};
} // namespace electron

View File

@@ -9,6 +9,7 @@
#ifndef ELECTRON_SHELL_BROWSER_UI_ELECTRON_DESKTOP_WINDOW_TREE_HOST_LINUX_H_
#define ELECTRON_SHELL_BROWSER_UI_ELECTRON_DESKTOP_WINDOW_TREE_HOST_LINUX_H_
#include "base/memory/raw_ptr.h"
#include "base/scoped_observation.h"
#include "shell/browser/native_window_views.h"
#include "shell/browser/ui/views/client_frame_view_linux.h"
@@ -59,7 +60,7 @@ class ElectronDesktopWindowTreeHostLinux
void UpdateClientDecorationHints(ClientFrameViewLinux* view);
void UpdateWindowState(ui::PlatformWindowState new_state);
NativeWindowViews* native_window_view_; // weak ref
raw_ptr<NativeWindowViews> native_window_view_; // weak ref
base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
theme_observation_{this};

View File

@@ -10,6 +10,7 @@
#include <vector>
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
@@ -112,7 +113,7 @@ class ElectronMenuModel : public ui::SimpleMenuModel {
ElectronMenuModel* GetSubmenuModelAt(size_t index);
private:
Delegate* delegate_; // weak ref.
raw_ptr<Delegate> delegate_; // weak ref.
#if BUILDFLAG(IS_MAC)
absl::optional<SharingItem> sharing_item_;

View File

@@ -10,6 +10,7 @@
#include <vector>
#include "base/files/file_path.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/promise.h"
@@ -44,7 +45,7 @@ enum SaveFileDialogProperty {
};
struct DialogSettings {
electron::NativeWindow* parent_window = nullptr;
RAW_PTR_EXCLUSION electron::NativeWindow* parent_window = nullptr;
std::string title;
std::string message;
std::string button_label;

View File

@@ -7,6 +7,8 @@
#include "base/files/file_util.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/strings/string_util.h"
#include "electron/electron_gtk_stubs.h"
#include "shell/browser/javascript_environment.h"
@@ -219,10 +221,10 @@ class FileChooserDialog {
private:
void AddFilters(const Filters& filters);
electron::NativeWindowViews* parent_;
raw_ptr<electron::NativeWindowViews> parent_;
GtkFileChooser* dialog_;
GtkWidget* preview_;
RAW_PTR_EXCLUSION GtkFileChooser* dialog_;
RAW_PTR_EXCLUSION GtkWidget* preview_;
Filters filters_;
std::unique_ptr<gin_helper::Promise<gin_helper::Dictionary>> save_promise_;

View File

@@ -13,6 +13,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/strings/pattern.h"
@@ -314,7 +315,7 @@ class InspectableWebContents::NetworkResourceLoader
void OnRetry(base::OnceClosure start_retry) override {}
const int stream_id_;
InspectableWebContents* const bindings_;
raw_ptr<InspectableWebContents> const bindings_;
const network::ResourceRequest resource_request_;
const net::NetworkTrafficAnnotationTag traffic_annotation_;
std::unique_ptr<network::SimpleURLLoader> loader_;

View File

@@ -15,6 +15,7 @@
#include "base/containers/span.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
#include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h"
@@ -211,9 +212,10 @@ class InspectableWebContents
std::string dock_state_;
bool activate_ = true;
InspectableWebContentsDelegate* delegate_ = nullptr; // weak references.
raw_ptr<InspectableWebContentsDelegate> delegate_ =
nullptr; // weak references.
PrefService* pref_service_; // weak reference.
raw_ptr<PrefService> pref_service_; // weak reference.
std::unique_ptr<content::WebContents> web_contents_;
@@ -221,7 +223,7 @@ class InspectableWebContents
// one assigned by SetDevToolsWebContents.
std::unique_ptr<content::WebContents> managed_devtools_web_contents_;
// The external devtools assigned by SetDevToolsWebContents.
content::WebContents* external_devtools_web_contents_ = nullptr;
raw_ptr<content::WebContents> external_devtools_web_contents_ = nullptr;
bool is_guest_;
std::unique_ptr<InspectableWebContentsView> view_;

View File

@@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "shell/common/api/api.mojom.h"
#include "ui/gfx/native_widget_types.h"
@@ -64,10 +65,11 @@ class InspectableWebContentsView {
protected:
// Owns us.
InspectableWebContents* inspectable_web_contents_;
raw_ptr<InspectableWebContents> inspectable_web_contents_;
private:
InspectableWebContentsViewDelegate* delegate_ = nullptr; // weak references.
raw_ptr<InspectableWebContentsViewDelegate> delegate_ =
nullptr; // weak references.
};
} // namespace electron

View File

@@ -9,6 +9,7 @@
#include <vector>
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/image/image_skia.h"
@@ -25,7 +26,7 @@ enum class MessageBoxType {
};
struct MessageBoxSettings {
electron::NativeWindow* parent_window = nullptr;
RAW_PTR_EXCLUSION electron::NativeWindow* parent_window = nullptr;
MessageBoxType type = electron::MessageBoxType::kNone;
std::vector<std::string> buttons;
absl::optional<int> id;

View File

@@ -8,6 +8,8 @@
#include "base/containers/contains.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/no_destructor.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -194,8 +196,8 @@ class GtkMessageBox : public NativeWindowObserver {
bool checkbox_checked_ = false;
NativeWindow* parent_;
GtkWidget* dialog_;
raw_ptr<NativeWindow> parent_;
RAW_PTR_EXCLUSION GtkWidget* dialog_;
MessageBoxCallback callback_;
};

View File

@@ -9,6 +9,7 @@
#include "shell/browser/ui/autofill_popup.h"
#include "base/memory/raw_ptr.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/render_widget_host.h"
#include "electron/buildflags/buildflags.h"
@@ -130,10 +131,10 @@ class AutofillPopupView : public views::WidgetDelegateView,
void RemoveObserver();
// Controller for this popup. Weak reference.
AutofillPopup* popup_;
raw_ptr<AutofillPopup> popup_;
// The widget of the window that triggered this popup. Weak reference.
views::Widget* parent_widget_;
raw_ptr<views::Widget> parent_widget_;
// The time when the popup was shown.
base::Time show_time_;

View File

@@ -9,6 +9,8 @@
#include <memory>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/scoped_observation.h"
#include "shell/browser/ui/views/frameless_view.h"
#include "ui/base/ui_base_types.h"
@@ -85,7 +87,7 @@ class ClientFrameViewLinux : public FramelessView,
void (views::Widget::*callback)();
int accessibility_id;
int hit_test_id;
views::ImageButton* button{nullptr};
RAW_PTR_EXCLUSION views::ImageButton* button{nullptr};
};
struct ThemeValues {
@@ -119,10 +121,10 @@ class ClientFrameViewLinux : public FramelessView,
gfx::Size SizeWithDecorations(gfx::Size size) const;
ui::NativeTheme* theme_;
raw_ptr<ui::NativeTheme> theme_;
ThemeValues theme_values_;
views::Label* title_;
RAW_PTR_EXCLUSION views::Label* title_;
std::unique_ptr<ui::NavButtonProvider> nav_button_provider_;
std::array<NavButton, kNavButtonCount> nav_buttons_;
@@ -132,7 +134,7 @@ class ClientFrameViewLinux : public FramelessView,
bool host_supports_client_frame_shadow_ = false;
ui::WindowFrameProvider* frame_provider_;
raw_ptr<ui::WindowFrameProvider> frame_provider_;
base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
native_theme_observer_{this};

View File

@@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_FRAMELESS_VIEW_H_
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_FRAMELESS_VIEW_H_
#include "base/memory/raw_ptr.h"
#include "ui/views/window/non_client_view.h"
namespace views {
@@ -57,8 +58,8 @@ class FramelessView : public views::NonClientFrameView {
const char* GetClassName() const override;
// Not owned.
NativeWindowViews* window_ = nullptr;
views::Widget* frame_ = nullptr;
raw_ptr<NativeWindowViews> window_ = nullptr;
raw_ptr<views::Widget> frame_ = nullptr;
friend class NativeWindowsViews;
};

View File

@@ -9,6 +9,7 @@
#include <set>
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
#include "ui/base/glib/glib_signal.h"
@@ -53,7 +54,7 @@ class GlobalMenuBarRegistrarX11 {
GObject*,
GParamSpec*);
GDBusProxy* registrar_proxy_ = nullptr;
raw_ptr<GDBusProxy> registrar_proxy_ = nullptr;
// x11::Window which want to be registered, but haven't yet been because
// we're waiting for the proxy to become available.

View File

@@ -8,6 +8,7 @@
#include <string>
#include "base/compiler_specific.h"
#include "base/memory/raw_ptr.h"
#include "shell/browser/ui/electron_menu_model.h"
#include "ui/base/glib/glib_signal.h"
#include "ui/gfx/native_widget_types.h"
@@ -72,10 +73,10 @@ class GlobalMenuBarX11 {
unsigned int);
CHROMEG_CALLBACK_0(GlobalMenuBarX11, void, OnSubMenuShow, DbusmenuMenuitem*);
NativeWindowViews* window_;
raw_ptr<NativeWindowViews> window_;
x11::Window xwindow_;
DbusmenuServer* server_ = nullptr;
raw_ptr<DbusmenuServer> server_ = nullptr;
};
} // namespace electron

View File

@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "shell/browser/ui/drag_util.h"
#include "shell/browser/ui/inspectable_web_contents.h"
@@ -66,9 +67,9 @@ class DevToolsWindowDelegate : public views::ClientView,
}
private:
InspectableWebContentsViewViews* shell_;
views::View* view_;
views::Widget* widget_;
raw_ptr<InspectableWebContentsViewViews> shell_;
raw_ptr<views::View> view_;
raw_ptr<views::Widget> widget_;
ui::ImageModel icon_;
};
@@ -95,8 +96,8 @@ InspectableWebContentsViewViews::InspectableWebContentsViewViews(
}
devtools_web_view_->SetVisible(false);
AddChildView(devtools_web_view_);
AddChildView(contents_web_view_);
AddChildView(devtools_web_view_.get());
AddChildView(contents_web_view_.get());
}
InspectableWebContentsViewViews::~InspectableWebContentsViewViews() {

View File

@@ -9,6 +9,7 @@
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
#include "shell/browser/ui/inspectable_web_contents_view.h"
#include "third_party/skia/include/core/SkRegion.h"
@@ -48,13 +49,13 @@ class InspectableWebContentsViewViews : public InspectableWebContentsView,
private:
std::unique_ptr<views::Widget> devtools_window_;
views::WebView* devtools_window_web_view_ = nullptr;
views::View* contents_web_view_ = nullptr;
views::WebView* devtools_web_view_ = nullptr;
raw_ptr<views::WebView> devtools_window_web_view_ = nullptr;
raw_ptr<views::View> contents_web_view_ = nullptr;
raw_ptr<views::WebView> devtools_web_view_ = nullptr;
DevToolsContentsResizingStrategy strategy_;
bool devtools_visible_ = false;
views::WidgetDelegate* devtools_window_delegate_ = nullptr;
raw_ptr<views::WidgetDelegate> devtools_window_delegate_ = nullptr;
std::u16string title_;
};

View File

@@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_
#include "base/memory/raw_ptr.h"
#include "shell/browser/native_window_observer.h"
#include "shell/browser/ui/electron_menu_model.h"
#include "shell/browser/ui/views/menu_delegate.h"
@@ -87,9 +88,9 @@ class MenuBar : public views::AccessiblePaneView,
SkColor disabled_color_;
#endif
NativeWindow* window_;
RootView* root_view_;
ElectronMenuModel* menu_model_ = nullptr;
raw_ptr<NativeWindow> window_;
raw_ptr<RootView> root_view_;
raw_ptr<ElectronMenuModel> menu_model_ = nullptr;
bool accelerator_installed_ = false;
};

View File

@@ -7,6 +7,7 @@
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "shell/browser/ui/electron_menu_model.h"
#include "ui/views/controls/menu/menu_delegate.h"
@@ -66,13 +67,13 @@ class MenuDelegate : public views::MenuDelegate {
views::MenuButton** button) override;
private:
MenuBar* menu_bar_;
raw_ptr<MenuBar> menu_bar_;
int id_ = -1;
std::unique_ptr<views::MenuDelegate> adapter_;
std::unique_ptr<views::MenuRunner> menu_runner_;
// The menu button to switch to.
views::MenuButton* button_to_open_ = nullptr;
raw_ptr<views::MenuButton> button_to_open_ = nullptr;
bool hold_first_switch_ = false;
base::ObserverList<Observer>::Unchecked observers_;

View File

@@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_MODEL_ADAPTER_H_
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_MODEL_ADAPTER_H_
#include "base/memory/raw_ptr.h"
#include "shell/browser/ui/electron_menu_model.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
@@ -23,7 +24,7 @@ class MenuModelAdapter : public views::MenuModelAdapter {
bool GetAccelerator(int id, ui::Accelerator* accelerator) const override;
private:
ElectronMenuModel* menu_model_;
raw_ptr<ElectronMenuModel> menu_model_;
};
} // namespace electron

View File

@@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_NATIVE_FRAME_VIEW_H_
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_NATIVE_FRAME_VIEW_H_
#include "base/memory/raw_ptr.h"
#include "ui/views/window/native_frame_view.h"
namespace electron {
@@ -29,7 +30,7 @@ class NativeFrameView : public views::NativeFrameView {
const char* GetClassName() const override;
private:
NativeWindow* window_; // weak ref.
raw_ptr<NativeWindow> window_; // weak ref.
};
} // namespace electron

View File

@@ -7,6 +7,7 @@
#include <memory>
#include "base/memory/raw_ptr.h"
#include "shell/browser/ui/accelerator_util.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/view.h"
@@ -53,7 +54,7 @@ class RootView : public views::View {
private:
// Parent window, weak ref.
NativeWindow* window_;
raw_ptr<NativeWindow> window_;
// Menu bar.
std::unique_ptr<MenuBar> menu_bar_;