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.
5 #ifndef WEB_CONTENTS_OBSERVER_EFL_H_
6 #define WEB_CONTENTS_OBSERVER_EFL_H_
10 #include "base/memory/weak_ptr.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "eweb_view.h"
14 class DidPrintPagesParams;
15 class Ewk_Wrt_Message_Data;
16 class FaviconDownloader;
26 class WebContentsDelegateEfl;
28 class WebContentsObserverEfl : public WebContentsObserver, public IPC::Sender {
30 explicit WebContentsObserverEfl(EWebView* view,
31 WebContentsDelegateEfl* delegate);
32 WebContentsObserverEfl(const WebContentsObserverEfl&) = delete;
33 WebContentsObserverEfl& operator=(const WebContentsObserverEfl&) = delete;
34 ~WebContentsObserverEfl() override;
36 void SetContentSecurityPolicy(const std::string& policy,
37 Ewk_CSP_Header_Type header_type);
39 // IPC::Sender-----------------------------------------------------------
40 bool Send(IPC::Message* message) override;
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;
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,
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);
84 void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
85 void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
87 void OnDidChangeContentsSize(int width, int height);
88 void OnDidChangeFocusedNodeBounds(const gfx::RectF& focused_node_bounds);
90 void DidDownloadFavicon(bool success,
92 const SkBitmap& bitmap);
94 struct ContentSecurityPolicy {
95 ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
96 : policy(p), header_type(type) {}
98 Ewk_CSP_Header_Type header_type;
100 #if BUILDFLAG(IS_TIZEN_TV)
101 void OnRunArrowScroll();
103 bool document_created_ = false;
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_;
112 } // namespace content
114 #endif // WEB_CONTENTS_OBSERVER_EFL_H_