Reorder the sequence of includes
[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
39 class WebApplication : public WebView::EventListener {
40  public:
41   WebApplication(NativeWindow* window,
42                  std::unique_ptr<common::ApplicationData> app_data);
43   virtual ~WebApplication();
44
45   void AppControl(std::unique_ptr<common::AppControl> appcontrol);
46   void Launch(std::unique_ptr<common::AppControl> appcontrol);
47   void Resume();
48   void Suspend();
49
50   std::string data_path() const { return app_data_path_; }
51   void set_terminator(std::function<void(void)> terminator)
52       { terminator_ = terminator; }
53   bool launched() const { return launched_; }
54
55   virtual void OnCreatedNewWebView(WebView* view, WebView* new_view);
56   virtual void OnClosedWebView(WebView * view);
57   virtual void OnReceivedWrtMessage(
58       WebView* view,
59       Ewk_IPC_Wrt_Message_Data* msg);
60   virtual void OnOrientationLock(
61       WebView* view,
62       bool lock,
63       NativeWindow::ScreenOrientation preferred_rotation);
64   virtual void OnHardwareKey(WebView* view, const std::string& keyname);
65   virtual void OnConsoleMessage(const std::string& msg, int level);
66   virtual void OnLoadStart(WebView* view);
67   virtual void OnLoadFinished(WebView* view);
68   virtual void OnRendered(WebView* view);
69   virtual void OnLanguageChanged();
70   virtual void OnLowMemory();
71   virtual bool OnContextMenuDisabled(WebView* view);
72   virtual bool OnDidNavigation(WebView* view, const std::string& url);
73   virtual void OnNotificationPermissionRequest(
74       WebView* view,
75       const std::string& url,
76       std::function<void(bool)> result_handler);
77   virtual void OnGeolocationPermissionRequest(
78       WebView* view,
79       const std::string& url,
80       std::function<void(bool)> result_handler);
81   virtual void OnQuotaExceed(
82       WebView* view,
83       const std::string& url,
84       std::function<void(bool)> result_handler);
85   virtual void OnAuthenticationRequest(
86       WebView* view,
87       const std::string& url,
88       const std::string& message,
89       std::function<void(bool submit,
90                          const std::string& id,
91                          const std::string& password)
92                    > result_handler);
93   virtual void OnCertificateAllowRequest(
94       WebView* view,
95       const std::string& url,
96       const std::string& pem,
97       std::function<void(bool allow)> result_handler);
98   virtual void OnUsermediaPermissionRequest(
99       WebView* view,
100       const std::string& url,
101       std::function<void(bool)> result_handler);
102
103  private:
104   bool Initialize();
105
106   void ClearViewStack();
107   void SendAppControlEvent();
108   void LaunchInspector(common::AppControl* appcontrol);
109   void SetupWebView(WebView* view);
110
111   bool launched_;
112   bool debug_mode_;
113   Ewk_Context* ewk_context_;
114   NativeWindow* window_;
115   std::string appid_;
116   std::string app_data_path_;
117   std::list<WebView*> view_stack_;
118   std::unique_ptr<common::LocaleManager> locale_manager_;
119   std::unique_ptr<common::ApplicationData> app_data_;
120   std::unique_ptr<common::ResourceManager> resource_manager_;
121   std::unique_ptr<common::AppControl> received_appcontrol_;
122   std::function<void(void)> terminator_;
123   int security_model_version_;
124   std::string csp_rule_;
125   std::string csp_report_rule_;
126 };
127
128 }  // namespace runtime
129
130 #endif  // XWALK_RUNTIME_BROWSER_WEB_APPLICATION_H_