[M85 Dev][EFL] Fix compilation errors for desktop build
[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 "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"
20 #include "url/gurl.h"
21 #include "browser/favicon/favicon_downloader.h"
22 #include "public/ewk_view_internal.h"
23 #include "ui/base/ime/text_input_type.h"
24
25 class DidPrintPagesParams;
26 class Ewk_Wrt_Message_Data;
27 class JavaScriptDialogManagerEfl;
28
29 namespace content {
30
31 class WebContentsDelegateEfl : public WebContentsDelegate,
32                                public WebContentsObserver,
33                                public IPC::Sender {
34  public:
35   WebContentsDelegateEfl(EWebView*);
36   ~WebContentsDelegateEfl() override;
37
38   // Overridden from WebContentsDelegate:
39   WebContents* OpenURLFromTab(WebContents* source,
40                               const OpenURLParams& params) override;
41   void NavigationStateChanged(WebContents* source,
42                               InvalidateTypes changed_flags) override;
43   void LoadingStateChanged(WebContents* source,
44                            bool to_different_document) override;
45   bool ShouldCreateWebContents(
46       WebContents* web_contents,
47       RenderFrameHost* opener,
48       SiteInstance* source_site_instance,
49       int32_t route_id,
50       int32_t main_frame_route_id,
51       int32_t main_frame_widget_route_id,
52       mojom::WindowContainerType window_container_type,
53       const GURL& opener_url,
54       const std::string& frame_name,
55       const GURL& target_url,
56       const std::string& partition_id,
57       SessionStorageNamespace* session_storage_namespace);
58   void CloseContents(WebContents* source) override;
59   void EnterFullscreenModeForTab(
60       RenderFrameHost* requesting_frame,
61       const blink::mojom::FullscreenOptions& options) override;
62   void ExitFullscreenModeForTab(WebContents* web_contents) override;
63   bool IsFullscreenForTabOrPending(const WebContents* web_contents) override;
64
65 #if defined(TIZEN_MULTIMEDIA_SUPPORT)
66   virtual bool CheckMediaAccessPermission(WebContents* web_contents,
67                                           const GURL& security_origin,
68                                           MediaStreamType type) override;
69
70   virtual void RequestMediaAccessPermission(
71       WebContents* web_contents,
72       const MediaStreamRequest& request,
73       MediaResponseCallback callback) override;
74
75   void RequestMediaAccessAllow(const MediaStreamRequest& request,
76                                MediaResponseCallback callback);
77
78   void RequestMediaAccessDeny(const MediaStreamRequest& request,
79                               MediaResponseCallback callback);
80 #endif
81   void RegisterProtocolHandler(WebContents* web_contents,
82                                const std::string& protocol,
83                                const GURL& url,
84                                bool user_gesture) override;
85   void UnregisterProtocolHandler(WebContents* web_contents,
86                                  const std::string& protocol,
87                                  const GURL& url,
88                                  bool user_gesture) override;
89   void FindReply(WebContents* web_contents,
90                  int request_id,
91                  int number_of_matches,
92                  const gfx::Rect& selection_rect,
93                  int active_match_ordinal,
94                  bool final_update) override;
95
96   void DidRenderFrame() override;
97
98   void RequestCertificateConfirm(
99       WebContents* web_contents,
100       int cert_error,
101       const net::SSLInfo& ssl_info,
102       const GURL& url,
103       bool overridable,
104       bool strict_enforcement,
105       base::Callback<void(CertificateRequestResultType)>& callback);
106
107   JavaScriptDialogManager* GetJavaScriptDialogManager(
108       WebContents* source) override;
109
110   void OnUpdateSettings(const Ewk_Settings* settings);
111   void SetContentSecurityPolicy(const std::string& policy,
112                                 Ewk_CSP_Header_Type header_type);
113
114   void DidFirstVisuallyNonEmptyPaint() override;
115   void DidStartLoading() override;
116
117   bool OnMessageReceived(const IPC::Message& message) override;
118   void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
119   void NavigationEntryCommitted(
120       const LoadCommittedDetails& load_details) override;
121   void RenderViewCreated(RenderViewHost* render_view_host) override;
122   void RenderProcessGone(base::TerminationStatus status) override;
123   bool DidAddMessageToConsole(WebContents* source,
124                               blink::mojom::ConsoleMessageLevel level,
125                               const base::string16& message,
126                               int32_t line_no,
127                               const base::string16& source_id) override;
128   void RunFileChooser(RenderFrameHost* render_frame_host,
129                       std::unique_ptr<FileSelectListener> listener,
130                       const blink::mojom::FileChooserParams& params) override;
131   ColorChooser* OpenColorChooser(
132       WebContents* web_contents,
133       SkColor color,
134       const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions)
135       override;
136 #if !defined(EWK_BRINGUP)  // FIXME: m76 bringup
137   void OpenDateTimeDialog(ui::TextInputType dialog_type,
138                           double dialog_value,
139                           double min,
140                           double max,
141                           double step,
142                           const std::vector<DateTimeSuggestion>& suggestions);
143 #endif
144   bool PreHandleGestureEvent(WebContents* source,
145                              const blink::WebGestureEvent& event) override;
146
147   // WebContentsObserver---------------------------------------------------
148   void DidFailLoad(RenderFrameHost* render_frame_host,
149                    const GURL& validated_url,
150                    int error_code) override;
151
152   // IPC::Sender-----------------------------------------------------------
153   bool Send(IPC::Message* message) override;
154
155   // EWK_BRINGUP: These APIs are removed in upstream.
156   void TitleWasSet(NavigationEntry* entry, bool explicit_set);
157
158   void LoadProgressChanged(WebContents* source, double progress);
159   void DidFinishLoad(RenderFrameHost* render_frame_host,
160                      const GURL& validated_url);
161
162   void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
163                                        const GURL& validated_url,
164                                        bool is_error_page,
165                                        bool is_iframe_srcdoc);
166
167   void DidUpdateFaviconURL(
168       RenderFrameHost* render_frame_host,
169       const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
170
171   void DidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
172                                         const GURL& url,
173                                         ui::PageTransition transition_type);
174
175   void DidNavigateMainFrame(const LoadCommittedDetails& details,
176                             const FrameNavigateParams& params);
177   void DocumentOnLoadCompletedInMainFrame();
178
179   void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
180                            const LoadCommittedDetails& details,
181                            const FrameNavigateParams& params);
182
183   void DidFailProvisionalLoad(RenderFrameHost* render_frame_host,
184                               const GURL& validated_url,
185                               int error_code,
186                               const base::string16& error_description,
187                               bool was_ignored_by_handler);
188   // EWK_BRINGUP end.
189
190   void OnAuthRequired(net::URLRequest* request,
191                       const std::string& realm,
192                       LoginDelegateEfl* login_delegate);
193
194   void DidDownloadFavicon(bool success,
195                           const GURL& icon_url,
196                           const SkBitmap& bitmap);
197
198   EWebView* web_view() const { return web_view_; }
199   WebContents& web_contents() const { return web_contents_; }
200
201  private:
202   void OnGetContentSecurityPolicy(IPC::Message* reply_msg);
203   void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
204   void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
205                               IPC::Message* reply);
206
207   EWebView* web_view_;
208   bool is_fullscreen_;
209   WebContents& web_contents_;
210
211   bool did_render_frame_;
212   bool did_first_visually_non_empty_paint_;
213
214   struct ContentSecurityPolicy {
215     ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
216         : policy(p), header_type(type) {}
217     std::string policy;
218     Ewk_CSP_Header_Type header_type;
219   };
220
221   std::unique_ptr<ContentSecurityPolicy> pending_content_security_policy_;
222   bool document_created_;
223   JavaScriptDialogManagerEfl* dialog_manager_;
224   std::unique_ptr<FaviconDownloader> favicon_downloader_;
225   base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;
226   std::unique_ptr<_Ewk_Certificate_Policy_Decision>
227       certificate_policy_decision_;
228
229   DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateEfl);
230 };
231 }
232
233 #endif