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 base::string16& 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 OnAccessRequestResponse(bool allowed);
79 void RegisterProtocolHandler(WebContents* web_contents,
80 const std::string& protocol,
82 bool user_gesture) override;
84 void FindReply(WebContents* web_contents,
86 int number_of_matches,
87 const gfx::Rect& selection_rect,
88 int active_match_ordinal,
89 bool final_update) override;
91 void RequestCertificateConfirm(WebContents* web_contents, int cert_error,
92 const net::SSLInfo& ssl_info, const GURL& url, ResourceType resource_type,
94 bool strict_enforcement,
95 const base::Callback<void(bool)>& callback,
96 CertificateRequestResultType* result);
98 EWebView* web_view() const { return web_view_; }
99 WebContents& web_contents() const { return web_contents_; }
101 virtual void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
102 const GURL& validated_url,
104 bool is_iframe_srcdoc) override;
106 virtual void DidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
108 ui::PageTransition transition_type) override;
110 virtual void DidNavigateMainFrame(const LoadCommittedDetails& details,
111 const FrameNavigateParams& params) override;
112 virtual void DocumentOnLoadCompletedInMainFrame() override;
114 virtual void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
115 const LoadCommittedDetails& details,
116 const FrameNavigateParams& params) override;
118 void OnAuthRequired(net::URLRequest* request,
119 const std::string& realm,
120 LoginDelegateEfl* login_delegate);
122 virtual void DidFinishLoad(RenderFrameHost* render_frame_host,
123 const GURL& validated_url) override;
125 virtual void DidUpdateFaviconURL(const std::vector<FaviconURL>& candidates) override;
126 virtual void DidDownloadFavicon(bool success, const GURL& icon_url, const SkBitmap& bitmap);
128 void OnUpdateSettings(const Ewk_Settings *settings);
129 void SetContentSecurityPolicy(const std::string& policy, Ewk_CSP_Header_Type header_type);
130 void UpdateFormNavigation(int formElementCount, int currentNodeIndex,
131 bool prevState, bool nextState);
133 JavaScriptDialogManager* GetJavaScriptDialogManager(WebContents* source) override;
135 void DidFirstVisuallyNonEmptyPaint() override;
137 bool OnMessageReceived(const IPC::Message& message) override;
138 void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
139 void NavigationEntryCommitted(const LoadCommittedDetails& load_details) override;
140 void RenderViewCreated(RenderViewHost* render_view_host) override;
141 void RenderProcessGone(base::TerminationStatus status) override;
142 bool AddMessageToConsole(WebContents* source,
144 const base::string16& message,
146 const base::string16& source_id) override;
147 void RunFileChooser(WebContents* web_contents,
148 const FileChooserParams& params) override;
149 ColorChooser* OpenColorChooser(WebContents* web_contents, SkColor color,
150 const std::vector<ColorSuggestion>& suggestions) override;
151 void OpenDateTimeDialog(ui::TextInputType dialog_type,
156 const std::vector<DateTimeSuggestion>& suggestions) override;
157 bool PreHandleGestureEvent(WebContents* source,
158 const blink::WebGestureEvent& event) override;
161 void OnGetContentSecurityPolicy(IPC::Message* reply_msg);
162 void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
163 void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
164 IPC::Message* reply);
168 WebContents& web_contents_;
170 struct ContentSecurityPolicy {
171 ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
176 Ewk_CSP_Header_Type header_type;
179 #if defined(TIZEN_MULTIMEDIA_SUPPORT)
180 // Structure to hold media request and its callback.
181 struct PendingAccessRequest {
182 PendingAccessRequest(const content::MediaStreamRequest& request,
183 const content::MediaResponseCallback& callback);
184 ~PendingAccessRequest();
185 content::MediaStreamRequest request;
186 content::MediaResponseCallback callback;
189 //Queue to hold all pending request for requesting user permissions.
190 std::deque<PendingAccessRequest> requests_queue_;
193 scoped_ptr<ContentSecurityPolicy> pending_content_security_policy_;
194 bool document_created_;
195 JavaScriptDialogManagerEfl* dialog_manager_;
196 scoped_ptr<FaviconDownloader> favicon_downloader_;
197 base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;
198 scoped_ptr<_Ewk_Certificate_Policy_Decision> certificate_policy_decision_;
200 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateEfl);