1 // Copyright (c) 2012 The Chromium Embedded Framework Authors. 2 // Portions copyright (c) 2011 The Chromium Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 6 #ifndef CEF_LIBCEF_RENDERER_BLINK_GLUE_H_ 7 #define CEF_LIBCEF_RENDERER_BLINK_GLUE_H_ 8 9 #include <stdint.h> 10 11 #include <memory> 12 #include <string> 13 14 #include "include/internal/cef_types.h" 15 16 #include "third_party/blink/public/platform/web_common.h" 17 #include "v8/include/v8.h" 18 19 namespace blink { 20 class WebElement; 21 class WebLocalFrame; 22 class WebNode; 23 class WebString; 24 class WebURLRequest; 25 class WebURLResponse; 26 class WebView; 27 28 namespace scheduler { 29 class WebResourceLoadingTaskRunnerHandle; 30 } 31 } // namespace blink 32 33 namespace blink_glue { 34 35 BLINK_EXPORT extern const int64_t kInvalidFrameId; 36 37 BLINK_EXPORT bool CanGoBack(blink::WebView* view); 38 BLINK_EXPORT bool CanGoForward(blink::WebView* view); 39 BLINK_EXPORT void GoBack(blink::WebView* view); 40 BLINK_EXPORT void GoForward(blink::WebView* view); 41 42 BLINK_EXPORT bool IsInBackForwardCache(blink::WebLocalFrame* frame); 43 44 // Returns the text of the document element. 45 BLINK_EXPORT blink::WebString DumpDocumentText(blink::WebLocalFrame* frame); 46 // Returns the markup of the document element. 47 BLINK_EXPORT blink::WebString DumpDocumentMarkup(blink::WebLocalFrame* frame); 48 49 // Expose additional actions on WebNode. 50 BLINK_EXPORT cef_dom_node_type_t GetNodeType(const blink::WebNode& node); 51 BLINK_EXPORT blink::WebString GetNodeName(const blink::WebNode& node); 52 BLINK_EXPORT blink::WebString CreateNodeMarkup(const blink::WebNode& node); 53 BLINK_EXPORT bool SetNodeValue(blink::WebNode& node, 54 const blink::WebString& value); 55 56 BLINK_EXPORT bool IsTextControlElement(const blink::WebElement& element); 57 58 BLINK_EXPORT v8::MaybeLocal<v8::Value> CallV8Function( 59 v8::Local<v8::Context> context, 60 v8::Local<v8::Function> function, 61 v8::Local<v8::Object> receiver, 62 int argc, 63 v8::Local<v8::Value> args[], 64 v8::Isolate* isolate); 65 66 BLINK_EXPORT v8::Local<v8::Value> ExecuteV8ScriptAndReturnValue( 67 const blink::WebString& source, 68 const blink::WebString& source_url, 69 int start_line, 70 v8::Local<v8::Context> context, 71 v8::TryCatch& tryCatch); 72 73 BLINK_EXPORT bool IsScriptForbidden(); 74 75 BLINK_EXPORT void RegisterURLSchemeAsSupportingFetchAPI( 76 const blink::WebString& scheme); 77 78 // Wrapper for blink::ScriptForbiddenScope. 79 class BLINK_EXPORT CefScriptForbiddenScope final { 80 public: 81 CefScriptForbiddenScope(); 82 83 CefScriptForbiddenScope(const CefScriptForbiddenScope&) = delete; 84 CefScriptForbiddenScope& operator=(const CefScriptForbiddenScope&) = delete; 85 86 ~CefScriptForbiddenScope(); 87 88 private: 89 struct Impl; 90 std::unique_ptr<Impl> impl_; 91 }; 92 93 BLINK_EXPORT bool ResponseWasCached(const blink::WebURLResponse& response); 94 95 // Returns true if the frame owner is a plugin. 96 BLINK_EXPORT bool HasPluginFrameOwner(blink::WebLocalFrame* frame); 97 98 BLINK_EXPORT void StartNavigation(blink::WebLocalFrame* frame, 99 const blink::WebURLRequest& request); 100 101 // Used by CefFrameImpl::CreateURLLoader. 102 BLINK_EXPORT 103 std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle> 104 CreateResourceLoadingTaskRunnerHandle(blink::WebLocalFrame* frame); 105 BLINK_EXPORT 106 std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle> 107 CreateResourceLoadingMaybeUnfreezableTaskRunnerHandle( 108 blink::WebLocalFrame* frame); 109 110 } // namespace blink_glue 111 112 #endif // CEF_LIBCEF_RENDERER_BLINK_GLUE_H_ 113