add console message verbose mode with 'verbose' key
[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                  std::unique_ptr<common::ApplicationData> app_data);
44   virtual ~WebApplication();
45
46   void AppControl(std::unique_ptr<common::AppControl> appcontrol);
47   void Launch(std::unique_ptr<common::AppControl> appcontrol);
48   void Resume();
49   void Suspend();
50   void Terminate();
51
52   std::string data_path() const { return app_data_path_; }
53   void set_terminator(std::function<void(void)> terminator) {
54     terminator_ = terminator;
55   }
56   bool launched() const { return launched_; }
57
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
93  private:
94   bool Initialize();
95
96   void ClearViewStack();
97   void SendAppControlEvent();
98   void LaunchInspector(common::AppControl* appcontrol);
99   void SetupWebView(WebView* view);
100
101   bool launched_;
102   bool debug_mode_;
103   bool verbose_mode_;
104   Ewk_Context* ewk_context_;
105   NativeWindow* window_;
106   std::string appid_;
107   std::string app_data_path_;
108   std::list<WebView*> view_stack_;
109   std::unique_ptr<SplashScreen> splash_screen_;
110   std::unique_ptr<common::LocaleManager> locale_manager_;
111   std::unique_ptr<common::ApplicationData> app_data_;
112   std::unique_ptr<common::ResourceManager> resource_manager_;
113   std::function<void(void)> terminator_;
114   int security_model_version_;
115   std::string csp_rule_;
116   std::string csp_report_rule_;
117 };
118
119 }  // namespace runtime
120
121 #endif  // XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_