Upstream version 10.39.233.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / common / manifest_handlers / tizen_appwidget_handler.h
1 // Copyright (c) 2014 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 XWALK_APPLICATION_COMMON_MANIFEST_HANDLERS_TIZEN_APPWIDGET_HANDLER_H_
6 #define XWALK_APPLICATION_COMMON_MANIFEST_HANDLERS_TIZEN_APPWIDGET_HANDLER_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "xwalk/application/common/application_data.h"
13 #include "xwalk/application/common/manifest_handler.h"
14
15 namespace xwalk {
16 namespace application {
17
18 typedef std::map<std::string, std::string> TizenAppWidgetLabelLangValueMap;
19
20 struct TizenAppWidgetLabel {
21   // may be empty
22   std::string default_value;
23
24   // may be empty if default is set
25   TizenAppWidgetLabelLangValueMap lang_value_map;
26 };
27
28 enum TizenAppWidgetSizeType {
29   k1x1, k2x1, k2x2
30 };
31
32 struct TizenAppWidgetSize {
33   // mandatory
34   TizenAppWidgetSizeType type;
35
36   // optional, relative to web app directory
37   std::string preview;
38
39   // optional, default: true
40   bool use_decoration;
41 };
42
43 typedef std::vector<TizenAppWidgetSize> TizenAppWidgetSizeVector;
44
45 struct TizenAppWidgetDropView {
46   // mandatory, relative to web app directory or remote URL
47   std::string src;
48
49   // mandatory
50   int width;
51
52   // mandatory, <1, 380>
53   int height;
54 };
55
56 typedef std::vector<TizenAppWidgetDropView> TizenAppWidgetDropViewVector;
57
58 struct TizenAppWidget {
59   // mandatory, unique, must start with application id and end with label
60   // separated with dot, the label can contain only 0-9, a-z, A-Z
61   std::string id;
62
63   // mandatory, only one may contain true
64   bool primary;
65
66   // optional(0-1), min: 1800.0, default: no update
67   std::vector<double> update_period;
68
69   // optional, default: false
70   bool auto_launch;
71
72   // box label, multiple(1+)
73   TizenAppWidgetLabel label;
74
75   // box icon, optional(0-1), src, mandatory, relative to web app directory
76   std::string icon_src;
77
78   // box content, mandatory(1) -[
79
80   // mandatory, relative to web app directory or remote URL
81   std::string content_src;
82
83   // optional, default: false
84   bool content_mouse_event;
85
86   // optional, default: true
87   bool content_touch_effect;
88
89   // box size, mandatory(1-3), 1x1 must exist
90   TizenAppWidgetSizeVector content_size;
91
92   // drop view, optional(0-1)
93   TizenAppWidgetDropViewVector content_drop_view;
94
95   // ]- box content
96 };
97
98 typedef std::vector<TizenAppWidget> TizenAppWidgetVector;
99
100 class TizenAppWidgetInfo : public ApplicationData::ManifestData {
101  public:
102   explicit TizenAppWidgetInfo(const TizenAppWidgetVector& app_widgets);
103   virtual ~TizenAppWidgetInfo();
104
105   const TizenAppWidgetVector& app_widgets() const {
106     return app_widgets_;
107   }
108
109  private:
110   // multiple(0+)
111   TizenAppWidgetVector app_widgets_;
112 };
113
114 class TizenAppWidgetHandler : public ManifestHandler {
115  public:
116   TizenAppWidgetHandler();
117   virtual ~TizenAppWidgetHandler();
118
119   bool Parse(scoped_refptr<ApplicationData> application,
120              base::string16* error) override;
121   bool Validate(scoped_refptr<const ApplicationData> application,
122                 std::string* error) const override;
123   std::vector<std::string> Keys() const override;
124
125  private:
126   DISALLOW_COPY_AND_ASSIGN(TizenAppWidgetHandler);
127 };
128
129 }  // namespace application
130 }  // namespace xwalk
131
132 #endif  // XWALK_APPLICATION_COMMON_MANIFEST_HANDLERS_TIZEN_APPWIDGET_HANDLER_H_