2018-10-19 13:50:30 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Copyright (c) 2013 Adam Roben <adam@roben.org>. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_INSPECTABLE_WEB_CONTENTS_VIEW_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_INSPECTABLE_WEB_CONTENTS_VIEW_H_
|
2013-03-14 13:03:50 +00:00
|
|
|
|
2021-03-16 19:43:51 +00:00
|
|
|
#include <string>
|
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2024-03-04 17:32:40 +00:00
|
|
|
#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
|
2023-07-16 14:14:43 +00:00
|
|
|
#include "electron/shell/common/api/api.mojom.h"
|
2013-03-14 13:03:50 +00:00
|
|
|
#include "ui/gfx/native_widget_types.h"
|
2024-03-04 17:32:40 +00:00
|
|
|
#include "ui/views/view.h"
|
2013-03-14 13:03:50 +00:00
|
|
|
|
2014-07-02 08:21:47 +00:00
|
|
|
class DevToolsContentsResizingStrategy;
|
2014-07-04 08:25:59 +00:00
|
|
|
namespace views {
|
2024-03-04 17:32:40 +00:00
|
|
|
class WebView;
|
|
|
|
class Widget;
|
|
|
|
class WidgetDelegate;
|
|
|
|
} // namespace views
|
2014-07-04 08:25:59 +00:00
|
|
|
|
2018-10-19 13:50:30 +00:00
|
|
|
namespace electron {
|
2013-03-14 13:03:50 +00:00
|
|
|
|
2022-10-17 15:10:07 +00:00
|
|
|
class InspectableWebContents;
|
2015-06-25 04:29:34 +00:00
|
|
|
class InspectableWebContentsViewDelegate;
|
|
|
|
|
2024-03-04 17:32:40 +00:00
|
|
|
class InspectableWebContentsView : public views::View {
|
2013-11-17 23:23:13 +00:00
|
|
|
public:
|
2022-10-17 15:10:07 +00:00
|
|
|
explicit InspectableWebContentsView(
|
|
|
|
InspectableWebContents* inspectable_web_contents);
|
2024-03-04 17:32:40 +00:00
|
|
|
~InspectableWebContentsView() override;
|
2022-10-17 15:10:07 +00:00
|
|
|
|
|
|
|
InspectableWebContents* inspectable_web_contents() {
|
|
|
|
return inspectable_web_contents_;
|
|
|
|
}
|
2013-03-14 13:03:50 +00:00
|
|
|
|
2015-06-25 04:29:34 +00:00
|
|
|
// The delegate manages its own life.
|
|
|
|
void SetDelegate(InspectableWebContentsViewDelegate* delegate) {
|
|
|
|
delegate_ = delegate;
|
|
|
|
}
|
2018-04-18 01:46:27 +00:00
|
|
|
InspectableWebContentsViewDelegate* GetDelegate() const { return delegate_; }
|
2015-06-25 04:29:34 +00:00
|
|
|
|
2024-03-04 17:32:40 +00:00
|
|
|
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;
|
2014-07-04 08:25:59 +00:00
|
|
|
#endif
|
|
|
|
|
2024-03-04 17:32:40 +00:00
|
|
|
private:
|
2022-10-17 15:10:07 +00:00
|
|
|
// Owns us.
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<InspectableWebContents> inspectable_web_contents_;
|
2022-10-17 15:10:07 +00:00
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<InspectableWebContentsViewDelegate> delegate_ =
|
|
|
|
nullptr; // weak references.
|
2024-03-04 17:32:40 +00:00
|
|
|
|
|
|
|
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_;
|
2013-03-14 13:03:50 +00:00
|
|
|
};
|
|
|
|
|
2018-10-19 13:50:30 +00:00
|
|
|
} // namespace electron
|
2013-03-14 13:03:50 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_INSPECTABLE_WEB_CONTENTS_VIEW_H_
|