mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for loading extensions (issue #1947)
- Add CefRequestContext::LoadExtension, CefExtension, CefExtensionHandler and related methods/interfaces. - Add chrome://extensions-support that lists supported Chrome APIs. - Add CefBrowserHost::SetAutoResizeEnabled and CefDisplayHandler::OnAutoResize to support browser resize based on preferred web contents size. - views: Add support for custom CefMenuButton popups. - cefclient: Run with `--load-extension=set_page_color` command-line flag for an extension loading example. Add `--use-views` on Windows and Linux for an even better example.
This commit is contained in:
64
libcef/browser/extensions/extension_view_host.h
Normal file
64
libcef/browser/extensions/extension_view_host.h
Normal file
@@ -0,0 +1,64 @@
|
||||
// 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>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "extensions/browser/extension_host.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
|
||||
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
|
||||
// page. Object lifespan is managed by CefBrowserHostImpl. Based on
|
||||
// chrome/browser/extensions/extension_view_host.h.
|
||||
class CefExtensionViewHost : public ExtensionHost,
|
||||
public content::NotificationObserver {
|
||||
public:
|
||||
CefExtensionViewHost(CefBrowserHostImpl* browser,
|
||||
const Extension* extension,
|
||||
content::BrowserContext* browser_context,
|
||||
content::WebContents* host_contents,
|
||||
const GURL& url,
|
||||
ViewType host_type);
|
||||
~CefExtensionViewHost() override;
|
||||
|
||||
// ExtensionHost methods:
|
||||
void OnDidStopFirstLoad() override;
|
||||
void LoadInitialURL() override;
|
||||
bool IsBackgroundPage() const override;
|
||||
|
||||
// content::WebContentsDelegate methods:
|
||||
bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
|
||||
bool PreHandleGestureEvent(content::WebContents* source,
|
||||
const blink::WebGestureEvent& event) override;
|
||||
|
||||
// extensions::ExtensionFunctionDispatcher::Delegate methods:
|
||||
content::WebContents* GetVisibleWebContents() const override;
|
||||
|
||||
// content::NotificationObserver methods:
|
||||
void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
|
||||
private:
|
||||
content::NotificationRegistrar registrar_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefExtensionViewHost);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_
|
Reference in New Issue
Block a user