Internalization for user_media
[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 RequestMediaAccessAllow(const MediaStreamRequest& request,
78     const MediaResponseCallback& callback);
79
80   void RequestMediaAccessDeny(const MediaStreamRequest& request,
81     const MediaResponseCallback& callback);
82 #endif
83   void RegisterProtocolHandler(WebContents* web_contents,
84                                const std::string& protocol,
85                                const GURL& url,
86                                bool user_gesture) override;
87
88   void FindReply(WebContents* web_contents,
89                  int request_id,
90                  int number_of_matches,
91                  const gfx::Rect& selection_rect,
92                  int active_match_ordinal,
93                  bool final_update) override;
94
95   void RequestCertificateConfirm(WebContents* web_contents, int cert_error,
96       const net::SSLInfo& ssl_info, const GURL& url, ResourceType resource_type,
97       bool overridable,
98       bool strict_enforcement,
99       const base::Callback<void(bool)>& callback,
100       CertificateRequestResultType* result);
101
102   EWebView* web_view() const { return web_view_; }
103   WebContents& web_contents() const { return web_contents_; }
104
105   virtual void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
106                                                const GURL& validated_url,
107                                                bool is_error_page,
108                                                bool is_iframe_srcdoc) override;
109
110   virtual void DidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
111                                                 const GURL& url,
112                                                 ui::PageTransition transition_type) override;
113
114   virtual void DidNavigateMainFrame(const LoadCommittedDetails& details,
115                                     const FrameNavigateParams& params) override;
116   virtual void DocumentOnLoadCompletedInMainFrame() override;
117
118   virtual void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
119                                    const LoadCommittedDetails& details,
120                                    const FrameNavigateParams& params) override;
121
122   void OnAuthRequired(net::URLRequest* request,
123                       const std::string& realm,
124                       LoginDelegateEfl* login_delegate);
125
126   virtual void DidFinishLoad(RenderFrameHost* render_frame_host,
127                              const GURL& validated_url) override;
128
129   virtual void DidUpdateFaviconURL(const std::vector<FaviconURL>& candidates) override;
130   virtual void DidDownloadFavicon(bool success, const GURL& icon_url, const SkBitmap& bitmap);
131
132   void OnUpdateSettings(const Ewk_Settings *settings);
133   void SetContentSecurityPolicy(const std::string& policy, Ewk_CSP_Header_Type header_type);
134
135   JavaScriptDialogManager* GetJavaScriptDialogManager(WebContents* source) override;
136
137   void DidFirstVisuallyNonEmptyPaint() override;
138
139   bool OnMessageReceived(const IPC::Message& message) override;
140   void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
141   void NavigationEntryCommitted(const LoadCommittedDetails& load_details) override;
142   void RenderViewCreated(RenderViewHost* render_view_host) override;
143   void RenderProcessGone(base::TerminationStatus status) override;
144   bool AddMessageToConsole(WebContents* source,
145                            int32 level,
146                            const base::string16& message,
147                            int32 line_no,
148                            const base::string16& source_id) override;
149   void RunFileChooser(WebContents* web_contents,
150                       const FileChooserParams& params) override;
151   ColorChooser* OpenColorChooser(WebContents* web_contents, SkColor color,
152       const std::vector<ColorSuggestion>& suggestions) override;
153   void OpenDateTimeDialog(ui::TextInputType dialog_type,
154       double dialog_value,
155       double min,
156       double max,
157       double step,
158       const std::vector<DateTimeSuggestion>& suggestions) override;
159   bool PreHandleGestureEvent(WebContents* source,
160                              const blink::WebGestureEvent& event) override;
161
162  private:
163   void OnGetContentSecurityPolicy(IPC::Message* reply_msg);
164   void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
165   void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
166                               IPC::Message* reply);
167
168   EWebView* web_view_;
169   bool is_fullscreen_;
170   WebContents& web_contents_;
171
172   struct ContentSecurityPolicy {
173     ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
174         : policy(p),
175           header_type(type) {
176     }
177     std::string policy;
178     Ewk_CSP_Header_Type header_type;
179   };
180
181   scoped_ptr<ContentSecurityPolicy> pending_content_security_policy_;
182   bool document_created_;
183   JavaScriptDialogManagerEfl* dialog_manager_;
184   scoped_ptr<FaviconDownloader> favicon_downloader_;
185   base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;
186   scoped_ptr<_Ewk_Certificate_Policy_Decision> certificate_policy_decision_;
187
188   DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateEfl);
189 };
190
191 }
192
193 #endif