[M120 Migration][VD] Support EWK Scroll API for TV WebBrowser
[platform/framework/web/chromium-efl.git] / third_party / blink / renderer / core / frame / local_frame_client_impl.h
1 /*
2  * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
3  * Copyright (C) 2011 Apple Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *     * Neither the name of Google Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_LOCAL_FRAME_CLIENT_IMPL_H_
33 #define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_LOCAL_FRAME_CLIENT_IMPL_H_
34
35 #include <memory>
36
37 #include "base/memory/scoped_refptr.h"
38
39 #include "base/time/time.h"
40 #include "mojo/public/cpp/bindings/pending_remote.h"
41 #include "mojo/public/cpp/bindings/receiver.h"
42 #include "mojo/public/cpp/bindings/receiver_set.h"
43 #include "mojo/public/cpp/bindings/remote.h"
44 #include "third_party/blink/public/common/performance/performance_timeline_constants.h"
45 #include "third_party/blink/public/common/responsiveness_metrics/user_interaction_latency.h"
46 #include "third_party/blink/public/common/subresource_load_metrics.h"
47 #include "third_party/blink/public/mojom/devtools/devtools_agent.mojom-blink-forward.h"
48 #include "third_party/blink/renderer/core/core_export.h"
49 #include "third_party/blink/renderer/core/frame/local_frame_client.h"
50 #include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
51 #include "third_party/blink/renderer/platform/heap/garbage_collected.h"
52 #include "third_party/blink/renderer/platform/weborigin/kurl.h"
53 #include "third_party/blink/renderer/platform/wtf/casting.h"
54
55 namespace blink {
56
57 class BrowserInterfaceBrokerProxy;
58 class WebDevToolsAgentImpl;
59 class WebLocalFrameImpl;
60 class WebSpellCheckPanelHostClient;
61
62 class CORE_EXPORT LocalFrameClientImpl final : public LocalFrameClient {
63  public:
64   explicit LocalFrameClientImpl(WebLocalFrameImpl*);
65   ~LocalFrameClientImpl() override;
66
67   void Trace(Visitor*) const override;
68
69   WebLocalFrameImpl* GetWebFrame() const override;
70
71   // LocalFrameClient ----------------------------------------------
72   WebContentCaptureClient* GetWebContentCaptureClient() const override;
73   void DidCommitDocumentReplacementNavigation(DocumentLoader*) override;
74   // Notifies the WebView delegate that the JS window object has been cleared,
75   // giving it a chance to bind native objects to the window before script
76   // parsing begins.
77   void DispatchDidClearWindowObjectInMainWorld(
78       v8::Isolate* isolate,
79       v8::MicrotaskQueue* microtask_queue) override;
80   void DocumentElementAvailable() override;
81   void RunScriptsAtDocumentElementAvailable() override;
82   void RunScriptsAtDocumentReady(bool document_is_empty) override;
83   void RunScriptsAtDocumentIdle() override;
84 #if BUILDFLAG(IS_EFL)
85   void AddEdgeEffectForUIF(bool, bool, bool, bool) override;
86 #endif
87 #if BUILDFLAG(IS_TIZEN_TV)
88   void RunArrowScroll() override;
89   void ThumbPartFocusChanged(ScrollbarOrientation, bool) override;
90 #endif
91   void DidCreateScriptContext(v8::Local<v8::Context>,
92                               int32_t world_id) override;
93 #if defined(ENABLE_WRT_JS)
94   void DidInstallConditionalFeatures(v8::Local<v8::Context>,
95                                      int32_t world_id) override;
96 #endif
97   void WillReleaseScriptContext(v8::Local<v8::Context>,
98                                 int32_t world_id) override;
99
100   // Returns true if we should allow register V8 extensions to be added.
101   bool AllowScriptExtensions() override;
102
103   bool HasWebView() const override;
104   bool InShadowTree() const override;
105   void WillBeDetached() override;
106   void Detached(FrameDetachType) override;
107   void DispatchWillSendRequest(ResourceRequest&) override;
108   void DispatchDidLoadResourceFromMemoryCache(const ResourceRequest&,
109                                               const ResourceResponse&) override;
110   void DispatchDidHandleOnloadEvents() override;
111   void DidFinishSameDocumentNavigation(WebHistoryCommitType,
112                                        bool is_handled_within_agent,
113                                        mojom::blink::SameDocumentNavigationType,
114                                        bool is_client_redirect,
115                                        bool is_browser_initiated) override;
116   void DidFailAsyncSameDocumentCommit() override;
117   void DispatchDidOpenDocumentInputStream(const KURL& url) override;
118   void DispatchDidReceiveTitle(const String&) override;
119   void DispatchDidCommitLoad(
120       HistoryItem*,
121       WebHistoryCommitType,
122       bool should_reset_browser_interface_broker,
123       const blink::ParsedPermissionsPolicy& permissions_policy_header,
124       const blink::DocumentPolicyFeatureState& document_policy_header) override;
125   void DispatchDidFailLoad(const ResourceError&, WebHistoryCommitType) override;
126   void DispatchDidDispatchDOMContentLoadedEvent() override;
127   void DispatchDidFinishLoad() override;
128   void DispatchDidFinishLoadForPrinting() override;
129
130   void BeginNavigation(
131       const ResourceRequest&,
132       const KURL& requestor_base_url,
133       mojom::RequestContextFrameType,
134       LocalDOMWindow* origin_window,
135       DocumentLoader*,
136       WebNavigationType,
137       NavigationPolicy,
138       WebFrameLoadType,
139       mojom::blink::ForceHistoryPush,
140       bool is_client_redirect,
141       // TODO(crbug.com/1315802): Refactor _unfencedTop handling.
142       bool is_unfenced_top_navigation,
143       mojom::blink::TriggeringEventInfo,
144       HTMLFormElement*,
145       network::mojom::CSPDisposition should_bypass_main_world_csp,
146       mojo::PendingRemote<mojom::blink::BlobURLToken>,
147       base::TimeTicks input_start_time,
148       const String& href_translate,
149       const absl::optional<Impression>& impression,
150       const LocalFrameToken* initiator_frame_token,
151       std::unique_ptr<SourceLocation> source_location,
152       mojo::PendingRemote<mojom::blink::PolicyContainerHostKeepAliveHandle>
153           initiator_policy_container_keep_alive_handle,
154       bool is_container_initiated,
155       bool is_fullscreen_requested) override;
156   void DispatchWillSendSubmitEvent(HTMLFormElement*) override;
157   void DidStartLoading() override;
158   void DidStopLoading() override;
159   bool NavigateBackForward(
160       int offset,
161       absl::optional<scheduler::TaskAttributionId>
162           soft_navigation_heuristics_task_id) const override;
163   void DidDispatchPingLoader(const KURL&) override;
164   void DidChangePerformanceTiming() override;
165   void DidObserveUserInteraction(base::TimeTicks max_event_start,
166                                  base::TimeTicks max_event_end,
167                                  UserInteractionType interaction_type) override;
168   void DidChangeCpuTiming(base::TimeDelta) override;
169   void DidObserveLoadingBehavior(LoadingBehaviorFlag) override;
170   void DidObserveJavaScriptFrameworks(
171       const JavaScriptFrameworkDetectionResult&) override;
172   void DidObserveSubresourceLoad(
173       const SubresourceLoadMetrics& subresource_load_metrics) override;
174   void DidObserveNewFeatureUsage(const UseCounterFeature&) override;
175   void DidObserveSoftNavigation(SoftNavigationMetrics metrics) override;
176   void DidObserveLayoutShift(double score, bool after_input_or_scroll) override;
177   void PreloadSubresourceOptimizationsForOrigins(
178       const WTF::HashSet<scoped_refptr<const SecurityOrigin>>& origins)
179       override;
180   void SelectorMatchChanged(const Vector<String>& added_selectors,
181                             const Vector<String>& removed_selectors) override;
182
183   void DidCreateDocumentLoader(DocumentLoader*) override;
184
185   String UserAgentOverride() override;
186   WTF::String UserAgent() override;
187   absl::optional<blink::UserAgentMetadata> UserAgentMetadata() override;
188   WTF::String DoNotTrackValue() override;
189   void TransitionToCommittedForNewPage() override;
190   LocalFrame* CreateFrame(const WTF::AtomicString& name,
191                           HTMLFrameOwnerElement*) override;
192   std::pair<RemoteFrame*, PortalToken> CreatePortal(
193       HTMLPortalElement*,
194       mojo::PendingAssociatedReceiver<mojom::blink::Portal>,
195       mojo::PendingAssociatedRemote<mojom::blink::PortalClient>) override;
196   RemoteFrame* AdoptPortal(HTMLPortalElement*) override;
197
198   RemoteFrame* CreateFencedFrame(
199       HTMLFencedFrameElement*,
200       mojo::PendingAssociatedReceiver<mojom::blink::FencedFrameOwnerHost>)
201       override;
202
203   WebPluginContainerImpl* CreatePlugin(HTMLPlugInElement&,
204                                        const KURL&,
205                                        const Vector<WTF::String>&,
206                                        const Vector<WTF::String>&,
207                                        const WTF::String&,
208                                        bool load_manually) override;
209   std::unique_ptr<WebMediaPlayer> CreateWebMediaPlayer(
210       HTMLMediaElement&,
211       const WebMediaPlayerSource&,
212       WebMediaPlayerClient*) override;
213   WebRemotePlaybackClient* CreateWebRemotePlaybackClient(
214       HTMLMediaElement&) override;
215   void DidChangeScrollOffset() override;
216   void NotifyCurrentHistoryItemChanged() override;
217   void DidUpdateCurrentHistoryItem() override;
218
219   bool AllowContentInitiatedDataUrlNavigations(const KURL&) override;
220
221   void DidChangeName(const String&) override;
222
223   std::unique_ptr<WebServiceWorkerProvider> CreateServiceWorkerProvider()
224       override;
225   WebContentSettingsClient* GetContentSettingsClient() override;
226
227   void DispatchDidChangeManifest() override;
228
229   unsigned BackForwardLength() override;
230
231   KURL OverrideFlashEmbedWithHTML(const KURL&) override;
232
233   void NotifyUserActivation() override;
234
235   void AbortClientNavigation() override;
236
237   WebSpellCheckPanelHostClient* SpellCheckPanelHostClient() const override;
238
239   WebTextCheckClient* GetTextCheckerClient() const override;
240
241   scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
242   std::unique_ptr<URLLoader> CreateURLLoaderForTesting() override;
243
244   blink::ChildURLLoaderFactoryBundle* GetLoaderFactoryBundle() override;
245
246   scoped_refptr<WebBackgroundResourceFetchAssets>
247   MaybeGetBackgroundResourceFetchAssets() override;
248
249   blink::BrowserInterfaceBrokerProxy& GetBrowserInterfaceBroker() override;
250
251   AssociatedInterfaceProvider* GetRemoteNavigationAssociatedInterfaces()
252       override;
253
254   void AnnotatedRegionsChanged() override;
255
256   base::UnguessableToken GetDevToolsFrameToken() const override;
257
258   String evaluateInInspectorOverlayForTesting(const String& script) override;
259
260   bool HandleCurrentKeyboardEvent() override;
261
262   void DidChangeSelection(bool is_selection_empty,
263                           blink::SyncCondition force_sync) override;
264
265   void DidChangeContents() override;
266
267   Frame* FindFrame(const AtomicString& name) const override;
268
269   void FocusedElementChanged(Element* element) override;
270
271   void OnMainFrameIntersectionChanged(
272       const gfx::Rect& main_frame_intersection_rect) override;
273
274   void OnMainFrameViewportRectangleChanged(
275       const gfx::Rect& main_frame_viewport_rect) override;
276
277   void OnMainFrameImageAdRectangleChanged(
278       DOMNodeId element_id,
279       const gfx::Rect& image_ad_rect) override;
280
281   void OnOverlayPopupAdDetected() override;
282
283   void OnLargeStickyAdDetected() override;
284
285   bool IsPluginHandledExternally(HTMLPlugInElement&,
286                                  const KURL&,
287                                  const String&) override;
288   v8::Local<v8::Object> GetScriptableObject(HTMLPlugInElement&,
289                                             v8::Isolate*) override;
290
291   scoped_refptr<WebWorkerFetchContext> CreateWorkerFetchContext() override;
292   scoped_refptr<WebWorkerFetchContext>
293   CreateWorkerFetchContextForPlzDedicatedWorker(
294       WebDedicatedWorkerHostFactoryClient*) override;
295   std::unique_ptr<WebContentSettingsClient> CreateWorkerContentSettingsClient()
296       override;
297
298   void SetMouseCapture(bool capture) override;
299
300   bool UsePrintingLayout() const override;
301
302   std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper>
303   CreateResourceLoadInfoNotifierWrapper() override;
304
305   void BindDevToolsAgent(
306       mojo::PendingAssociatedRemote<mojom::blink::DevToolsAgentHost> host,
307       mojo::PendingAssociatedReceiver<mojom::blink::DevToolsAgent> receiver)
308       override;
309
310  private:
311   bool IsLocalFrameClientImpl() const override { return true; }
312   WebDevToolsAgentImpl* DevToolsAgent();
313
314   // The WebFrame that owns this object and manages its lifetime. Therefore,
315   // the web frame object is guaranteed to exist.
316   Member<WebLocalFrameImpl> web_frame_;
317
318   String user_agent_;
319 };
320
321 template <>
322 struct DowncastTraits<LocalFrameClientImpl> {
323   static bool AllowFrom(const LocalFrameClient& client) {
324     return client.IsLocalFrameClientImpl();
325   }
326 };
327
328 }  // namespace blink
329
330 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_LOCAL_FRAME_CLIENT_IMPL_H_