}
WebContents::WebContents(content::WebContents* web_contents)
- : CommonWebContentsDelegate(false),
- content::WebContentsObserver(web_contents),
+ : content::WebContentsObserver(web_contents),
guest_opaque_(true),
guest_host_(nullptr),
auto_size_enabled_(false),
}
WebContents::WebContents(const mate::Dictionary& options)
- : CommonWebContentsDelegate(true),
- guest_opaque_(true),
+ : guest_opaque_(true),
guest_host_(nullptr),
auto_size_enabled_(false),
is_full_page_plugin_(false),
return CommonWebContentsDelegate::OpenURLFromTab(source, params);
}
+bool WebContents::IsPopupOrPanel(const content::WebContents* source) const {
+ return type_ == BROWSER_WINDOW;
+}
+
void WebContents::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
}
void WebContents::RenderViewReady() {
- if (!is_guest())
+ if (type_ != WEB_VIEW)
return;
// We don't want to accidentally set the opacity of an interstitial page.
}
void WebContents::Destroy() {
- if (is_guest() && managed_web_contents()) {
+ if (type_ == WEB_VIEW && managed_web_contents()) {
// When force destroying the "destroyed" event is not emitted.
WebContentsDestroyed();
}
void WebContents::OpenDevTools(mate::Arguments* args) {
- if (!inspectable_web_contents())
+ if (type_ == REMOTE)
return;
+
bool detach = false;
- if (is_guest()) {
+ if (type_ == WEB_VIEW) {
detach = true;
} else if (args && args->Length() == 1) {
mate::Dictionary options;
}
void WebContents::CloseDevTools() {
- if (!inspectable_web_contents())
+ if (type_ == REMOTE)
return;
+
inspectable_web_contents()->CloseDevTools();
}
bool WebContents::IsDevToolsOpened() {
- if (!inspectable_web_contents())
+ if (type_ == REMOTE)
return false;
return inspectable_web_contents()->IsDevToolsViewShowing();
}
}
void WebContents::InspectElement(int x, int y) {
- if (!inspectable_web_contents())
+ if (type_ == REMOTE)
return;
+
OpenDevTools(nullptr);
scoped_refptr<content::DevToolsAgentHost> agent(
content::DevToolsAgentHost::GetOrCreateFor(web_contents()));
}
void WebContents::InspectServiceWorker() {
- if (!inspectable_web_contents())
+ if (type_ == REMOTE)
return;
+
for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) {
if (agent_host->GetType() ==
content::DevToolsAgentHost::TYPE_SERVICE_WORKER) {
}
bool WebContents::IsGuest() const {
- return is_guest();
+ return type_ == WEB_VIEW;
}
mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
} // namespace
-CommonWebContentsDelegate::CommonWebContentsDelegate(bool is_guest)
- : is_guest_(is_guest),
- owner_window_(nullptr),
+CommonWebContentsDelegate::CommonWebContentsDelegate()
+ : owner_window_(nullptr),
html_fullscreen_(false),
native_fullscreen_(false) {
}
return false;
}
-bool CommonWebContentsDelegate::IsPopupOrPanel(
- const content::WebContents* source) const {
- return !is_guest_;
-}
-
content::JavaScriptDialogManager*
CommonWebContentsDelegate::GetJavaScriptDialogManager(
content::WebContents* source) {
: public brightray::DefaultWebContentsDelegate,
public brightray::InspectableWebContentsDelegate {
public:
- explicit CommonWebContentsDelegate(bool is_guest);
+ CommonWebContentsDelegate();
virtual ~CommonWebContentsDelegate();
// Create a InspectableWebContents object and takes onwership of
return web_contents_.get();
}
- bool is_guest() const { return is_guest_; }
-
protected:
// content::WebContentsDelegate:
content::WebContents* OpenURLFromTab(
bool user_gesture,
bool last_unlocked_by_target) override;
bool CanOverscrollContent() const override;
- bool IsPopupOrPanel(const content::WebContents* source) const override;
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) override;
content::ColorChooser* OpenColorChooser(
// Set fullscreen mode triggered by html api.
void SetHtmlApiFullscreen(bool enter_fullscreen);
- // Whether this is guest WebContents or NativeWindow.
- const bool is_guest_;
-
// The window that this WebContents belongs to.
NativeWindow* owner_window_;