[M120 Migration][VD] Use Arrow Scroll for WebBrowser
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / web_contents_observer_efl.h
1 // Copyright 2022 Samsung Electronics. 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.
4
5 #ifndef WEB_CONTENTS_OBSERVER_EFL_H_
6 #define WEB_CONTENTS_OBSERVER_EFL_H_
7
8 #include <string>
9
10 #include "base/memory/weak_ptr.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "eweb_view.h"
13
14 class DidPrintPagesParams;
15 class Ewk_Wrt_Message_Data;
16 class FaviconDownloader;
17 class GURL;
18 class SkBitmap;
19
20 namespace gfx {
21 class Rect;
22 }
23
24 namespace content {
25
26 class WebContentsDelegateEfl;
27
28 class WebContentsObserverEfl : public WebContentsObserver, public IPC::Sender {
29  public:
30   explicit WebContentsObserverEfl(EWebView* view,
31                                   WebContentsDelegateEfl* delegate);
32   WebContentsObserverEfl(const WebContentsObserverEfl&) = delete;
33   WebContentsObserverEfl& operator=(const WebContentsObserverEfl&) = delete;
34   ~WebContentsObserverEfl() override;
35
36   void SetContentSecurityPolicy(const std::string& policy,
37                                 Ewk_CSP_Header_Type header_type);
38
39   // IPC::Sender-----------------------------------------------------------
40   bool Send(IPC::Message* message) override;
41
42  private:
43   // WebContentsObserver overrides:
44   void DidStartNavigation(NavigationHandle* navigation_handle) override;
45   void DidRedirectNavigation(NavigationHandle* navigation_handle) override;
46   void DidFinishNavigation(NavigationHandle* navigation_handle) override;
47   void LoadProgressChanged(double progress) override;
48   void DidFinishLoad(RenderFrameHost* render_frame_host,
49                      const GURL& validated_url) override;
50   void DidFailLoad(RenderFrameHost* render_frame_host,
51                    const GURL& validated_url,
52                    int error_code) override;
53   void TitleWasSet(NavigationEntry* entry) override;
54   void OnPageScaleFactorChanged(float page_scale_factor) override;
55   void DidFirstVisuallyNonEmptyPaint() override;
56   void DidStartLoading() override;
57   void NavigationEntryCommitted(
58       const LoadCommittedDetails& load_details) override;
59   void PrimaryMainFrameRenderProcessGone(
60       base::TerminationStatus status) override;
61   void RenderViewReady() override;
62   void DidUpdateFaviconURL(
63       RenderFrameHost* render_frame_host,
64       const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
65   bool OnMessageReceived(const IPC::Message& message,
66                          RenderFrameHost* render_frame_host) override;
67   void DidChangeThemeColor() override;
68
69   // IPC message handlers:
70   void OnDidCreateDocumentElement();
71   void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
72   void OnRequestSelectCollectionInformationUpdateACK(int form_element_count,
73                                                      int current_node_index,
74                                                      bool prev_state,
75                                                      bool nest_state);
76   void OnDidChangeMaxScrollOffset(int max_scroll_x, int max_scroll_y);
77   void OnDidChangeScrollOffset(int scroll_x, int scroll_y);
78   void OnFormSubmit(const GURL& url);
79   void OnDidNotAllowScript();
80   void OnPlayLinkEffect();
81 #if BUILDFLAG(IS_TIZEN)
82   void OnEdgeEffectForUIF(bool, bool, bool, bool);
83 #endif
84   void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
85   void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
86                               IPC::Message* reply);
87   void OnDidChangeContentsSize(int width, int height);
88   void OnDidChangeFocusedNodeBounds(const gfx::RectF& focused_node_bounds);
89
90   void DidDownloadFavicon(bool success,
91                           const GURL& icon_url,
92                           const SkBitmap& bitmap);
93
94   struct ContentSecurityPolicy {
95     ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
96         : policy(p), header_type(type) {}
97     std::string policy;
98     Ewk_CSP_Header_Type header_type;
99   };
100 #if BUILDFLAG(IS_TIZEN_TV)
101   void OnRunArrowScroll();
102 #endif
103   bool document_created_ = false;
104   EWebView* web_view_;
105   WebContents& web_contents_;
106   std::unique_ptr<ContentSecurityPolicy> pending_content_security_policy_;
107   std::unique_ptr<FaviconDownloader> favicon_downloader_;
108   WebContentsDelegateEfl* web_contents_delegate_ = nullptr;
109   base::WeakPtrFactory<WebContentsObserverEfl> weak_ptr_factory_;
110 };
111
112 }  // namespace content
113
114 #endif  // WEB_CONTENTS_OBSERVER_EFL_H_