7245364226c0aa7b3c5342d954573e5620c3d7bc
[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_H_
6 #define WEB_CONTENTS_DELEGATE_EFL_H_
7
8 #include "content/public/browser/web_contents_delegate.h"
9 #include "eweb_view.h"
10 #include "private/ewk_manifest_private.h"
11 #include "public/ewk_view_internal.h"
12 #include "third_party/blink/public/mojom/manifest/manifest.mojom.h"
13 #include "ui/base/ime/text_input_type.h"
14
15 class JavaScriptDialogManagerEfl;
16
17 namespace content {
18
19 class WebContentsObserverEfl;
20
21 class WebContentsDelegateEfl : public WebContentsDelegate {
22  public:
23   WebContentsDelegateEfl(EWebView*);
24   ~WebContentsDelegateEfl();
25
26   WebContentsDelegateEfl(const WebContentsDelegateEfl&) = delete;
27   WebContentsDelegateEfl& operator=(const WebContentsDelegateEfl&) = delete;
28
29   // WebContentsDelegate overrides.
30   WebContents* OpenURLFromTab(WebContents* source,
31                               const OpenURLParams& params) override;
32   void NavigationStateChanged(WebContents* source,
33                               InvalidateTypes changed_flags) override;
34
35   void AddNewContents(WebContents* source,
36                       std::unique_ptr<WebContents> new_contents,
37                       const GURL& target_url,
38                       WindowOpenDisposition disposition,
39                       const blink::mojom::WindowFeatures& window_features,
40                       bool user_gesture,
41                       bool* was_blocked) override;
42   bool ShouldCreateWebContents(
43       WebContents* web_contents,
44       RenderFrameHost* opener,
45       SiteInstance* source_site_instance,
46       mojom::WindowContainerType window_container_type,
47       const GURL& opener_url,
48       const std::string& frame_name,
49       const GURL& target_url,
50       const std::string& partition_id,
51       SessionStorageNamespace* session_storage_namespace);
52
53   void CloseContents(WebContents* source) override;
54   void EnterFullscreenModeForTab(
55       RenderFrameHost* requesting_frame,
56       const blink::mojom::FullscreenOptions& options) override;
57   void ExitFullscreenModeForTab(WebContents* web_contents) override;
58   bool IsFullscreenForTabOrPending(const WebContents* web_contents) override;
59
60   void FindReply(WebContents* web_contents,
61                  int request_id,
62                  int number_of_matches,
63                  const gfx::Rect& selection_rect,
64                  int active_match_ordinal,
65                  bool final_update) override;
66   void DidRenderFrame() override;
67   void DidChangeInputType(bool is_password_input) override;
68
69   void OnGetMainFrameScrollbarVisible(int callback_id, bool visible) override;
70   void RequestCertificateConfirm(
71       WebContents* web_contents,
72       int cert_error,
73       const net::SSLInfo& ssl_info,
74       const GURL& url,
75       bool is_main_frame_request,
76       bool strict_enforcement,
77       base::OnceCallback<void(CertificateRequestResultType)> callback);
78
79   JavaScriptDialogManager* GetJavaScriptDialogManager(
80       WebContents* source) override;
81   void ActivateContents(WebContents* contents) override;
82   void OnUpdateSettings(const Ewk_Settings* settings);
83   void SetContentSecurityPolicy(const std::string& policy,
84                                 Ewk_CSP_Header_Type header_type);
85
86   void BackgroundColorReceived(int callback_id, SkColor bg_color) override;
87
88   void DidFirstVisuallyNonEmptyPaint();
89   void DidStartLoading();
90
91   bool DidAddMessageToConsole(WebContents* source,
92                               blink::mojom::ConsoleMessageLevel level,
93                               const std::u16string& message,
94                               int32_t line_no,
95                               const std::u16string& source_id) override;
96   void RunFileChooser(RenderFrameHost* render_frame_host,
97                       scoped_refptr<FileSelectListener> listener,
98                       const blink::mojom::FileChooserParams& params) override;
99   std::unique_ptr<ColorChooser> OpenColorChooser(
100       WebContents* web_contents,
101       SkColor color,
102       const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions);
103 #if !defined(EWK_BRINGUP)  // FIXME: m76 bringup
104   void OpenDateTimeDialog(ui::TextInputType dialog_type,
105                           double dialog_value,
106                           double min,
107                           double max,
108                           double step,
109                           const std::vector<DateTimeSuggestion>& suggestions);
110 #endif
111   bool PreHandleGestureEvent(WebContents* source,
112                              const blink::WebGestureEvent& event) override;
113   void VisibleSecurityStateChanged(WebContents* source) override;
114   EWebView* web_view() const { return web_view_; }
115   WebContents& web_contents() const { return web_contents_; }
116
117   void RequestManifestInfo(Ewk_View_Request_Manifest_Callback callback,
118                            void* user_data);
119   void OnAuthRequired(const std::string& realm,
120                       const GURL& url,
121                       LoginDelegateEfl* login_delegate);
122
123 #if defined(TIZEN_MULTIMEDIA)
124   bool CheckMediaAccessPermission(RenderFrameHost* render_frame_host,
125                                   const GURL& security_origin,
126                                   blink::mojom::MediaStreamType type) override;
127
128   void RequestMediaAccessPermission(WebContents* web_contents,
129                                     const MediaStreamRequest& request,
130                                     MediaResponseCallback callback) override;
131
132   void RequestMediaAccessAllow(const MediaStreamRequest& request,
133                                MediaResponseCallback callback);
134
135   void RequestMediaAccessDeny(const MediaStreamRequest& request,
136                               MediaResponseCallback callback);
137 #endif
138
139 #if BUILDFLAG(IS_TIZEN_TV)
140   void UpdateTargetURL(WebContents* source, const GURL& url) override;
141 #endif
142
143 #if defined(TIZEN_AUTOFILL)
144   void UpdateAutofillIfRequired();
145 #endif
146
147 #if defined(TIZEN_AUTOFILL_FW)
148   void ResetLastInteractedElements();
149 #endif
150
151  private:
152   void OnDidGetManifest(Ewk_View_Request_Manifest_Callback callback,
153                         void* user_data,
154                         const GURL& manifest_url,
155                         blink::mojom::ManifestPtr manifest);
156   void OnDidChangeFocusedNodeBounds(const gfx::RectF& focused_node_bounds);
157   EWebView* web_view_;
158   bool is_fullscreen_;
159   WebContents& web_contents_;
160 #if BUILDFLAG(IS_TIZEN_TV)
161   std::string last_hovered_url_;
162 #endif
163
164   bool did_render_frame_ = false;
165   bool did_first_visually_non_empty_paint_ = false;
166
167   std::unique_ptr<WebContentsObserverEfl> contents_observer_;
168   void* ime_window_ = nullptr;
169   GURL last_visible_url_;
170
171   JavaScriptDialogManagerEfl* dialog_manager_ = nullptr;
172   int rotation_ = -1;
173   std::unique_ptr<_Ewk_Certificate_Policy_Decision>
174       certificate_policy_decision_;
175 };
176 }
177
178 #endif  // WEB_CONTENTS_DELEGATE_EFL_H_