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);
55 std::string data_path() const { return app_data_path_; }
56 void set_terminator(std::function<void(void)> terminator) {
57 terminator_ = terminator;
59 bool launched() const { return launched_; }
60 std::list<WebView*> view_stack() const { return view_stack_; }
62 virtual void OnCreatedNewWebView(WebView* view, WebView* new_view);
63 virtual void OnClosedWebView(WebView* view);
64 virtual void OnReceivedWrtMessage(WebView* view,
65 Ewk_IPC_Wrt_Message_Data* msg);
66 virtual void OnOrientationLock(
67 WebView* view, bool lock,
68 NativeWindow::ScreenOrientation preferred_rotation);
69 virtual void OnHardwareKey(WebView* view, const std::string& keyname);
70 virtual void OnConsoleMessage(const std::string& msg, int level);
71 virtual void OnLoadStart(WebView* view);
72 virtual void OnLoadFinished(WebView* view);
73 virtual void OnRendered(WebView* view);
74 virtual void OnLanguageChanged();
75 virtual void OnLowMemory();
76 virtual void OnTimeTick(long time);
77 virtual void OnAmbientTick(long time);
78 virtual void OnAmbientChanged(bool ambient_mode);
79 virtual bool OnContextMenuDisabled(WebView* view);
80 virtual bool OnDidNavigation(WebView* view, const std::string& url);
81 virtual void OnNotificationPermissionRequest(
82 WebView* view, const std::string& url,
83 std::function<void(bool)> result_handler);
84 virtual void OnGeolocationPermissionRequest(
85 WebView* view, const std::string& url,
86 std::function<void(bool)> result_handler);
87 virtual void OnQuotaExceed(WebView* view, const std::string& url,
88 std::function<void(bool)> result_handler);
89 virtual void OnAuthenticationRequest(
90 WebView* view, const std::string& url, const std::string& message,
91 std::function<void(bool submit, const std::string& id,
92 const std::string& password)> result_handler);
93 virtual void OnCertificateAllowRequest(
94 WebView* view, const std::string& url, const std::string& pem,
95 std::function<void(bool allow)> result_handler);
96 virtual void OnUsermediaPermissionRequest(
97 WebView* view, const std::string& url,
98 std::function<void(bool)> result_handler);
99 virtual void OnSoftKeyboardChangeEvent(
100 WebView* view, SoftKeyboardChangeEventValue softkeyboard_value);
101 #ifdef ROTARY_EVENT_FEATURE_SUPPORT
102 virtual void OnRotaryEvent(
103 WebView* view, RotaryEventType type);
104 #endif // ROTARY_EVENT_FEATURE_SUPPORT
105 #ifdef MANUAL_ROTATE_FEATURE_SUPPORT
106 virtual void OnRotatePrepared(WebView* view);
107 #endif // MANUAL_ROTATE_FEATURE_SUPPORT
112 void ClearViewStack();
113 void SendAppControlEvent();
114 void LaunchInspector(common::AppControl* appcontrol);
115 void SetupWebView(WebView* view);
116 void SetupWebViewTizenApplicationInfo(WebView* view);
117 void RemoveWebViewFromStack(WebView* view);
119 void SetupTizenVersion();
120 bool tizenWebKitCompatibilityEnabled() const;
125 bool tizenWebKitCompatibilityEnabled() const { return (m_major && m_major < 3); }
126 } m_tizenCompatibilitySettings;
131 bool lang_changed_mode_;
132 Ewk_Context* ewk_context_;
133 bool has_ownership_of_ewk_context_;
134 bool is_terminated_by_callback_;
135 NativeWindow* window_;
137 std::string app_data_path_;
138 common::ApplicationData* app_data_;
139 std::list<WebView*> view_stack_;
140 std::unique_ptr<SplashScreen> splash_screen_;
141 std::unique_ptr<common::LocaleManager> locale_manager_;
142 std::unique_ptr<common::ResourceManager> resource_manager_;
143 std::function<void(void)> terminator_;
144 int security_model_version_;
145 std::string csp_rule_;
146 std::string csp_report_rule_;
149 } // namespace runtime
151 #endif // XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_