Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / web / WebLocalFrame.h
blobe9dbe9926f5cc2ac9ad063c5728c1d13a436e5d1
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WebLocalFrame_h
6 #define WebLocalFrame_h
8 #include "WebFrame.h"
9 #include "WebFrameLoadType.h"
11 namespace blink {
13 enum class WebAppBannerPromptReply;
14 enum class WebSandboxFlags;
15 enum class WebTreeScopeType;
16 class WebAutofillClient;
17 class WebContentSettingsClient;
18 class WebDevToolsAgent;
19 class WebDevToolsAgentClient;
20 class WebFrameClient;
21 class WebNode;
22 class WebScriptExecutionCallback;
23 class WebSuspendableTask;
24 class WebTestInterfaceFactory;
25 struct WebPrintPresetOptions;
27 // Interface for interacting with in process frames. This contains methods that
28 // require interacting with a frame's document.
29 // FIXME: Move lots of methods from WebFrame in here.
30 class WebLocalFrame : public WebFrame {
31 public:
32 // Creates a WebFrame. Delete this WebFrame by calling WebFrame::close().
33 // It is valid to pass a null client pointer.
34 BLINK_EXPORT static WebLocalFrame* create(WebTreeScopeType, WebFrameClient*);
36 // Returns the WebFrame associated with the current V8 context. This
37 // function can return 0 if the context is associated with a Document that
38 // is not currently being displayed in a Frame.
39 BLINK_EXPORT static WebLocalFrame* frameForCurrentContext();
41 // Returns the frame corresponding to the given context. This can return 0
42 // if the context is detached from the frame, or if the context doesn't
43 // correspond to a frame (e.g., workers).
44 BLINK_EXPORT static WebLocalFrame* frameForContext(v8::Local<v8::Context>);
46 // Returns the frame inside a given frame or iframe element. Returns 0 if
47 // the given element is not a frame, iframe or if the frame is empty.
48 BLINK_EXPORT static WebLocalFrame* fromFrameOwnerElement(const WebElement&);
50 // Initialization ---------------------------------------------------------
52 // Used when we might swap from a remote frame to a local frame.
53 // Creates a provisional, semi-attached frame that will be fully
54 // swapped into the frame tree if it commits.
55 virtual void initializeToReplaceRemoteFrame(WebRemoteFrame*, const WebString& name, WebSandboxFlags) = 0;
57 virtual void setAutofillClient(WebAutofillClient*) = 0;
58 virtual WebAutofillClient* autofillClient() = 0;
59 virtual void setDevToolsAgentClient(WebDevToolsAgentClient*) = 0;
60 virtual WebDevToolsAgent* devToolsAgent() = 0;
62 // Navigation Ping --------------------------------------------------------
63 virtual void sendPings(const WebNode& contextNode, const WebURL& destinationURL) = 0;
65 // Navigation ----------------------------------------------------------
67 // Returns a WebURLRequest corresponding to the load of the WebHistoryItem.
68 virtual WebURLRequest requestFromHistoryItem(const WebHistoryItem&, WebURLRequest::CachePolicy)
69 const = 0;
71 // Returns a WebURLRequest corresponding to the reload of the current
72 // HistoryItem.
73 virtual WebURLRequest requestForReload(WebFrameLoadType,
74 const WebURL& overrideURL = WebURL()) const = 0;
76 // Load the given URL. For history navigations, a valid WebHistoryItem
77 // should be given, as well as a WebHistoryLoadType.
78 // TODO(clamy): Remove the reload, reloadWithOverrideURL, loadHistoryItem
79 // loadRequest functions in WebFrame once RenderFrame only calls loadRequest.
80 virtual void load(const WebURLRequest&, WebFrameLoadType = WebFrameLoadType::Standard,
81 const WebHistoryItem& = WebHistoryItem(),
82 WebHistoryLoadType = WebHistoryDifferentDocumentLoad) = 0;
84 // Navigation State -------------------------------------------------------
86 // Returns true if the current frame's load event has not completed.
87 virtual bool isLoading() const = 0;
89 // Returns true if any resource load is currently in progress. Exposed
90 // primarily for use in layout tests. You probably want isLoading()
91 // instead.
92 virtual bool isResourceLoadInProgress() const = 0;
94 // Returns true if there is a pending redirect or location change.
95 // This could be caused by:
96 // * an HTTP Refresh header
97 // * an X-Frame-Options header
98 // * the respective http-equiv meta tags
99 // * window.location value being mutated
100 // * CSP policy block
101 // * reload
102 // * form submission
103 virtual bool isNavigationScheduled() const = 0;
105 // Override the normal rules for whether a load has successfully committed
106 // in this frame. Used to propagate state when this frame has navigated
107 // cross process.
108 virtual void setCommittedFirstRealLoad() = 0;
110 // Orientation Changes ----------------------------------------------------
112 // Notify the frame that the screen orientation has changed.
113 virtual void sendOrientationChangeEvent() = 0;
116 // Printing ------------------------------------------------------------
118 // Returns true on success and sets the out parameter to the print preset options for the document.
119 virtual bool getPrintPresetOptionsForPlugin(const WebNode&, WebPrintPresetOptions*) = 0;
122 // Scripting --------------------------------------------------------------
123 // Executes script in the context of the current page and returns the value
124 // that the script evaluated to with callback. Script execution can be
125 // suspend.
126 virtual void requestExecuteScriptAndReturnValue(const WebScriptSource&,
127 bool userGesture, WebScriptExecutionCallback*) = 0;
129 // worldID must be > 0 (as 0 represents the main world).
130 // worldID must be < EmbedderWorldIdLimit, high number used internally.
131 virtual void requestExecuteScriptInIsolatedWorld(
132 int worldID, const WebScriptSource* sourceIn, unsigned numSources,
133 int extensionGroup, bool userGesture, WebScriptExecutionCallback*) = 0;
135 // Run the task when the context of the current page is not suspended
136 // otherwise run it on context resumed.
137 // Method takes ownership of the passed task.
138 virtual void requestRunTask(WebSuspendableTask*) const = 0;
140 // Associates an isolated world with human-readable name which is useful for
141 // extension debugging.
142 virtual void setIsolatedWorldHumanReadableName(int worldID, const WebString&) = 0;
145 // Selection --------------------------------------------------------------
147 // Moves the selection extent point. This function does not allow the
148 // selection to collapse. If the new extent is set to the same position as
149 // the current base, this function will do nothing.
150 virtual void moveRangeSelectionExtent(const WebPoint&) = 0;
152 // Content Settings -------------------------------------------------------
154 virtual void setContentSettingsClient(WebContentSettingsClient*) = 0;
156 // App banner -------------------------------------------------------------
158 // Request to show an application install banner for the given |platforms|.
159 // The implementation can request the embedder to cancel the call by setting
160 // |cancel| to true.
161 virtual void willShowInstallBannerPrompt(int requestId, const WebVector<WebString>& platforms, WebAppBannerPromptReply*) = 0;
163 // Image reload -----------------------------------------------------------
165 // If the provided node is an image, reload the image bypassing the cache.
166 virtual void reloadImage(const WebNode&) = 0;
168 // Testing ----------------------------------------------------------------
170 // Registers a test interface factory. Takes ownership of the factory.
171 virtual void registerTestInterface(const WebString& name, WebTestInterfaceFactory*) = 0;
173 // Iframe sandbox ---------------------------------------------------------
175 // Returns the effective sandbox flags which are inherited from their parent frame.
176 virtual WebSandboxFlags effectiveSandboxFlags() const = 0;
178 protected:
179 explicit WebLocalFrame(WebTreeScopeType scope) : WebFrame(scope) { }
182 } // namespace blink
184 #endif // WebLocalFrame_h