1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Copyright 2014 Samsung Electronics. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #ifndef TIZEN_WEBVIEW_PUBLIC_TW_WEBVIEW_DELEGATE_H_
7 #define TIZEN_WEBVIEW_PUBLIC_TW_WEBVIEW_DELEGATE_H_
10 #include <eina_rectangle.h>
14 namespace tizen_webview {
18 class WebViewDelegate {
20 // Register the default delegate.
21 // Client of WebView should register one before creating a WebView first time.
22 // Client has the ownership for |wv_delegate| and should ensure its validity
23 // while using WebView.
24 // Currently, it is not allowed to re-register another delegate,
25 // and if try to do it it is simply ignored.
26 static void RegisterDelegate(WebViewDelegate* wv_delegate);
28 // Check if a default delegate is registered or not
29 static bool IsDelegateRegistered();
31 // Get the default delegate registered in RegisterDefaultDelegate()
32 static WebViewDelegate* GetInstance();
34 // Retrieve WebView from |evas_object|.
35 // If |evas_object| is not WebView, return NULL.
36 virtual WebView* GetWebViewFromEvasObject(Evas_Object* evas_object) = 0;
38 // Check if |evas_object| is WebView or not.
39 virtual bool IsWebViewEvasObject(Evas_Object* evas_object) = 0;
41 // Get clipped data from WebView evas object which is a clipped smart object.
42 virtual Evas_Object_Smart_Clipped_Data* GetSmartClippedData(
43 Evas_Object* evas_object) = 0;
45 // Get lastly used view port area.
46 // If |evas_object| is not a WebView, return Enia_Rectangle with width -1.
47 virtual Eina_Rectangle GetLastUsedViewPortArea(Evas_Object* evas_object) = 0;
49 // ---- Custom Event handlers
50 // Give opportunity for client to process event.
51 // [Note] return true if handled, false otherwise.
52 virtual bool RequestHandleEvent_FocusIn(EWebView* wv) { return false; }
53 virtual bool RequestHandleEvent_FocusOut(EWebView* wv) { return false; }
54 virtual bool RequestHandleEvent_MouseUp(
55 EWebView* wv, const Evas_Event_Mouse_Up* event_info) { return false; }
56 virtual bool RequestHandleEvent_MouseDown(
57 EWebView* wv, const Evas_Event_Mouse_Down* event_info) { return false; }
58 virtual bool RequestHandleEvent_MouseMove(
59 EWebView* wv, const Evas_Event_Mouse_Move* event_info) { return false; }
60 virtual bool RequestHandleEvent_MouseWheel(
61 EWebView* wv, const Evas_Event_Mouse_Wheel* event_info) { return false; }
62 virtual bool RequestHandleEvent_KeyUp(
63 EWebView* wv, const Evas_Event_Key_Up* event_info) { return false; }
64 virtual bool RequestHandleEvent_KeyDown(
65 EWebView* wv, const Evas_Event_Key_Down* event_info) { return false; }
68 } // namespace tizen_webview
70 #endif // TIZEN_WEBVIEW_PUBLIC_TW_WEBVIEW_DELEGATE_H_