Upstream version 9.38.204.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / common / application_storage.cc
1 // Copyright (c) 2013 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 #include "xwalk/application/common/application_storage.h"
6
7 #if defined(OS_TIZEN)
8 #include "xwalk/application/common/application_storage_impl_tizen.h"
9 #else
10 #include "xwalk/application/common/application_storage_impl.h"
11 #endif
12
13 namespace xwalk {
14 namespace application {
15
16 ApplicationStorage::ApplicationStorage(const base::FilePath& path)
17     : impl_(new ApplicationStorageImpl(path)) {
18   impl_->Init();
19 }
20
21 ApplicationStorage::~ApplicationStorage() {
22 }
23
24 bool ApplicationStorage::AddApplication(
25     scoped_refptr<ApplicationData> app_data) {
26   if (Contains(app_data->ID())) {
27     LOG(WARNING) << "Application " << app_data->ID()
28                  << " has been already installed";
29     return false;
30   }
31
32   return impl_->AddApplication(app_data.get(), base::Time::Now());
33 }
34
35 bool ApplicationStorage::RemoveApplication(const std::string& id) {
36   return impl_->RemoveApplication(id);
37 }
38
39 bool ApplicationStorage::UpdateApplication(
40     scoped_refptr<ApplicationData> app_data) {
41   return impl_->UpdateApplication(app_data.get(), base::Time::Now());
42 }
43
44 bool ApplicationStorage::Contains(const std::string& app_id) const {
45   return impl_->ContainsApplication(app_id);
46 }
47
48 scoped_refptr<ApplicationData> ApplicationStorage::GetApplicationData(
49     const std::string& app_id) const {
50   return impl_->GetApplicationData(app_id);
51 }
52
53 bool ApplicationStorage::GetInstalledApplicationIDs(
54     std::vector<std::string>& app_ids) const {  // NOLINT
55   return impl_->GetInstalledApplicationIDs(app_ids);
56 }
57
58 }  // namespace application
59 }  // namespace xwalk