Implements extension loader and server
[platform/framework/web/crosswalk-tizen.git] / src / runtime / web_application.h
1 // Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WRT_RUNTIME_WEB_APPLICATION_H_
6 #define WRT_RUNTIME_WEB_APPLICATION_H_
7
8 #include <string>
9 #include <list>
10
11 #include "runtime/web_view.h"
12 #include "extension/extension_server.h"
13
14 class Ewk_Context;
15
16 namespace wrt {
17 class NativeWindow;
18
19 class WebApplication : public WebView::EventListener {
20  public:
21   explicit WebApplication(const std::string& appid);
22   virtual ~WebApplication();
23
24   void AppControl();
25   void Launch();
26   void Resume();
27   void Suspend();
28
29   bool Initialize(NativeWindow* window);
30   std::string data_path() const { return app_data_path_; }
31   bool initialized() const { return initialized_; }
32
33   virtual void OnCreatedNewWebView(WebView* view, WebView* new_view);
34   virtual void OnClosedWebView(WebView * view);
35   virtual void OnRendered(WebView* view);
36   virtual void OnReceivedWrtMessage(WebView* view,
37                                     Ewk_IPC_Wrt_Message_Data* message);
38   virtual void OnOrientationLock(WebView* view,
39                                  bool lock,
40                                  int preferred_rotation);
41   virtual void OnHardwareKey(WebView* view, const std::string& keyname);
42
43  private:
44   void ClearViewStack();
45   void SendAppControlEvent();
46
47   bool initialized_;
48   std::string appid_;
49   Ewk_Context* ewk_context_;
50   NativeWindow* window_;
51   ExtensionServer* extension_server_;
52   std::list<WebView*> view_stack_;
53   std::string app_data_path_;
54 };
55
56 }  // namespace wrt
57
58 #endif  // WRT_RUNTIME_WEB_APPLICATION_H_