Add ewk_settings_tizen_compatibility_mode_set API
[platform/framework/web/crosswalk-tizen.git] / runtime / browser / web_application.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_
18 #define XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_
19
20 #include <functional>
21 #include <list>
22 #include <memory>
23 #include <string>
24
25 #include "runtime/browser/web_view.h"
26
27 class Ewk_Context;
28
29 namespace common {
30 class AppControl;
31 class ApplicationData;
32 class LocaleManager;
33 class ResourceManager;
34 }  // namespace common
35
36 namespace runtime {
37 class NativeWindow;
38 class SplashScreen;
39
40 class WebApplication : public WebView::EventListener {
41  public:
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();
48
49   void AppControl(std::unique_ptr<common::AppControl> appcontrol);
50   void Launch(std::unique_ptr<common::AppControl> appcontrol);
51   void Resume();
52   void Suspend();
53   void Terminate();
54
55   std::string data_path() const { return app_data_path_; }
56   void set_terminator(std::function<void(void)> terminator) {
57     terminator_ = terminator;
58   }
59   bool launched() const { return launched_; }
60
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
107
108  private:
109   bool Initialize();
110
111   void ClearViewStack();
112   void SendAppControlEvent();
113   void LaunchInspector(common::AppControl* appcontrol);
114   void SetupWebView(WebView* view);
115   void SetupWebViewTizenApplicationInfo(WebView* view);
116   void RemoveWebViewFromStack(WebView* view);
117
118   bool launched_;
119   bool debug_mode_;
120   bool verbose_mode_;
121   bool lang_changed_mode_;
122   Ewk_Context* ewk_context_;
123   bool has_ownership_of_ewk_context_;
124   NativeWindow* window_;
125   std::string appid_;
126   std::string app_data_path_;
127   common::ApplicationData* app_data_;
128   std::list<WebView*> view_stack_;
129   std::unique_ptr<SplashScreen> splash_screen_;
130   std::unique_ptr<common::LocaleManager> locale_manager_;
131   std::unique_ptr<common::ResourceManager> resource_manager_;
132   std::function<void(void)> terminator_;
133   int security_model_version_;
134   std::string csp_rule_;
135   std::string csp_report_rule_;
136 };
137
138 }  // namespace runtime
139
140 #endif  // XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_