cef/libcef/renderer/blink_glue.h

140 lines
4.4 KiB
C
Raw Normal View History

// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2011 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_RENDERER_BLINK_GLUE_H_
#define CEF_LIBCEF_RENDERER_BLINK_GLUE_H_
#include <stdint.h>
#include <memory>
#include <string>
#include "include/internal/cef_types.h"
#include "third_party/blink/public/mojom/frame/lifecycle.mojom-blink-forward.h"
#include "third_party/blink/public/platform/web_common.h"
#include "v8/include/v8.h"
namespace blink {
class WebElement;
class WebLocalFrame;
class WebNode;
class WebString;
class WebURLRequest;
class WebURLResponse;
class WebView;
namespace scheduler {
class WebResourceLoadingTaskRunnerHandle;
}
} // namespace blink
namespace blink_glue {
BLINK_EXPORT extern const int64_t kInvalidFrameId;
BLINK_EXPORT bool CanGoBack(blink::WebView* view);
BLINK_EXPORT bool CanGoForward(blink::WebView* view);
BLINK_EXPORT void GoBack(blink::WebView* view);
BLINK_EXPORT void GoForward(blink::WebView* view);
BLINK_EXPORT bool IsInBackForwardCache(blink::WebLocalFrame* frame);
// Returns the text of the document element.
BLINK_EXPORT blink::WebString DumpDocumentText(blink::WebLocalFrame* frame);
// Returns the markup of the document element.
BLINK_EXPORT blink::WebString DumpDocumentMarkup(blink::WebLocalFrame* frame);
// Expose additional actions on WebNode.
BLINK_EXPORT cef_dom_node_type_t GetNodeType(const blink::WebNode& node);
BLINK_EXPORT blink::WebString GetNodeName(const blink::WebNode& node);
BLINK_EXPORT blink::WebString CreateNodeMarkup(const blink::WebNode& node);
BLINK_EXPORT bool SetNodeValue(blink::WebNode& node,
const blink::WebString& value);
BLINK_EXPORT bool IsTextControlElement(const blink::WebElement& element);
BLINK_EXPORT v8::MaybeLocal<v8::Value> CallV8Function(
v8::Local<v8::Context> context,
v8::Local<v8::Function> function,
v8::Local<v8::Object> receiver,
int argc,
v8::Local<v8::Value> args[],
v8::Isolate* isolate);
BLINK_EXPORT v8::Local<v8::Value> ExecuteV8ScriptAndReturnValue(
const blink::WebString& source,
const blink::WebString& source_url,
int start_line,
v8::Local<v8::Context> context,
v8::TryCatch& tryCatch);
BLINK_EXPORT bool IsScriptForbidden();
class BLINK_EXPORT CefObserverRegistration {
public:
CefObserverRegistration() = default;
CefObserverRegistration(const CefObserverRegistration&) = delete;
CefObserverRegistration& operator=(const CefObserverRegistration&) = delete;
virtual ~CefObserverRegistration() = default;
};
class BLINK_EXPORT CefExecutionContextLifecycleStateObserver {
public:
virtual void ContextLifecycleStateChanged(
blink::mojom::blink::FrameLifecycleState state) {}
protected:
virtual ~CefExecutionContextLifecycleStateObserver() = default;
};
// Register an ExecutionContextLifecycleStateObserver. Remains registered until
// the returned object is destroyed.
BLINK_EXPORT std::unique_ptr<CefObserverRegistration>
RegisterExecutionContextLifecycleStateObserver(
v8::Local<v8::Context> context,
CefExecutionContextLifecycleStateObserver* observer);
BLINK_EXPORT void RegisterURLSchemeAsSupportingFetchAPI(
const blink::WebString& scheme);
// Wrapper for blink::ScriptForbiddenScope.
class BLINK_EXPORT CefScriptForbiddenScope final {
public:
CefScriptForbiddenScope();
CefScriptForbiddenScope(const CefScriptForbiddenScope&) = delete;
CefScriptForbiddenScope& operator=(const CefScriptForbiddenScope&) = delete;
~CefScriptForbiddenScope();
private:
struct Impl;
std::unique_ptr<Impl> impl_;
};
BLINK_EXPORT bool ResponseWasCached(const blink::WebURLResponse& response);
Add support for MimeHandlerViewInCrossProcessFrame (fixes issue #2727) The PDF loading documentation in extension_system.cc has be updated to describe the new code paths. To support delivery of input events to the mime handler renderer process it is now necessary to route events via the correct RWHV interface. For Aura-based platforms (Windows/Linux) this means RWHVAura::On*Event and for macOS this means RWHVMac::RouteOrProcess*Event. Since Aura uses UI event types these have become the source of truth on Aura-based platforms with conversion to Web event types when needed (primarily for OSR). This change also adds a timeout for CefProcessHostMsg_GetNewBrowserInfo to avoid a hung renderer process if the guest WebContents route is not registered via CefMimeHandlerViewGuestDelegate::OnGuestDetached as expected prior to CefBrowserInfoManager::OnGetNewBrowserInfo being called. This timeout can be disabled for testing purposes by passing the `--disable-new-browser-info-timeout` command-line flag. The `--disable-features=MimeHandlerViewInCrossProcessFrame` command-line flag can be used for a limited time to restore the previous implementation based on BrowserPlugin. That implementation will be deleted starting with the 3897 branch update. Known issues: - ExecuteJavaScript calls on the frame hosting the PDF extension will not be routed to the mime handler renderer process. - The PDF extension will not load successfully if blocked by ChromePluginPlaceholder and then manually continued via the "Run this plugin" context menu option (see https://crbug.com/533069#c41).
2020-01-23 22:58:01 +01:00
// Returns true if the frame owner is a plugin.
BLINK_EXPORT bool HasPluginFrameOwner(blink::WebLocalFrame* frame);
BLINK_EXPORT void StartNavigation(blink::WebLocalFrame* frame,
const blink::WebURLRequest& request);
// Used by CefFrameImpl::CreateURLLoader.
BLINK_EXPORT
std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle>
CreateResourceLoadingTaskRunnerHandle(blink::WebLocalFrame* frame);
BLINK_EXPORT
std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle>
CreateResourceLoadingMaybeUnfreezableTaskRunnerHandle(
blink::WebLocalFrame* frame);
} // namespace blink_glue
#endif // CEF_LIBCEF_RENDERER_BLINK_GLUE_H_