cef/libcef/browser/extension_impl.h
Marshall Greenblatt 9cff99dc4e 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.
2017-08-25 18:40:32 -04:00

59 lines
1.7 KiB
C++

// Copyright (c) 2017 The Chromium Embedded Framework 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_EXTENSION_IMPL_H_
#define CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_
#pragma once
#include <memory>
#include "include/cef_extension.h"
#include "include/cef_extension_handler.h"
#include "include/cef_request_context.h"
namespace extensions {
class Extension;
};
// CefNavigationEntry implementation
class CefExtensionImpl : public CefExtension {
public:
CefExtensionImpl(const extensions::Extension* extension,
CefRequestContext* loader_context,
CefRefPtr<CefExtensionHandler> handler);
// CefExtension methods.
CefString GetIdentifier() override;
CefString GetPath() override;
CefRefPtr<CefDictionaryValue> GetManifest() override;
bool IsSame(CefRefPtr<CefExtension> that) override;
CefRefPtr<CefExtensionHandler> GetHandler() override;
CefRefPtr<CefRequestContext> GetLoaderContext() override;
bool IsLoaded() override;
void Unload() override;
void OnExtensionLoaded();
void OnExtensionUnloaded();
// Use this instead of the GetLoaderContext version during
// CefRequestContext destruction.
CefRequestContext* loader_context() const { return loader_context_; }
private:
CefString id_;
CefString path_;
CefRefPtr<CefDictionaryValue> manifest_;
CefRequestContext* loader_context_;
CefRefPtr<CefExtensionHandler> handler_;
// Only accessed on the UI thread.
bool unloaded_ = false;
IMPLEMENT_REFCOUNTING(CefExtensionImpl);
DISALLOW_COPY_AND_ASSIGN(CefExtensionImpl);
};
#endif // CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_