1 // Copyright 2014 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_DELEGATE_EFL
6 #define WEB_CONTENTS_DELEGATE_EFL
10 #include "content/public/browser/browser_context.h"
11 #include "browser/javascript_dialog_manager_efl.h"
12 #include "browser_context_efl.h"
13 #include "eweb_view.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_contents_delegate.h"
16 #include "content/public/common/frame_navigate_params.h"
17 #include "content/public/browser/render_view_host.h"
18 #include "content/public/browser/web_contents_observer.h"
19 #include "content/browser/web_contents/web_contents_impl.h"
21 #include "browser/favicon/favicon_downloader.h"
22 #include "public/ewk_view_internal.h"
23 #include "ui/base/ime/text_input_type.h"
25 class DidPrintPagesParams;
26 class Ewk_Wrt_Message_Data;
27 class JavaScriptDialogManagerEfl;
31 class WebContentsDelegateEfl : public WebContentsDelegate,
32 public WebContentsObserver,
35 WebContentsDelegateEfl(EWebView*);
36 ~WebContentsDelegateEfl() override;
38 // Overridden from WebContentsDelegate:
39 WebContents* OpenURLFromTab(WebContents* source,
40 const OpenURLParams& params) override;
41 void NavigationStateChanged(WebContents* source,
42 InvalidateTypes changed_flags) override;
43 void LoadingStateChanged(WebContents* source,
44 bool to_different_document) override;
45 bool ShouldCreateWebContents(
46 WebContents* web_contents,
47 RenderFrameHost* opener,
48 SiteInstance* source_site_instance,
50 int32_t main_frame_route_id,
51 int32_t main_frame_widget_route_id,
52 mojom::WindowContainerType window_container_type,
53 const GURL& opener_url,
54 const std::string& frame_name,
55 const GURL& target_url,
56 const std::string& partition_id,
57 SessionStorageNamespace* session_storage_namespace);
58 void CloseContents(WebContents* source) override;
59 void EnterFullscreenModeForTab(
60 RenderFrameHost* requesting_frame,
61 const blink::mojom::FullscreenOptions& options) override;
62 void ExitFullscreenModeForTab(WebContents* web_contents) override;
63 bool IsFullscreenForTabOrPending(const WebContents* web_contents) override;
65 #if defined(TIZEN_MULTIMEDIA_SUPPORT)
66 virtual bool CheckMediaAccessPermission(WebContents* web_contents,
67 const GURL& security_origin,
68 MediaStreamType type) override;
70 virtual void RequestMediaAccessPermission(
71 WebContents* web_contents,
72 const MediaStreamRequest& request,
73 MediaResponseCallback callback) override;
75 void RequestMediaAccessAllow(const MediaStreamRequest& request,
76 MediaResponseCallback callback);
78 void RequestMediaAccessDeny(const MediaStreamRequest& request,
79 MediaResponseCallback callback);
81 void RegisterProtocolHandler(WebContents* web_contents,
82 const std::string& protocol,
84 bool user_gesture) override;
85 void UnregisterProtocolHandler(WebContents* web_contents,
86 const std::string& protocol,
88 bool user_gesture) override;
89 void FindReply(WebContents* web_contents,
91 int number_of_matches,
92 const gfx::Rect& selection_rect,
93 int active_match_ordinal,
94 bool final_update) override;
96 void DidRenderFrame() override;
98 void RequestCertificateConfirm(
99 WebContents* web_contents,
101 const net::SSLInfo& ssl_info,
104 bool strict_enforcement,
105 base::Callback<void(CertificateRequestResultType)>& callback);
107 JavaScriptDialogManager* GetJavaScriptDialogManager(
108 WebContents* source) override;
110 void OnUpdateSettings(const Ewk_Settings* settings);
111 void SetContentSecurityPolicy(const std::string& policy,
112 Ewk_CSP_Header_Type header_type);
114 void DidFirstVisuallyNonEmptyPaint() override;
115 void DidStartLoading() override;
117 bool OnMessageReceived(const IPC::Message& message) override;
118 void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
119 void NavigationEntryCommitted(
120 const LoadCommittedDetails& load_details) override;
121 void RenderViewCreated(RenderViewHost* render_view_host) override;
122 void RenderProcessGone(base::TerminationStatus status) override;
123 bool DidAddMessageToConsole(WebContents* source,
124 blink::mojom::ConsoleMessageLevel level,
125 const base::string16& message,
127 const base::string16& source_id) override;
128 void RunFileChooser(RenderFrameHost* render_frame_host,
129 std::unique_ptr<FileSelectListener> listener,
130 const blink::mojom::FileChooserParams& params) override;
131 ColorChooser* OpenColorChooser(
132 WebContents* web_contents,
134 const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions)
136 #if !defined(EWK_BRINGUP) // FIXME: m76 bringup
137 void OpenDateTimeDialog(ui::TextInputType dialog_type,
142 const std::vector<DateTimeSuggestion>& suggestions);
144 bool PreHandleGestureEvent(WebContents* source,
145 const blink::WebGestureEvent& event) override;
147 // WebContentsObserver---------------------------------------------------
148 void DidFailLoad(RenderFrameHost* render_frame_host,
149 const GURL& validated_url,
150 int error_code) override;
152 // IPC::Sender-----------------------------------------------------------
153 bool Send(IPC::Message* message) override;
155 // EWK_BRINGUP: These APIs are removed in upstream.
156 void TitleWasSet(NavigationEntry* entry, bool explicit_set);
158 void LoadProgressChanged(WebContents* source, double progress);
159 void DidFinishLoad(RenderFrameHost* render_frame_host,
160 const GURL& validated_url);
162 void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
163 const GURL& validated_url,
165 bool is_iframe_srcdoc);
167 void DidUpdateFaviconURL(
168 RenderFrameHost* render_frame_host,
169 const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
171 void DidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
173 ui::PageTransition transition_type);
175 void DidNavigateMainFrame(const LoadCommittedDetails& details,
176 const FrameNavigateParams& params);
177 void DocumentOnLoadCompletedInMainFrame();
179 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
180 const LoadCommittedDetails& details,
181 const FrameNavigateParams& params);
183 void DidFailProvisionalLoad(RenderFrameHost* render_frame_host,
184 const GURL& validated_url,
186 const base::string16& error_description,
187 bool was_ignored_by_handler);
190 void OnAuthRequired(net::URLRequest* request,
191 const std::string& realm,
192 LoginDelegateEfl* login_delegate);
194 void DidDownloadFavicon(bool success,
195 const GURL& icon_url,
196 const SkBitmap& bitmap);
198 EWebView* web_view() const { return web_view_; }
199 WebContents& web_contents() const { return web_contents_; }
202 void OnGetContentSecurityPolicy(IPC::Message* reply_msg);
203 void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
204 void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
205 IPC::Message* reply);
209 WebContents& web_contents_;
211 bool did_render_frame_;
212 bool did_first_visually_non_empty_paint_;
214 struct ContentSecurityPolicy {
215 ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
216 : policy(p), header_type(type) {}
218 Ewk_CSP_Header_Type header_type;
221 std::unique_ptr<ContentSecurityPolicy> pending_content_security_policy_;
222 bool document_created_;
223 JavaScriptDialogManagerEfl* dialog_manager_;
224 std::unique_ptr<FaviconDownloader> favicon_downloader_;
225 base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;
226 std::unique_ptr<_Ewk_Certificate_Policy_Decision>
227 certificate_policy_decision_;
229 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateEfl);