refactor: remove InspectableWebContentsViewMac in favor of the Views version (#41326)
This commit is contained in:
parent
814ba71dc1
commit
e67ab9a93d
20 changed files with 304 additions and 956 deletions
|
@ -9,27 +9,28 @@
|
|||
#include <string>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
#include "ui/views/view.h"
|
||||
|
||||
class DevToolsContentsResizingStrategy;
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
namespace views {
|
||||
class View;
|
||||
}
|
||||
#endif
|
||||
class WebView;
|
||||
class Widget;
|
||||
class WidgetDelegate;
|
||||
} // namespace views
|
||||
|
||||
namespace electron {
|
||||
|
||||
class InspectableWebContents;
|
||||
class InspectableWebContentsViewDelegate;
|
||||
|
||||
class InspectableWebContentsView {
|
||||
class InspectableWebContentsView : public views::View {
|
||||
public:
|
||||
explicit InspectableWebContentsView(
|
||||
InspectableWebContents* inspectable_web_contents);
|
||||
virtual ~InspectableWebContentsView();
|
||||
~InspectableWebContentsView() override;
|
||||
|
||||
InspectableWebContents* inspectable_web_contents() {
|
||||
return inspectable_web_contents_;
|
||||
|
@ -41,31 +42,38 @@ class InspectableWebContentsView {
|
|||
}
|
||||
InspectableWebContentsViewDelegate* GetDelegate() const { return delegate_; }
|
||||
|
||||
#if defined(TOOLKIT_VIEWS) && !BUILDFLAG(IS_MAC)
|
||||
// Returns the container control, which has devtools view attached.
|
||||
virtual views::View* GetView() = 0;
|
||||
#else
|
||||
virtual gfx::NativeView GetNativeView() const = 0;
|
||||
void ShowDevTools(bool activate);
|
||||
void CloseDevTools();
|
||||
bool IsDevToolsViewShowing();
|
||||
bool IsDevToolsViewFocused();
|
||||
void SetIsDocked(bool docked, bool activate);
|
||||
void SetContentsResizingStrategy(
|
||||
const DevToolsContentsResizingStrategy& strategy);
|
||||
void SetTitle(const std::u16string& title);
|
||||
const std::u16string GetTitle();
|
||||
|
||||
// views::View:
|
||||
void Layout(PassKey) override;
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
bool OnMousePressed(const ui::MouseEvent& event) override;
|
||||
#endif
|
||||
|
||||
virtual void ShowDevTools(bool activate) = 0;
|
||||
// Hide the DevTools view.
|
||||
virtual void CloseDevTools() = 0;
|
||||
virtual bool IsDevToolsViewShowing() = 0;
|
||||
virtual bool IsDevToolsViewFocused() = 0;
|
||||
virtual void SetIsDocked(bool docked, bool activate) = 0;
|
||||
virtual void SetContentsResizingStrategy(
|
||||
const DevToolsContentsResizingStrategy& strategy) = 0;
|
||||
virtual void SetTitle(const std::u16string& title) = 0;
|
||||
virtual const std::u16string GetTitle() = 0;
|
||||
|
||||
protected:
|
||||
private:
|
||||
// Owns us.
|
||||
raw_ptr<InspectableWebContents> inspectable_web_contents_;
|
||||
|
||||
private:
|
||||
raw_ptr<InspectableWebContentsViewDelegate> delegate_ =
|
||||
nullptr; // weak references.
|
||||
|
||||
std::unique_ptr<views::Widget> devtools_window_;
|
||||
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;
|
||||
raw_ptr<views::WidgetDelegate> devtools_window_delegate_ = nullptr;
|
||||
std::u16string title_;
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue