[M40 Merge] Disable double tap zoom on fullscreen view
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / web_contents_delegate_efl.h
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.
4
5 #ifndef WEB_CONTENTS_DELEGATE_EFL
6 #define WEB_CONTENTS_DELEGATE_EFL
7
8 #include <deque>
9
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"
21 #include "url/gurl.h"
22 #include "browser/favicon/favicon_downloader.h"
23 #include "public/ewk_view.h"
24 #include "ui/base/ime/text_input_type.h"
25
26 class DidPrintPagesParams;
27 class Ewk_Wrt_Message_Data;
28 class JavaScriptDialogManagerEfl;
29
30 namespace content {
31 struct DateTimeSuggestion;
32
33 class WebContentsDelegateEfl
34     : public WebContentsDelegate,
35       public WebContentsObserver {
36  public:
37   WebContentsDelegateEfl(EWebView*);
38   ~WebContentsDelegateEfl();
39
40   virtual WebContents* OpenURLFromTab(WebContents* source,
41       const content::OpenURLParams& params) override;
42   virtual void NavigationStateChanged(WebContents* source,
43                                       InvalidateTypes changed_flags) override;
44
45   virtual void LoadProgressChanged(WebContents* source, double progress) override;
46   virtual void LoadingStateChanged(WebContents* source,
47                                    bool to_different_document) override;
48
49   virtual bool ShouldCreateWebContents(
50       WebContents*,
51       int route_id,
52       int main_frame_route_id,
53       WindowContainerType,
54       const base::string16& frame_name,
55       const GURL& target_url,
56       const std::string& partition_id,
57       SessionStorageNamespace* session_storage_namespace) override;
58
59   virtual void CloseContents(WebContents* source) override;
60
61   void EnterFullscreenModeForTab(content::WebContents* web_contents,
62                                  const GURL& origin) override;
63   void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
64
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;
71
72   virtual void RequestMediaAccessPermission(
73       WebContents* web_contents,
74       const MediaStreamRequest& request,
75       const MediaResponseCallback& callback) override;
76
77   void OnAccessRequestResponse(bool allowed);
78 #endif
79   void RegisterProtocolHandler(WebContents* web_contents,
80                                const std::string& protocol,
81                                const GURL& url,
82                                bool user_gesture) override;
83
84   void FindReply(WebContents* web_contents,
85                  int request_id,
86                  int number_of_matches,
87                  const gfx::Rect& selection_rect,
88                  int active_match_ordinal,
89                  bool final_update) override;
90
91   void RequestCertificateConfirm(WebContents* web_contents, int cert_error,
92       const net::SSLInfo& ssl_info, const GURL& url, ResourceType resource_type,
93       bool overridable,
94       bool strict_enforcement,
95       const base::Callback<void(bool)>& callback,
96       CertificateRequestResultType* result);
97
98   EWebView* web_view() const { return web_view_; }
99   WebContents& web_contents() const { return web_contents_; }
100
101   virtual void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
102                                                const GURL& validated_url,
103                                                bool is_error_page,
104                                                bool is_iframe_srcdoc) override;
105
106   virtual void DidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
107                                                 const GURL& url,
108                                                 ui::PageTransition transition_type) override;
109
110   virtual void DidNavigateMainFrame(const LoadCommittedDetails& details,
111                                     const FrameNavigateParams& params) override;
112   virtual void DocumentOnLoadCompletedInMainFrame() override;
113
114   virtual void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
115                                    const LoadCommittedDetails& details,
116                                    const FrameNavigateParams& params) override;
117
118   void OnAuthRequired(net::URLRequest* request,
119                       const std::string& realm,
120                       LoginDelegateEfl* login_delegate);
121
122   virtual void DidFinishLoad(RenderFrameHost* render_frame_host,
123                              const GURL& validated_url) override;
124
125   virtual void DidUpdateFaviconURL(const std::vector<FaviconURL>& candidates) override;
126   virtual void DidDownloadFavicon(bool success, const GURL& icon_url, const SkBitmap& bitmap);
127
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);
132
133   JavaScriptDialogManager* GetJavaScriptDialogManager(WebContents* source) override;
134
135   void DidFirstVisuallyNonEmptyPaint() override;
136
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,
143                            int32 level,
144                            const base::string16& message,
145                            int32 line_no,
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,
152       double dialog_value,
153       double min,
154       double max,
155       double step,
156       const std::vector<DateTimeSuggestion>& suggestions) override;
157   bool PreHandleGestureEvent(WebContents* source,
158                              const blink::WebGestureEvent& event) override;
159
160  private:
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);
165
166   EWebView* web_view_;
167   bool is_fullscreen_;
168   WebContents& web_contents_;
169
170   struct ContentSecurityPolicy {
171     ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
172         : policy(p),
173           header_type(type) {
174     }
175     std::string policy;
176     Ewk_CSP_Header_Type header_type;
177   };
178
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;
187   };
188
189   //Queue to hold all pending request for requesting user permissions.
190   std::deque<PendingAccessRequest> requests_queue_;
191 #endif
192
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_;
199
200   DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateEfl);
201 };
202
203 }
204
205 #endif