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.h"
23 #include "ui/base/ime/text_input_type.h"
25 class DidPrintPagesParams;
26 class Ewk_Wrt_Message_Data;
27 class JavaScriptDialogManagerEfl;
30 struct DateTimeSuggestion;
32 class WebContentsDelegateEfl : public WebContentsDelegate,
33 public WebContentsObserver {
35 WebContentsDelegateEfl(EWebView*);
36 ~WebContentsDelegateEfl();
38 // Overridden from content::WebContentsDelegate:
39 content::WebContents* OpenURLFromTab(
40 content::WebContents* source,
41 const content::OpenURLParams& params) override;
42 void NavigationStateChanged(content::WebContents* source,
43 content::InvalidateTypes changed_flags) override;
44 void LoadingStateChanged(content::WebContents* source,
45 bool to_different_document) override;
46 bool ShouldCreateWebContents(
47 content::WebContents* web_contents,
48 content::RenderFrameHost* opener,
49 content::SiteInstance* source_site_instance,
51 int32_t main_frame_route_id,
52 int32_t main_frame_widget_route_id,
53 content::mojom::WindowContainerType window_container_type,
54 const GURL& opener_url,
55 const std::string& frame_name,
56 const GURL& target_url,
57 const std::string& partition_id,
58 content::SessionStorageNamespace* session_storage_namespace) override;
59 void CloseContents(content::WebContents* source) override;
60 void EnterFullscreenModeForTab(content::WebContents* web_contents,
61 const GURL& origin) override;
62 void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
63 bool IsFullscreenForTabOrPending(
64 const content::WebContents* web_contents) const override;
66 #if defined(TIZEN_MULTIMEDIA_SUPPORT)
67 virtual bool CheckMediaAccessPermission(WebContents* web_contents,
68 const GURL& security_origin,
69 MediaStreamType type) override;
71 virtual void RequestMediaAccessPermission(
72 WebContents* web_contents,
73 const MediaStreamRequest& request,
74 const MediaResponseCallback& callback) override;
76 void RequestMediaAccessAllow(const MediaStreamRequest& request,
77 const MediaResponseCallback& callback);
79 void RequestMediaAccessDeny(const MediaStreamRequest& request,
80 const MediaResponseCallback& callback);
82 void RegisterProtocolHandler(content::WebContents* web_contents,
83 const std::string& protocol,
85 bool user_gesture) override;
86 void UnregisterProtocolHandler(content::WebContents* web_contents,
87 const std::string& protocol,
89 bool user_gesture) override;
90 void FindReply(content::WebContents* web_contents,
92 int number_of_matches,
93 const gfx::Rect& selection_rect,
94 int active_match_ordinal,
95 bool final_update) override;
97 void DidRenderFrame() override;
99 void RequestCertificateConfirm(
100 WebContents* web_contents,
102 const net::SSLInfo& ssl_info,
104 ResourceType resource_type,
106 bool strict_enforcement,
107 base::Callback<void(CertificateRequestResultType)>& callback);
109 JavaScriptDialogManager* GetJavaScriptDialogManager(
110 WebContents* source) override;
112 void OnUpdateSettings(const Ewk_Settings* settings);
113 void SetContentSecurityPolicy(const std::string& policy,
114 Ewk_CSP_Header_Type header_type);
116 void DidFirstVisuallyNonEmptyPaint() override;
117 void DidStartLoading() override;
119 bool OnMessageReceived(const IPC::Message& message) override;
120 void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
121 void NavigationEntryCommitted(
122 const LoadCommittedDetails& load_details) override;
123 void RenderViewCreated(RenderViewHost* render_view_host) override;
124 void RenderProcessGone(base::TerminationStatus status) override;
125 bool DidAddMessageToConsole(WebContents* source,
127 const base::string16& message,
129 const base::string16& source_id) override;
130 void RunFileChooser(content::RenderFrameHost* render_frame_host,
131 const FileChooserParams& params) override;
132 ColorChooser* OpenColorChooser(
133 WebContents* web_contents,
135 const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions)
137 void OpenDateTimeDialog(ui::TextInputType dialog_type,
142 const std::vector<DateTimeSuggestion>& suggestions);
143 bool PreHandleGestureEvent(WebContents* source,
144 const blink::WebGestureEvent& event) override;
146 // WebContentsObserver---------------------------------------------------
147 void DidFailLoad(RenderFrameHost* render_frame_host,
148 const GURL& validated_url,
150 const base::string16& error_description) override;
152 // EWK_BRINGUP: These APIs are removed in upstream.
153 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set);
155 void LoadProgressChanged(WebContents* source, double progress);
156 void DidFinishLoad(RenderFrameHost* render_frame_host,
157 const GURL& validated_url);
159 void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
160 const GURL& validated_url,
162 bool is_iframe_srcdoc);
164 void DidUpdateFaviconURL(const std::vector<FaviconURL>& candidates);
166 void DidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
168 ui::PageTransition transition_type);
170 void DidNavigateMainFrame(const LoadCommittedDetails& details,
171 const FrameNavigateParams& params);
172 void DocumentOnLoadCompletedInMainFrame();
174 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
175 const LoadCommittedDetails& details,
176 const FrameNavigateParams& params);
178 void DidFailProvisionalLoad(RenderFrameHost* render_frame_host,
179 const GURL& validated_url,
181 const base::string16& error_description,
182 bool was_ignored_by_handler);
185 void OnAuthRequired(net::URLRequest* request,
186 const std::string& realm,
187 LoginDelegateEfl* login_delegate);
189 void DidDownloadFavicon(bool success,
190 const GURL& icon_url,
191 const SkBitmap& bitmap);
193 EWebView* web_view() const { return web_view_; }
194 WebContents& web_contents() const { return web_contents_; }
197 void OnGetContentSecurityPolicy(IPC::Message* reply_msg);
198 void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
199 void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
200 IPC::Message* reply);
204 WebContents& web_contents_;
206 bool did_render_frame_;
207 bool did_first_visually_non_empty_paint_;
209 struct ContentSecurityPolicy {
210 ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
211 : policy(p), header_type(type) {}
213 Ewk_CSP_Header_Type header_type;
216 std::unique_ptr<ContentSecurityPolicy> pending_content_security_policy_;
217 bool document_created_;
218 JavaScriptDialogManagerEfl* dialog_manager_;
219 std::unique_ptr<FaviconDownloader> favicon_downloader_;
220 base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;
221 std::unique_ptr<_Ewk_Certificate_Policy_Decision>
222 certificate_policy_decision_;
224 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateEfl);