Fix invalid licenses
[platform/framework/web/crosswalk-tizen.git] / src / runtime / web_view.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16
17
18 #ifndef WRT_RUNTIME_WEB_VIEW_H_
19 #define WRT_RUNTIME_WEB_VIEW_H_
20
21 #include <Elementary.h>
22 #include <ewk_ipc_message.h>
23 #include <string>
24 #include <functional>
25
26 class Ewk_Context;
27
28 namespace wrt {
29 class NativeWindow;
30 class WebViewImpl;
31
32 class WebView {
33  public:
34   class EventListener {
35    public:
36     virtual void OnLoadStart(WebView* /*view*/) {}
37     virtual void OnLoadProgress(WebView* /*view*/, double /*persent*/ ) {}
38     virtual void OnLoadFinished(WebView* /*view*/) {}
39     virtual void OnRendered(WebView* /*view*/) {}
40     virtual void OnCreatedNewWebView(WebView* /*view*/,
41                                      WebView* /*new_view*/) {}
42     virtual void OnClosedWebView(WebView* /*view*/) {}
43     virtual void OnCrashed(WebView* /*view*/) {}
44     virtual bool OnDidOpenWindow(
45         WebView* /*view*/, const std::string& /*url*/) { return true; }
46     virtual bool OnDidNavigation(
47         WebView* /*view*/, const std::string& /*url*/) { return true; }
48     virtual void OnHardwareKey(
49         WebView* /*view*/, const std::string& /*keyname*/) {}
50     virtual void OnReceivedWrtMessage(
51         WebView* /*view*/, Ewk_IPC_Wrt_Message_Data* /*msg*/) {}
52     virtual void OnOrientationLock(
53         WebView* /*view*/,
54         bool /*lock*/,
55         int /*preferred_rotation*/) {}
56     virtual void OnConsoleMessage(const std::string& /*msg*/, int /*level*/) {}
57     virtual bool OnContextMenuDisabled(WebView* /*view*/) { return false; }
58
59     virtual void OnNotificationPermissionRequest(
60         WebView* /*view*/,
61         const std::string& /*url*/,
62         std::function<void(bool)> /*result_handler*/) {}
63     virtual void OnGeolocationPermissionRequest(
64         WebView* /*view*/,
65         const std::string& /*url*/,
66         std::function<void(bool)> /*result_handler*/) {}
67     virtual void OnQuotaExceed(
68         WebView* /*view*/,
69         const std::string& /*url*/,
70         std::function<void(bool)> /*result_handler*/) {}
71     virtual void OnAuthenticationRequest(
72         WebView* /*view*/,
73         const std::string& /*url*/,
74         const std::string& /*message*/,
75         std::function<void(bool /*submit*/,
76                            const std::string& /*id*/,
77                            const std::string& /*password*/)
78                      > /*result_handler*/) {}
79     virtual void OnCertificateAllowRequest(
80         WebView* /*view*/,
81         const std::string& /*url*/,
82         const std::string& /*pem*/,
83         std::function<void(bool allow)> result_handler) {
84       result_handler(false);
85     }
86   };
87
88   WebView(wrt::NativeWindow* window, Ewk_Context* context);
89   virtual ~WebView();
90
91   void LoadUrl(const std::string& url);
92   std::string GetUrl();
93
94   void Suspend();
95   void Resume();
96   void Reload();
97   void SetVisibility(bool show);
98   bool EvalJavascript(const std::string& script);
99   void SetAppInfo(const std::string& app_name, const std::string& version);
100   bool SetUserAgent(const std::string& user_agent);
101
102   void SetEventListener(EventListener* listener);
103   Evas_Object* evas_object() const;
104
105  private:
106   WebViewImpl* impl_;
107 };
108
109 }  // namespace wrt
110
111 #endif  // WRT_RUNTIME_WEB_VIEW_H_