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 RenderViewCreated(RenderViewHost* render_view_host);
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;
68 // IPC message handlers:
69 void OnDidCreateDocumentElement();
70 void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
71 void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
72 void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
74 void OnDidChangeContentsSize(int width, int height);
75 void OnDidChangeFocusedNodeBounds(const gfx::RectF& focused_node_bounds);
77 void DidDownloadFavicon(bool success,
79 const SkBitmap& bitmap);
81 struct ContentSecurityPolicy {
82 ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
83 : policy(p), header_type(type) {}
85 Ewk_CSP_Header_Type header_type;
88 bool document_created_ = false;
90 WebContents& web_contents_;
91 std::unique_ptr<ContentSecurityPolicy> pending_content_security_policy_;
92 std::unique_ptr<FaviconDownloader> favicon_downloader_;
93 WebContentsDelegateEfl* web_contents_delegate_ = nullptr;
94 base::WeakPtrFactory<WebContentsObserverEfl> weak_ptr_factory_;
97 } // namespace content
99 #endif // WEB_CONTENTS_OBSERVER_EFL_H_