b37ddc47e672e1dd7368a69248d8c1377f97acd3
[platform/framework/web/crosswalk.git] / src / xwalk / application / extension / application_widget_extension.h
1 // Copyright (c) 2014 Intel Corporation. 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_EXTENSION_APPLICATION_WIDGET_EXTENSION_H_
6 #define XWALK_APPLICATION_EXTENSION_APPLICATION_WIDGET_EXTENSION_H_
7
8 #include <string>
9
10 #include "xwalk/extensions/browser/xwalk_extension_function_handler.h"
11 #include "xwalk/extensions/common/xwalk_extension.h"
12
13 namespace xwalk {
14 namespace application {
15 class Application;
16
17 using extensions::XWalkExtension;
18 using extensions::XWalkExtensionFunctionHandler;
19 using extensions::XWalkExtensionFunctionInfo;
20 using extensions::XWalkExtensionInstance;
21
22 class ApplicationWidgetExtension : public XWalkExtension {
23  public:
24   explicit ApplicationWidgetExtension(Application* application);
25
26   // XWalkExtension implementation.
27   virtual XWalkExtensionInstance* CreateInstance() OVERRIDE;
28
29  private:
30   Application* application_;
31 };
32
33 class AppWidgetExtensionInstance : public XWalkExtensionInstance {
34  public:
35   explicit AppWidgetExtensionInstance(Application* application);
36   virtual ~AppWidgetExtensionInstance();
37
38   virtual void HandleMessage(scoped_ptr<base::Value> msg) OVERRIDE;
39   virtual void HandleSyncMessage(scoped_ptr<base::Value> msg) OVERRIDE;
40
41  private:
42   scoped_ptr<base::StringValue> GetWidgetInfo(scoped_ptr<base::Value> msg);
43   scoped_ptr<base::FundamentalValue> SetPreferencesItem(
44       scoped_ptr<base::Value> mgs);
45   scoped_ptr<base::FundamentalValue> RemovePreferencesItem(
46       scoped_ptr<base::Value> mgs);
47   scoped_ptr<base::FundamentalValue> ClearAllItems(scoped_ptr<base::Value> mgs);
48   scoped_ptr<base::DictionaryValue> GetAllItems(scoped_ptr<base::Value> mgs);
49   scoped_ptr<base::FundamentalValue> KeyExists(
50       scoped_ptr<base::Value> mgs) const;
51
52   Application* application_;
53   scoped_ptr<class AppWidgetStorage> widget_storage_;
54   XWalkExtensionFunctionHandler handler_;
55 };
56
57 }  // namespace application
58 }  // namespace xwalk
59
60 #endif  // XWALK_APPLICATION_EXTENSION_APPLICATION_WIDGET_EXTENSION_H_