1 #ifndef WEB_CONTENTS_DELEGATE_EFL
2 #define WEB_CONTENTS_DELEGATE_EFL
6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/weak_ptr.h"
8 #include "content/public/browser/browser_context.h"
9 #include "browser/javascript_dialog_manager_efl.h"
10 #include "browser_context_efl.h"
11 #include "eweb_view.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_contents_delegate.h"
14 #include "content/public/common/frame_navigate_params.h"
15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents_observer.h"
17 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "browser/favicon/favicon_downloader.h"
20 #include "third_party/WebKit/Source/platform/text/TextDirection.h"
21 #include "ui/base/ime/text_input_type.h"
23 #include "tizen_webview/public/tw_content_security_policy.h"
25 class DidPrintPagesParams;
27 namespace tizen_webview {
28 class WrtIpcMessageData;
32 struct DateTimeSuggestion;
34 class WebContentsDelegateEfl
35 : public WebContentsDelegate,
36 public WebContentsObserver {
38 WebContentsDelegateEfl(EWebView*);
39 ~WebContentsDelegateEfl();
41 // Reusing the given WebContents instead of creating a new one.
42 WebContentsDelegateEfl(EWebView*, WebContents*);
44 virtual void NavigationStateChanged(const WebContents* source,
45 unsigned changed_flags) OVERRIDE;
47 virtual void LoadProgressChanged(WebContents* source, double progress) OVERRIDE;
48 virtual void LoadingStateChanged(WebContents* source,
49 bool to_different_document) OVERRIDE;
51 virtual bool ShouldCreateWebContents(
55 const base::string16& frame_name,
56 const GURL& target_url,
57 const std::string& partition_id,
58 SessionStorageNamespace* session_storage_namespace) OVERRIDE;
60 virtual void WebContentsCreated(
61 WebContents* source_contents,
62 int opener_render_frame_id,
63 const base::string16& frame_name,
64 const GURL& target_url,
65 WebContents* new_contents) OVERRIDE;
67 virtual void CloseContents(WebContents* source) OVERRIDE;
69 virtual void ToggleFullscreenModeForTab(WebContents* web_contents,
70 bool enter_fullscreen) OVERRIDE;
71 virtual bool IsFullscreenForTabOrPending(
72 const WebContents* web_contents) const OVERRIDE;
73 virtual void RequestMediaAccessPermission(
74 WebContents* web_contents,
75 const MediaStreamRequest& request,
76 const MediaResponseCallback& callback) OVERRIDE;
77 void RegisterProtocolHandler(WebContents* web_contents,
78 const std::string& protocol,
80 bool user_gesture) OVERRIDE;
82 void FindReply(WebContents* web_contents,
84 int number_of_matches,
85 const gfx::Rect& selection_rect,
86 int active_match_ordinal,
87 bool final_update) OVERRIDE;
89 void RequestCertificateConfirm(WebContents* web_contents, int cert_error,
90 const net::SSLInfo& ssl_info, const GURL& url, ResourceType::Type resource_type,
92 bool strict_enforcement,
93 const base::Callback<void(bool)>& callback,
94 CertificateRequestResultType* result);
96 EWebView* web_view() const { return web_view_; }
97 WebContents* web_contents() const { return web_contents_; }
99 virtual void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
100 const GURL& validated_url,
102 bool is_iframe_srcdoc) OVERRIDE;
104 virtual void DidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
106 PageTransition transition_type) OVERRIDE;
108 virtual void DidNavigateAnyFrame(const LoadCommittedDetails& details, const FrameNavigateParams& params) OVERRIDE;
109 void OnAuthRequired(net::URLRequest* request,
110 const std::string& realm,
111 LoginDelegateEfl* login_delegate);
112 virtual void DidFailProvisionalLoad(RenderFrameHost* render_frame_host,
113 const GURL& validated_url,
115 const base::string16& error_description) OVERRIDE;
116 virtual void DidFailLoad(RenderFrameHost* render_frame_host,
117 const GURL& validated_url,
119 const base::string16& error_description) OVERRIDE;
121 virtual void DidFinishLoad(RenderFrameHost* render_frame_host,
122 const GURL& validated_url) OVERRIDE;
124 virtual void DidStartLoading(RenderViewHost* render_view_host) 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 OnFormSubmit(const GURL&);
129 void SetContentSecurityPolicy(const std::string& policy, tizen_webview::ContentSecurityPolicyType header_type);
130 void ShowPopupMenu(const gfx::Rect& rect, blink::TextDirection textDirection, double pageScaleFactor, const std::vector<MenuItem>& items, int data, int selectedIndex, bool multiple);
131 void HidePopupMenu();
133 void set_new_window_policy(bool policy) { should_open_new_window_ = policy; }
134 bool get_new_window_policy() const { return should_open_new_window_; }
135 JavaScriptDialogManager* GetJavaScriptDialogManager() OVERRIDE;
137 void DidFirstVisuallyNonEmptyPaint() OVERRIDE;
139 bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
140 void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
141 virtual void NavigationEntryCommitted(const LoadCommittedDetails& load_details) OVERRIDE;
142 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
143 virtual bool AddMessageToConsole(WebContents* source,
145 const base::string16& message,
147 const base::string16& source_id) OVERRIDE;
148 void RunFileChooser(WebContents* web_contents, const FileChooserParams& params);
149 ColorChooser* OpenColorChooser(WebContents* web_contents, SkColor color, const std::vector<ColorSuggestion>& suggestions);
150 void OnAccessRequestResponse(Eina_Bool allowed);
151 void OpenDateTimeDialog(ui::TextInputType dialog_type,
156 const std::vector<DateTimeSuggestion>& suggestions);
159 void OnGetContentSecurityPolicy(IPC::Message* reply_msg);
160 void OnWrtPluginMessage(const tizen_webview::WrtIpcMessageData& data);
161 void OnWrtPluginSyncMessage(const tizen_webview::WrtIpcMessageData& data,
162 IPC::Message* reply);
166 WebContents* web_contents_;
168 struct ContentSecurityPolicy {
169 ContentSecurityPolicy(const std::string& p, tizen_webview::ContentSecurityPolicyType type)
174 tizen_webview::ContentSecurityPolicyType header_type;
177 // Structure to hold media request and its callback.
178 struct PendingAccessRequest {
179 PendingAccessRequest(const content::MediaStreamRequest& request,
180 const content::MediaResponseCallback& callback);
181 ~PendingAccessRequest();
182 content::MediaStreamRequest request;
183 content::MediaResponseCallback callback;
186 //Queue to hold all pending request for requesting user permissions.
187 std::deque<PendingAccessRequest> requests_Queue_;
188 scoped_ptr<ContentSecurityPolicy> pending_content_security_policy_;
189 bool document_created_;
190 bool should_open_new_window_;
191 JavaScriptDialogManagerEfl* dialog_manager_;
192 int forward_backward_list_count_;
193 scoped_ptr<FaviconDownloader> favicon_downloader_;
194 base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;
196 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateEfl);