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