• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "base/macros.h"
17 #include "third_party/blink/public/platform/web_common.h"
18 #include "v8/include/v8.h"
19 
20 namespace blink {
21 class WebElement;
22 class WebLocalFrame;
23 class WebNode;
24 class WebString;
25 class WebURLRequest;
26 class WebURLResponse;
27 class WebView;
28 
29 namespace scheduler {
30 class WebResourceLoadingTaskRunnerHandle;
31 }
32 }  // namespace blink
33 
34 namespace blink_glue {
35 
36 BLINK_EXPORT extern const int64_t kInvalidFrameId;
37 
38 BLINK_EXPORT bool CanGoBack(blink::WebView* view);
39 BLINK_EXPORT bool CanGoForward(blink::WebView* view);
40 BLINK_EXPORT void GoBack(blink::WebView* view);
41 BLINK_EXPORT void GoForward(blink::WebView* view);
42 
43 // Returns the text of the document element.
44 BLINK_EXPORT std::string DumpDocumentText(blink::WebLocalFrame* frame);
45 // Returns the markup of the document element.
46 BLINK_EXPORT std::string DumpDocumentMarkup(blink::WebLocalFrame* frame);
47 
48 // Expose additional actions on WebNode.
49 BLINK_EXPORT cef_dom_node_type_t GetNodeType(const blink::WebNode& node);
50 BLINK_EXPORT blink::WebString GetNodeName(const blink::WebNode& node);
51 BLINK_EXPORT blink::WebString CreateNodeMarkup(const blink::WebNode& node);
52 BLINK_EXPORT bool SetNodeValue(blink::WebNode& node,
53                                const blink::WebString& value);
54 
55 BLINK_EXPORT bool IsTextControlElement(const blink::WebElement& element);
56 
57 BLINK_EXPORT v8::MaybeLocal<v8::Value> CallV8Function(
58     v8::Local<v8::Context> context,
59     v8::Local<v8::Function> function,
60     v8::Local<v8::Object> receiver,
61     int argc,
62     v8::Local<v8::Value> args[],
63     v8::Isolate* isolate);
64 
65 BLINK_EXPORT v8::Local<v8::Value> ExecuteV8ScriptAndReturnValue(
66     const blink::WebString& source,
67     const blink::WebString& source_url,
68     int start_line,
69     v8::Local<v8::Context> context,
70     v8::TryCatch& tryCatch);
71 
72 BLINK_EXPORT bool IsScriptForbidden();
73 
74 BLINK_EXPORT void RegisterURLSchemeAsSupportingFetchAPI(
75     const blink::WebString& scheme);
76 
77 // Wrapper for blink::ScriptForbiddenScope.
78 class BLINK_EXPORT CefScriptForbiddenScope final {
79  public:
80   CefScriptForbiddenScope();
81   ~CefScriptForbiddenScope();
82 
83  private:
84   struct Impl;
85   std::unique_ptr<Impl> impl_;
86 
87   DISALLOW_COPY_AND_ASSIGN(CefScriptForbiddenScope);
88 };
89 
90 BLINK_EXPORT bool ResponseWasCached(const blink::WebURLResponse& response);
91 
92 // Returns true if the frame owner is a plugin.
93 BLINK_EXPORT bool HasPluginFrameOwner(blink::WebLocalFrame* frame);
94 
95 BLINK_EXPORT void StartNavigation(blink::WebLocalFrame* frame,
96                                   const blink::WebURLRequest& request);
97 
98 // Used by CefFrameImpl::CreateURLLoader.
99 BLINK_EXPORT
100 std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle>
101 CreateResourceLoadingTaskRunnerHandle(blink::WebLocalFrame* frame);
102 BLINK_EXPORT
103 std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle>
104 CreateResourceLoadingMaybeUnfreezableTaskRunnerHandle(
105     blink::WebLocalFrame* frame);
106 
107 }  // namespace blink_glue
108 
109 #endif  // CEF_LIBCEF_RENDERER_BLINK_GLUE_H_
110