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 WebRemoteFrameImpl_h
6 #define WebRemoteFrameImpl_h
8 #include "core/frame/FrameOwner.h"
9 #include "platform/heap/Handle.h"
10 #include "public/web/WebRemoteFrame.h"
11 #include "public/web/WebRemoteFrameClient.h"
12 #include "web/RemoteFrameClientImpl.h"
13 #include "wtf/HashMap.h"
14 #include "wtf/OwnPtr.h"
15 #include "wtf/RefCounted.h"
23 class WebRemoteFrameImpl final
: public RefCountedWillBeGarbageCollectedFinalized
<WebRemoteFrameImpl
>, public WebRemoteFrame
{
25 static WebRemoteFrame
* create(WebTreeScopeType
, WebRemoteFrameClient
*);
26 ~WebRemoteFrameImpl() override
;
28 // WebRemoteFrame methods.
29 bool isWebLocalFrame() const override
;
30 WebLocalFrame
* toWebLocalFrame() override
;
31 bool isWebRemoteFrame() const override
;
32 WebRemoteFrame
* toWebRemoteFrame() override
;
33 void close() override
;
34 WebString
uniqueName() const override
;
35 WebString
assignedName() const override
;
36 void setName(const WebString
&) override
;
37 WebVector
<WebIconURL
> iconURLs(int iconTypesMask
) const override
;
38 void setRemoteWebLayer(WebLayer
*) override
;
39 void setSharedWorkerRepositoryClient(WebSharedWorkerRepositoryClient
*) override
;
40 void setCanHaveScrollbars(bool) override
;
41 WebSize
scrollOffset() const override
;
42 void setScrollOffset(const WebSize
&) override
;
43 WebSize
contentsSize() const override
;
44 bool hasVisibleContent() const override
;
45 WebRect
visibleContentRect() const override
;
46 bool hasHorizontalScrollbar() const override
;
47 bool hasVerticalScrollbar() const override
;
48 WebView
* view() const override
;
49 void removeChild(WebFrame
*) override
;
50 WebDocument
document() const override
;
51 WebPerformance
performance() const override
;
52 bool dispatchBeforeUnloadEvent() override
;
53 void dispatchUnloadEvent() override
;
54 NPObject
* windowObject() const override
;
55 void bindToWindowObject(const WebString
& name
, NPObject
*) override
;
56 void bindToWindowObject(const WebString
& name
, NPObject
*, void*) override
;
57 void executeScript(const WebScriptSource
&) override
;
58 void executeScriptInIsolatedWorld(
59 int worldID
, const WebScriptSource
* sources
, unsigned numSources
,
60 int extensionGroup
) override
;
61 void setIsolatedWorldSecurityOrigin(int worldID
, const WebSecurityOrigin
&) override
;
62 void setIsolatedWorldContentSecurityPolicy(int worldID
, const WebString
&) override
;
63 void addMessageToConsole(const WebConsoleMessage
&) override
;
64 void collectGarbage() override
;
65 bool checkIfRunInsecureContent(const WebURL
&) const override
;
66 v8::Local
<v8::Value
> executeScriptAndReturnValue(
67 const WebScriptSource
&) override
;
68 void executeScriptInIsolatedWorld(
69 int worldID
, const WebScriptSource
* sourcesIn
, unsigned numSources
,
70 int extensionGroup
, WebVector
<v8::Local
<v8::Value
>>* results
) override
;
71 v8::Local
<v8::Value
> callFunctionEvenIfScriptDisabled(
72 v8::Local
<v8::Function
>,
75 v8::Local
<v8::Value
> argv
[]) override
;
76 v8::Local
<v8::Context
> mainWorldScriptContext() const override
;
77 v8::Local
<v8::Context
> deprecatedMainWorldScriptContext() const override
;
78 void reload(bool ignoreCache
) override
;
79 void reloadWithOverrideURL(const WebURL
& overrideUrl
, bool ignoreCache
) override
;
80 void loadRequest(const WebURLRequest
&) override
;
81 void loadHistoryItem(const WebHistoryItem
&, WebHistoryLoadType
, WebURLRequest::CachePolicy
) override
;
83 const WebData
&, const WebString
& mimeType
, const WebString
& textEncoding
,
84 const WebURL
& baseURL
, const WebURL
& unreachableURL
, bool replace
) override
;
86 const WebData
& html
, const WebURL
& baseURL
, const WebURL
& unreachableURL
,
87 bool replace
) override
;
88 void stopLoading() override
;
89 WebDataSource
* provisionalDataSource() const override
;
90 WebDataSource
* dataSource() const override
;
91 void enableViewSourceMode(bool enable
) override
;
92 bool isViewSourceModeEnabled() const override
;
93 void setReferrerForRequest(WebURLRequest
&, const WebURL
& referrer
) override
;
94 void dispatchWillSendRequest(WebURLRequest
&) override
;
95 WebURLLoader
* createAssociatedURLLoader(const WebURLLoaderOptions
&) override
;
96 unsigned unloadListenerCount() const override
;
97 void replaceSelection(const WebString
&) override
;
98 void insertText(const WebString
&) override
;
99 void setMarkedText(const WebString
&, unsigned location
, unsigned length
) override
;
100 void unmarkText() override
;
101 bool hasMarkedText() const override
;
102 WebRange
markedRange() const override
;
103 bool firstRectForCharacterRange(unsigned location
, unsigned length
, WebRect
&) const override
;
104 size_t characterIndexForPoint(const WebPoint
&) const override
;
105 bool executeCommand(const WebString
&, const WebNode
& = WebNode()) override
;
106 bool executeCommand(const WebString
&, const WebString
& value
, const WebNode
& = WebNode()) override
;
107 bool isCommandEnabled(const WebString
&) const override
;
108 void enableContinuousSpellChecking(bool) override
;
109 bool isContinuousSpellCheckingEnabled() const override
;
110 void requestTextChecking(const WebElement
&) override
;
111 void replaceMisspelledRange(const WebString
&) override
;
112 void removeSpellingMarkers() override
;
113 bool hasSelection() const override
;
114 WebRange
selectionRange() const override
;
115 WebString
selectionAsText() const override
;
116 WebString
selectionAsMarkup() const override
;
117 bool selectWordAroundCaret() override
;
118 void selectRange(const WebPoint
& base
, const WebPoint
& extent
) override
;
119 void selectRange(const WebRange
&) override
;
120 void moveRangeSelection(const WebPoint
& base
, const WebPoint
& extent
, WebFrame::TextGranularity
= CharacterGranularity
) override
;
121 void moveCaretSelection(const WebPoint
&) override
;
122 bool setEditableSelectionOffsets(int start
, int end
) override
;
123 bool setCompositionFromExistingText(int compositionStart
, int compositionEnd
, const WebVector
<WebCompositionUnderline
>& underlines
) override
;
124 void extendSelectionAndDelete(int before
, int after
) override
;
125 void setCaretVisible(bool) override
;
126 int printBegin(const WebPrintParams
&, const WebNode
& constrainToNode
) override
;
127 float printPage(int pageToPrint
, WebCanvas
*) override
;
128 float getPrintPageShrink(int page
) override
;
129 void printEnd() override
;
130 bool isPrintScalingDisabledForPlugin(const WebNode
&) override
;
131 bool hasCustomPageSizeStyle(int pageIndex
) override
;
132 bool isPageBoxVisible(int pageIndex
) override
;
133 void pageSizeAndMarginsInPixels(
139 int& marginLeft
) override
;
140 WebString
pageProperty(const WebString
& propertyName
, int pageIndex
) override
;
141 void printPagesWithBoundaries(WebCanvas
*, const WebSize
&) override
;
143 int identifier
, const WebString
& searchText
, const WebFindOptions
&,
144 bool wrapWithinFrame
, WebRect
* selectionRect
) override
;
145 void stopFinding(bool clearSelection
) override
;
146 void scopeStringMatches(
147 int identifier
, const WebString
& searchText
, const WebFindOptions
&,
148 bool reset
) override
;
149 void cancelPendingScopingEffort() override
;
150 void increaseMatchCount(int count
, int identifier
) override
;
151 void resetMatchCount() override
;
152 int findMatchMarkersVersion() const override
;
153 WebFloatRect
activeFindMatchRect() override
;
154 void findMatchRects(WebVector
<WebFloatRect
>&) override
;
155 int selectNearestFindMatch(const WebFloatPoint
&, WebRect
* selectionRect
) override
;
156 void setTickmarks(const WebVector
<WebRect
>&) override
;
157 void dispatchMessageEventWithOriginCheck(
158 const WebSecurityOrigin
& intendedTargetOrigin
,
159 const WebDOMEvent
&) override
;
161 WebString
contentAsText(size_t maxChars
) const override
;
162 WebString
contentAsMarkup() const override
;
163 WebString
layoutTreeAsText(LayoutAsTextControls toShow
= LayoutAsTextNormal
) const override
;
164 WebString
markerTextForListItem(const WebElement
&) const override
;
165 WebRect
selectionBoundsRect() const override
;
167 bool selectionStartHasSpellingMarkerFor(int from
, int length
) const override
;
168 WebString
layerTreeAsText(bool showDebugInfo
= false) const override
;
170 WebLocalFrame
* createLocalChild(WebTreeScopeType
, const WebString
& name
, WebSandboxFlags
, WebFrameClient
*, WebFrame
* previousSibling
) override
;
171 WebRemoteFrame
* createRemoteChild(WebTreeScopeType
, const WebString
& name
, WebSandboxFlags
, WebRemoteFrameClient
*) override
;
173 void initializeCoreFrame(FrameHost
*, FrameOwner
*, const AtomicString
& name
);
175 void setCoreFrame(PassRefPtrWillBeRawPtr
<RemoteFrame
>);
176 RemoteFrame
* frame() const { return m_frame
.get(); }
178 WebRemoteFrameClient
* client() const { return m_client
; }
180 static WebRemoteFrameImpl
* fromFrame(RemoteFrame
&);
182 void initializeFromFrame(WebLocalFrame
*) const override
;
184 void setReplicatedOrigin(const WebSecurityOrigin
&) const override
;
185 void setReplicatedSandboxFlags(WebSandboxFlags
) const override
;
186 void setReplicatedName(const WebString
&) const override
;
187 void DispatchLoadEventForFrameOwner() const override
;
189 void didStartLoading() override
;
190 void didStopLoading() override
;
197 WebRemoteFrameImpl(WebTreeScopeType
, WebRemoteFrameClient
*);
199 OwnPtrWillBeMember
<RemoteFrameClientImpl
> m_frameClient
;
200 RefPtrWillBeMember
<RemoteFrame
> m_frame
;
201 WebRemoteFrameClient
* m_client
;
203 WillBeHeapHashMap
<WebFrame
*, OwnPtrWillBeMember
<FrameOwner
>> m_ownersForChildren
;
206 // Oilpan: WebRemoteFrameImpl must remain alive until close() is called.
207 // Accomplish that by keeping a self-referential Persistent<>. It is
208 // cleared upon close().
209 SelfKeepAlive
<WebRemoteFrameImpl
> m_selfKeepAlive
;
213 DEFINE_TYPE_CASTS(WebRemoteFrameImpl
, WebFrame
, frame
, frame
->isWebRemoteFrame(), frame
.isWebRemoteFrame());
217 #endif // WebRemoteFrameImpl_h