Upstream version 6.34.113.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / extension / application_widget_storage.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_STORAGE_H_
6 #define XWALK_APPLICATION_EXTENSION_APPLICATION_WIDGET_STORAGE_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/values.h"
12 #include "base/files/file_path.h"
13 #include "sql/connection.h"
14 #include "xwalk/application/browser/application.h"
15
16 namespace xwalk {
17 namespace application {
18
19 class AppWidgetStorage {
20  public:
21   AppWidgetStorage(Application* application,
22                    const base::FilePath& data_dir);
23   ~AppWidgetStorage();
24
25   // Adds or replaces entry (if not readonly);
26   // returns true on success.
27   bool AddEntry(const std::string& key,
28                const std::string& value,
29                bool read_only);
30   bool RemoveEntry(const std::string& key);
31   bool Clear();
32   bool GetAllEntries(base::DictionaryValue* result);
33   bool EntryExists(const std::string& key) const;
34
35  private:
36   bool Init();
37   bool IsReadOnly(const std::string& key);
38   bool InitStorageTable();
39   bool SaveConfigInfoInDB();
40   bool SaveConfigInfoItem(base::DictionaryValue* dict);
41
42   Application* application_;
43   scoped_ptr<sql::Connection> sqlite_db_;
44   base::FilePath data_path_;
45   bool db_initialized_;
46 };
47
48 }  // namespace application
49 }  // namespace xwalk
50 #endif  // XWALK_APPLICATION_EXTENSION_APPLICATION_WIDGET_STORAGE_H_