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_APPLICATION_H_
18 #define XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_
25 #include "runtime/browser/web_view.h"
31 class ApplicationData;
33 class ResourceManager;
40 class WebApplication : public WebView::EventListener {
42 WebApplication(NativeWindow* window,
43 common::ApplicationData* app_data);
44 WebApplication(NativeWindow* window,
45 common::ApplicationData* app_data,
46 Ewk_Context* context);
47 virtual ~WebApplication();
49 void AppControl(std::unique_ptr<common::AppControl> appcontrol);
50 void Launch(std::unique_ptr<common::AppControl> appcontrol);
57 void ProcessClosingPage();
59 std::string data_path() const { return app_data_path_; }
60 void set_terminator(std::function<void(void)> terminator) {
61 terminator_ = terminator;
63 bool launched() const { return launched_; }
64 std::list<WebView*> view_stack() const { return view_stack_; }
66 virtual void OnCreatedNewWebView(WebView* view, WebView* new_view);
67 virtual void OnClosedWebView(WebView* view);
68 virtual void OnReceivedWrtMessage(WebView* view,
69 Ewk_IPC_Wrt_Message_Data* msg);
70 virtual void OnOrientationLock(
71 WebView* view, bool lock,
72 NativeWindow::ScreenOrientation preferred_rotation);
73 virtual void OnHardwareKey(WebView* view, const std::string& keyname);
74 virtual void OnConsoleMessage(const std::string& msg, int level);
75 virtual void OnLoadStart(WebView* view);
76 virtual void OnLoadFinished(WebView* view);
77 virtual void OnRendered(WebView* view);
78 virtual void OnLanguageChanged();
79 virtual void OnLowMemory();
80 virtual void OnTimeTick(long time);
81 virtual void OnAmbientTick(long time);
82 virtual void OnAmbientChanged(bool ambient_mode);
83 virtual bool OnContextMenuDisabled(WebView* view);
84 virtual bool OnDidNavigation(WebView* view, const std::string& url);
85 virtual void OnNotificationPermissionRequest(
86 WebView* view, const std::string& url,
87 std::function<void(bool)> result_handler);
88 virtual void OnGeolocationPermissionRequest(
89 WebView* view, const std::string& url,
90 std::function<void(bool)> result_handler);
91 virtual void OnQuotaExceed(WebView* view, const std::string& url,
92 std::function<void(bool)> result_handler);
93 virtual void OnAuthenticationRequest(
94 WebView* view, const std::string& url, const std::string& message,
95 std::function<void(bool submit, const std::string& id,
96 const std::string& password)> result_handler);
97 virtual void OnCertificateAllowRequest(
98 WebView* view, const std::string& url, const std::string& pem,
99 std::function<void(bool allow)> result_handler);
100 virtual void OnUsermediaPermissionRequest(
101 WebView* view, const std::string& url,
102 std::function<void(bool)> result_handler);
103 virtual void OnSoftKeyboardChangeEvent(
104 WebView* view, SoftKeyboardChangeEventValue softkeyboard_value);
105 #ifdef ROTARY_EVENT_FEATURE_SUPPORT
106 virtual void OnRotaryEvent(
107 WebView* view, RotaryEventType type);
108 #endif // ROTARY_EVENT_FEATURE_SUPPORT
109 #ifdef MANUAL_ROTATE_FEATURE_SUPPORT
110 virtual void OnRotatePrepared(WebView* view);
111 #endif // MANUAL_ROTATE_FEATURE_SUPPORT
112 static Eina_Bool CheckPluginSession(void* user_data);
113 static Eina_Bool ClosePageInExtendedMainLoop(void* user_data);
116 WebApplication* application;
118 } main_loop, session_counter;
123 void ClearViewStack();
124 void SendAppControlEvent();
125 void LaunchInspector(common::AppControl* appcontrol);
126 void SetupWebView(WebView* view);
127 void SetupWebViewCompatibilitySettings(WebView* view);
128 void RemoveWebViewFromStack(WebView* view);
130 void SetupTizenVersion();
131 bool tizenWebKitCompatibilityEnabled() const;
136 bool tizenWebKitCompatibilityEnabled() const { return (m_major && m_major < 3); }
137 } m_tizenCompatibilitySettings;
142 bool lang_changed_mode_;
143 bool is_terminate_called_;
144 bool is_close_page_called_;
145 Ewk_Context* ewk_context_;
146 bool has_ownership_of_ewk_context_;
147 NativeWindow* window_;
149 std::string app_data_path_;
150 common::ApplicationData* app_data_;
151 std::list<WebView*> view_stack_;
152 std::unique_ptr<SplashScreen> splash_screen_;
153 std::unique_ptr<common::LocaleManager> locale_manager_;
154 std::unique_ptr<common::ResourceManager> resource_manager_;
155 std::function<void(void)> terminator_;
156 int security_model_version_;
157 std::string csp_rule_;
158 std::string csp_report_rule_;
161 } // namespace runtime
163 #endif // XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_