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_; }
61 virtual void OnCreatedNewWebView(WebView* view, WebView* new_view);
62 virtual void OnClosedWebView(WebView* view);
63 virtual void OnReceivedWrtMessage(WebView* view,
64 Ewk_IPC_Wrt_Message_Data* msg);
65 virtual void OnOrientationLock(
66 WebView* view, bool lock,
67 NativeWindow::ScreenOrientation preferred_rotation);
68 virtual void OnHardwareKey(WebView* view, const std::string& keyname);
69 virtual void OnConsoleMessage(const std::string& msg, int level);
70 virtual void OnLoadStart(WebView* view);
71 virtual void OnLoadFinished(WebView* view);
72 virtual void OnRendered(WebView* view);
73 virtual void OnLanguageChanged();
74 virtual void OnLowMemory();
75 virtual void OnTimeTick(long time);
76 virtual void OnAmbientTick(long time);
77 virtual void OnAmbientChanged(bool ambient_mode);
78 virtual bool OnContextMenuDisabled(WebView* view);
79 virtual bool OnDidNavigation(WebView* view, const std::string& url);
80 virtual void OnNotificationPermissionRequest(
81 WebView* view, const std::string& url,
82 std::function<void(bool)> result_handler);
83 virtual void OnGeolocationPermissionRequest(
84 WebView* view, const std::string& url,
85 std::function<void(bool)> result_handler);
86 virtual void OnQuotaExceed(WebView* view, const std::string& url,
87 std::function<void(bool)> result_handler);
88 virtual void OnAuthenticationRequest(
89 WebView* view, const std::string& url, const std::string& message,
90 std::function<void(bool submit, const std::string& id,
91 const std::string& password)> result_handler);
92 virtual void OnCertificateAllowRequest(
93 WebView* view, const std::string& url, const std::string& pem,
94 std::function<void(bool allow)> result_handler);
95 virtual void OnUsermediaPermissionRequest(
96 WebView* view, const std::string& url,
97 std::function<void(bool)> result_handler);
98 virtual void OnSoftKeyboardChangeEvent(
99 WebView* view, SoftKeyboardChangeEventValue softkeyboard_value);
100 #ifdef ROTARY_EVENT_FEATURE_SUPPORT
101 virtual void OnRotaryEvent(
102 WebView* view, RotaryEventType type);
103 #endif // ROTARY_EVENT_FEATURE_SUPPORT
104 #ifdef MANUAL_ROTATE_FEATURE_SUPPORT
105 virtual void OnRotatePrepared(WebView* view);
106 #endif // MANUAL_ROTATE_FEATURE_SUPPORT
111 void ClearViewStack();
112 void SendAppControlEvent();
113 void LaunchInspector(common::AppControl* appcontrol);
114 void SetupWebView(WebView* view);
115 void RemoveWebViewFromStack(WebView* view);
120 Ewk_Context* ewk_context_;
121 bool has_ownership_of_ewk_context_;
122 NativeWindow* window_;
124 std::string app_data_path_;
125 common::ApplicationData* app_data_;
126 std::list<WebView*> view_stack_;
127 std::unique_ptr<SplashScreen> splash_screen_;
128 std::unique_ptr<common::LocaleManager> locale_manager_;
129 std::unique_ptr<common::ResourceManager> resource_manager_;
130 std::function<void(void)> terminator_;
131 int security_model_version_;
132 std::string csp_rule_;
133 std::string csp_report_rule_;
136 } // namespace runtime
138 #endif // XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_