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 "base/memory/scoped_ptr.h"
11 #include "content/public/browser/browser_context.h"
12 #include "browser/javascript_dialog_manager_efl.h"
13 #include "browser_context_efl.h"
14 #include "eweb_view.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_delegate.h"
17 #include "content/public/common/frame_navigate_params.h"
18 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/web_contents_observer.h"
20 #include "content/browser/web_contents/web_contents_impl.h"
22 #include "browser/favicon/favicon_downloader.h"
23 #include "public/ewk_view.h"
24 #include "ui/base/ime/text_input_type.h"
26 class DidPrintPagesParams;
27 class Ewk_Wrt_Message_Data;
28 class JavaScriptDialogManagerEfl;
31 struct DateTimeSuggestion;
33 class WebContentsDelegateEfl
34 : public WebContentsDelegate,
35 public WebContentsObserver {
37 WebContentsDelegateEfl(EWebView*);
38 ~WebContentsDelegateEfl();
40 virtual WebContents* OpenURLFromTab(WebContents* source,
41 const content::OpenURLParams& params) override;
42 virtual void NavigationStateChanged(WebContents* source,
43 InvalidateTypes changed_flags) override;
45 virtual void LoadProgressChanged(WebContents* source, double progress) override;
46 virtual void LoadingStateChanged(WebContents* source,
47 bool to_different_document) override;
49 virtual bool ShouldCreateWebContents(
52 int main_frame_route_id,
54 const std::string& frame_name,
55 const GURL& target_url,
56 const std::string& partition_id,
57 SessionStorageNamespace* session_storage_namespace) override;
59 virtual void CloseContents(WebContents* source) override;
61 void EnterFullscreenModeForTab(content::WebContents* web_contents,
62 const GURL& origin) override;
63 void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
65 virtual bool IsFullscreenForTabOrPending(
66 const WebContents* web_contents) const override;
67 #if defined(TIZEN_MULTIMEDIA_SUPPORT)
68 virtual bool CheckMediaAccessPermission(WebContents* web_contents,
69 const GURL& security_origin,
70 MediaStreamType type) override;
72 virtual void RequestMediaAccessPermission(
73 WebContents* web_contents,
74 const MediaStreamRequest& request,
75 const MediaResponseCallback& callback) override;
77 void RequestMediaAccessAllow(const MediaStreamRequest& request,
78 const MediaResponseCallback& callback);
80 void RequestMediaAccessDeny(const MediaStreamRequest& request,
81 const MediaResponseCallback& callback);
83 void RegisterProtocolHandler(WebContents* web_contents,
84 const std::string& protocol,
86 bool user_gesture) override;
88 void UnregisterProtocolHandler(WebContents* web_contents,
89 const std::string& protocol,
91 bool user_gesture) override;
93 void FindReply(WebContents* web_contents,
95 int number_of_matches,
96 const gfx::Rect& selection_rect,
97 int active_match_ordinal,
98 bool final_update) override;
100 void RequestCertificateConfirm(WebContents* web_contents, int cert_error,
101 const net::SSLInfo& ssl_info, const GURL& url, ResourceType resource_type,
103 bool strict_enforcement,
104 const base::Callback<void(bool)>& callback,
105 CertificateRequestResultType* result);
107 EWebView* web_view() const { return web_view_; }
108 WebContents& web_contents() const { return web_contents_; }
110 virtual void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
111 const GURL& validated_url,
113 bool is_iframe_srcdoc) override;
115 virtual void DidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
117 ui::PageTransition transition_type) override;
119 virtual void DidNavigateMainFrame(const LoadCommittedDetails& details,
120 const FrameNavigateParams& params) override;
121 virtual void DocumentOnLoadCompletedInMainFrame() override;
123 virtual void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
124 const LoadCommittedDetails& details,
125 const FrameNavigateParams& params) override;
127 void OnAuthRequired(net::URLRequest* request,
128 const std::string& realm,
129 LoginDelegateEfl* login_delegate);
131 virtual void DidFinishLoad(RenderFrameHost* render_frame_host,
132 const GURL& validated_url) override;
134 virtual void DidUpdateFaviconURL(const std::vector<FaviconURL>& candidates) override;
135 virtual void DidDownloadFavicon(bool success, const GURL& icon_url, const SkBitmap& bitmap);
137 void OnUpdateSettings(const Ewk_Settings *settings);
138 void SetContentSecurityPolicy(const std::string& policy, Ewk_CSP_Header_Type header_type);
140 JavaScriptDialogManager* GetJavaScriptDialogManager(WebContents* source) override;
142 void DidFirstVisuallyNonEmptyPaint() override;
144 bool OnMessageReceived(const IPC::Message& message) override;
145 void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
146 void NavigationEntryCommitted(const LoadCommittedDetails& load_details) override;
147 void RenderViewCreated(RenderViewHost* render_view_host) override;
148 void RenderProcessGone(base::TerminationStatus status) override;
149 bool AddMessageToConsole(WebContents* source,
151 const base::string16& message,
153 const base::string16& source_id) override;
154 void RunFileChooser(WebContents* web_contents,
155 const FileChooserParams& params) override;
156 ColorChooser* OpenColorChooser(WebContents* web_contents, SkColor color,
157 const std::vector<ColorSuggestion>& suggestions) override;
158 void OpenDateTimeDialog(ui::TextInputType dialog_type,
163 const std::vector<DateTimeSuggestion>& suggestions) override;
164 bool PreHandleGestureEvent(WebContents* source,
165 const blink::WebGestureEvent& event) override;
167 void TitleWasSet(content::NavigationEntry* entry,
168 bool explicit_set) override;
171 void OnGetContentSecurityPolicy(IPC::Message* reply_msg);
172 void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
173 void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
174 IPC::Message* reply);
178 WebContents& web_contents_;
180 struct ContentSecurityPolicy {
181 ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
186 Ewk_CSP_Header_Type header_type;
189 scoped_ptr<ContentSecurityPolicy> pending_content_security_policy_;
190 bool document_created_;
191 JavaScriptDialogManagerEfl* dialog_manager_;
192 scoped_ptr<FaviconDownloader> favicon_downloader_;
193 base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;
194 scoped_ptr<_Ewk_Certificate_Policy_Decision> certificate_policy_decision_;
196 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateEfl);