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 std::unique_ptr<common::ApplicationData> app_data);
44 virtual ~WebApplication();
46 void AppControl(std::unique_ptr<common::AppControl> appcontrol);
47 void Launch(std::unique_ptr<common::AppControl> appcontrol);
52 std::string data_path() const { return app_data_path_; }
53 void set_terminator(std::function<void(void)> terminator) {
54 terminator_ = terminator;
56 bool launched() const { return launched_; }
58 virtual void OnCreatedNewWebView(WebView* view, WebView* new_view);
59 virtual void OnClosedWebView(WebView* view);
60 virtual void OnReceivedWrtMessage(WebView* view,
61 Ewk_IPC_Wrt_Message_Data* msg);
62 virtual void OnOrientationLock(
63 WebView* view, bool lock,
64 NativeWindow::ScreenOrientation preferred_rotation);
65 virtual void OnHardwareKey(WebView* view, const std::string& keyname);
66 virtual void OnConsoleMessage(const std::string& msg, int level);
67 virtual void OnLoadStart(WebView* view);
68 virtual void OnLoadFinished(WebView* view);
69 virtual void OnRendered(WebView* view);
70 virtual void OnLanguageChanged();
71 virtual void OnLowMemory();
72 virtual bool OnContextMenuDisabled(WebView* view);
73 virtual bool OnDidNavigation(WebView* view, const std::string& url);
74 virtual void OnNotificationPermissionRequest(
75 WebView* view, const std::string& url,
76 std::function<void(bool)> result_handler);
77 virtual void OnGeolocationPermissionRequest(
78 WebView* view, const std::string& url,
79 std::function<void(bool)> result_handler);
80 virtual void OnQuotaExceed(WebView* view, const std::string& url,
81 std::function<void(bool)> result_handler);
82 virtual void OnAuthenticationRequest(
83 WebView* view, const std::string& url, const std::string& message,
84 std::function<void(bool submit, const std::string& id,
85 const std::string& password)> result_handler);
86 virtual void OnCertificateAllowRequest(
87 WebView* view, const std::string& url, const std::string& pem,
88 std::function<void(bool allow)> result_handler);
89 virtual void OnUsermediaPermissionRequest(
90 WebView* view, const std::string& url,
91 std::function<void(bool)> result_handler);
92 virtual void OnSoftKeyboardChangeEvent(
93 WebView* view, SoftKeyboardChangeEventValue softkeyboard_value);
94 #ifdef PROFILE_WEARABLE
95 virtual void OnRotaryEvent(
96 WebView* view, RotaryEventType type);
97 #endif // PROFILE_WEARABLE
102 void ClearViewStack();
103 void SendAppControlEvent();
104 void LaunchInspector(common::AppControl* appcontrol);
105 void SetupWebView(WebView* view);
110 Ewk_Context* ewk_context_;
111 NativeWindow* window_;
113 std::string app_data_path_;
114 std::list<WebView*> view_stack_;
115 std::unique_ptr<SplashScreen> splash_screen_;
116 std::unique_ptr<common::LocaleManager> locale_manager_;
117 std::unique_ptr<common::ApplicationData> app_data_;
118 std::unique_ptr<common::ResourceManager> resource_manager_;
119 std::function<void(void)> terminator_;
120 int security_model_version_;
121 std::string csp_rule_;
122 std::string csp_report_rule_;
125 } // namespace runtime
127 #endif // XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_