2017-08-04 00:55:19 +02:00
|
|
|
// Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
|
|
|
|
// 2013 The Chromium Authors. All rights reserved. Use of this source code is
|
|
|
|
// governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2021-12-16 23:35:54 +01:00
|
|
|
#include "base/scoped_observation.h"
|
2017-08-04 00:55:19 +02:00
|
|
|
#include "extensions/browser/extension_host.h"
|
2021-12-16 23:35:54 +01:00
|
|
|
#include "extensions/browser/extension_host_registry.h"
|
2017-08-04 00:55:19 +02:00
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
class AlloyBrowserHostImpl;
|
2017-08-04 00:55:19 +02:00
|
|
|
|
|
|
|
namespace content {
|
|
|
|
class WebContents;
|
|
|
|
} // namespace content
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
|
|
|
// The ExtensionHost for an extension that backs a view in the browser UI. For
|
|
|
|
// example, this could be an extension popup or dialog, but not a background
|
2020-09-22 21:54:02 +02:00
|
|
|
// page. Object lifespan is managed by AlloyBrowserHostImpl. Based on
|
2017-08-04 00:55:19 +02:00
|
|
|
// chrome/browser/extensions/extension_view_host.h.
|
|
|
|
class CefExtensionViewHost : public ExtensionHost,
|
2021-12-16 23:35:54 +01:00
|
|
|
public ExtensionHostRegistry::Observer {
|
2017-08-04 00:55:19 +02:00
|
|
|
public:
|
2020-09-22 21:54:02 +02:00
|
|
|
CefExtensionViewHost(AlloyBrowserHostImpl* browser,
|
2017-08-04 00:55:19 +02:00
|
|
|
const Extension* extension,
|
|
|
|
content::WebContents* host_contents,
|
|
|
|
const GURL& url,
|
2021-04-21 00:52:34 +02:00
|
|
|
mojom::ViewType host_type);
|
2021-12-06 21:40:25 +01:00
|
|
|
|
|
|
|
CefExtensionViewHost(const CefExtensionViewHost&) = delete;
|
|
|
|
CefExtensionViewHost& operator=(const CefExtensionViewHost&) = delete;
|
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
~CefExtensionViewHost() override;
|
|
|
|
|
|
|
|
// ExtensionHost methods:
|
|
|
|
void OnDidStopFirstLoad() override;
|
|
|
|
void LoadInitialURL() override;
|
|
|
|
bool IsBackgroundPage() const override;
|
|
|
|
|
|
|
|
// content::WebContentsDelegate methods:
|
2021-07-23 18:40:13 +02:00
|
|
|
bool ShouldAllowRendererInitiatedCrossProcessNavigation(
|
|
|
|
bool is_main_frame_navigation) override;
|
2017-08-04 00:55:19 +02:00
|
|
|
bool PreHandleGestureEvent(content::WebContents* source,
|
|
|
|
const blink::WebGestureEvent& event) override;
|
|
|
|
|
|
|
|
// extensions::ExtensionFunctionDispatcher::Delegate methods:
|
|
|
|
content::WebContents* GetVisibleWebContents() const override;
|
|
|
|
|
2021-12-16 23:35:54 +01:00
|
|
|
// ExtensionHostRegistry::Observer methods:
|
|
|
|
void OnExtensionHostDocumentElementAvailable(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
ExtensionHost* extension_host) override;
|
2017-08-04 00:55:19 +02:00
|
|
|
|
|
|
|
private:
|
2021-12-16 23:35:54 +01:00
|
|
|
base::ScopedObservation<ExtensionHostRegistry,
|
|
|
|
ExtensionHostRegistry::Observer>
|
|
|
|
host_registry_observation_{this};
|
2017-08-04 00:55:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace extensions
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_
|