2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef XWALK_RUNTIME_BROWSER_WEB_VIEW_H_
18 #define XWALK_RUNTIME_BROWSER_WEB_VIEW_H_
20 #include <Elementary.h>
22 #include <EWebKit_internal.h>
26 #include "runtime/browser/native_window.h"
33 enum class RotaryEventType {
34 CLOCKWISE, // Rotary is rotated clockwise direction
35 COUNTER_CLOCKWISE // Rotary is rotated counter clockwise direction
38 class SoftKeyboardChangeEventValue {
49 virtual void OnLoadStart(WebView* /*view*/) {}
50 virtual void OnLoadProgress(WebView* /*view*/, double /*persent*/ ) {}
51 virtual void OnLoadFinished(WebView* /*view*/) {}
52 virtual void OnRendered(WebView* /*view*/) {}
53 virtual void OnCreatedNewWebView(WebView* /*view*/,
54 WebView* /*new_view*/) {}
55 virtual void OnClosedWebView(WebView* /*view*/) {}
56 virtual void OnCrashed(WebView* /*view*/) {}
57 virtual bool OnDidOpenWindow(
58 WebView* /*view*/, const std::string& /*url*/) { return true; }
59 virtual bool OnDidNavigation(
60 WebView* /*view*/, const std::string& /*url*/) { return true; }
61 virtual void OnHardwareKey(
62 WebView* /*view*/, const std::string& /*keyname*/) {}
63 virtual void OnReceivedWrtMessage(
64 WebView* /*view*/, Ewk_IPC_Wrt_Message_Data* /*msg*/) {}
65 virtual void OnOrientationLock(
68 NativeWindow::ScreenOrientation /*preferred_rotation*/) {}
69 virtual void OnConsoleMessage(const std::string& /*msg*/, int /*level*/) {}
70 virtual bool OnContextMenuDisabled(WebView* /*view*/) { return false; }
72 virtual void OnNotificationPermissionRequest(
74 const std::string& /*url*/,
75 std::function<void(bool)> /*result_handler*/) {}
76 virtual void OnGeolocationPermissionRequest(
78 const std::string& /*url*/,
79 std::function<void(bool)> /*result_handler*/) {}
80 virtual void OnQuotaExceed(
82 const std::string& /*url*/,
83 std::function<void(bool)> /*result_handler*/) {}
84 virtual void OnAuthenticationRequest(
86 const std::string& /*url*/,
87 const std::string& /*message*/,
88 std::function<void(bool /*submit*/,
89 const std::string& /*id*/,
90 const std::string& /*password*/)
91 > /*result_handler*/) {}
92 virtual void OnCertificateAllowRequest(
94 const std::string& /*url*/,
95 const std::string& /*pem*/,
96 std::function<void(bool allow)> result_handler) {
97 result_handler(false);
99 virtual void OnUsermediaPermissionRequest(
101 const std::string& /*url*/,
102 std::function<void(bool)> /*result_handler*/) {}
103 virtual void OnSoftKeyboardChangeEvent(
105 SoftKeyboardChangeEventValue /*softkeyboard_value*/) {}
106 #ifdef ROTARY_EVENT_FEATURE_SUPPORT
107 virtual void OnRotaryEvent(
109 RotaryEventType /*type*/) {}
110 #endif // ROTARY_EVENT_FEATURE_SUPPORT
111 #ifdef MANUAL_ROTATE_FEATURE_SUPPORT
112 virtual void OnRotatePrepared(WebView* /*view*/) {}
113 #endif // MANUAL_ROTATE_FEATURE_SUPPORT
116 WebView(NativeWindow* window, Ewk_Context* context);
119 void LoadUrl(const std::string& url, const std::string& mime = std::string());
120 std::string GetUrl();
126 void SetVisibility(bool show);
127 bool EvalJavascript(const std::string& script);
128 void SetAppInfo(const std::string& app_name, const std::string& version);
129 bool SetUserAgent(const std::string& user_agent);
130 void SetCSPRule(const std::string& rule, bool report_only);
131 void SetDefaultEncoding(const std::string& encoding);
132 #ifdef PROFILE_WEARABLE
133 void SetBGColor(int r, int g, int b, int a);
136 void SetEventListener(EventListener* listener);
137 Evas_Object* evas_object() const;
143 } // namespace runtime
145 #endif // XWALK_RUNTIME_BROWSER_WEB_VIEW_H_