| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" | 5 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "base/version.h" | 13 #include "base/version.h" |
| 14 #include "extensions/common/api/extensions_manifest_types.h" | 14 #include "extensions/common/api/extensions_manifest_types.h" |
| 15 #include "extensions/common/manifest_constants.h" | 15 #include "extensions/common/manifest_constants.h" |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 | 18 |
| 19 namespace keys = manifest_keys; | 19 namespace keys = manifest_keys; |
| 20 | 20 |
| 21 using api::extensions_manifest_types::KioskSecondaryAppsType; | 21 using api::extensions_manifest_types::KioskSecondaryAppsType; |
| 22 | 22 |
| 23 KioskModeInfo::KioskModeInfo(KioskStatus kiosk_status, | 23 KioskModeInfo::KioskModeInfo(KioskStatus kiosk_status, |
| 24 const std::vector<std::string>& secondary_app_ids, | 24 const std::vector<std::string>& secondary_app_ids, |
| 25 const std::string& required_platform_version) | 25 const std::string& required_platform_version, |
| 26 bool always_update) |
| 26 : kiosk_status(kiosk_status), | 27 : kiosk_status(kiosk_status), |
| 27 secondary_app_ids(secondary_app_ids), | 28 secondary_app_ids(secondary_app_ids), |
| 28 required_platform_version(required_platform_version) {} | 29 required_platform_version(required_platform_version), |
| 30 always_update(always_update) {} |
| 29 | 31 |
| 30 KioskModeInfo::~KioskModeInfo() { | 32 KioskModeInfo::~KioskModeInfo() { |
| 31 } | 33 } |
| 32 | 34 |
| 33 // static | 35 // static |
| 34 KioskModeInfo* KioskModeInfo::Get(const Extension* extension) { | 36 KioskModeInfo* KioskModeInfo::Get(const Extension* extension) { |
| 35 return static_cast<KioskModeInfo*>( | 37 return static_cast<KioskModeInfo*>( |
| 36 extension->GetManifestData(keys::kKioskMode)); | 38 extension->GetManifestData(keys::kKioskMode)); |
| 37 } | 39 } |
| 38 | 40 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 std::string required_platform_version; | 132 std::string required_platform_version; |
| 131 if (manifest->HasPath(keys::kKioskRequiredPlatformVersion) && | 133 if (manifest->HasPath(keys::kKioskRequiredPlatformVersion) && |
| 132 (!manifest->GetString(keys::kKioskRequiredPlatformVersion, | 134 (!manifest->GetString(keys::kKioskRequiredPlatformVersion, |
| 133 &required_platform_version) || | 135 &required_platform_version) || |
| 134 !KioskModeInfo::IsValidPlatformVersion(required_platform_version))) { | 136 !KioskModeInfo::IsValidPlatformVersion(required_platform_version))) { |
| 135 *error = base::ASCIIToUTF16( | 137 *error = base::ASCIIToUTF16( |
| 136 manifest_errors::kInvalidKioskRequiredPlatformVersion); | 138 manifest_errors::kInvalidKioskRequiredPlatformVersion); |
| 137 return false; | 139 return false; |
| 138 } | 140 } |
| 139 | 141 |
| 142 // Optional kiosk.always_update key. |
| 143 bool always_update = false; |
| 144 if (manifest->HasPath(keys::kKioskAlwaysUpdate) && |
| 145 !manifest->GetBoolean(keys::kKioskAlwaysUpdate, &always_update)) { |
| 146 *error = base::ASCIIToUTF16(manifest_errors::kInvalidKioskAlwaysUpdate); |
| 147 return false; |
| 148 } |
| 149 |
| 140 extension->SetManifestData( | 150 extension->SetManifestData( |
| 141 keys::kKioskMode, | 151 keys::kKioskMode, |
| 142 new KioskModeInfo(kiosk_status, ids, required_platform_version)); | 152 new KioskModeInfo(kiosk_status, ids, required_platform_version, |
| 153 always_update)); |
| 143 | 154 |
| 144 return true; | 155 return true; |
| 145 } | 156 } |
| 146 | 157 |
| 147 const std::vector<std::string> KioskModeHandler::Keys() const { | 158 const std::vector<std::string> KioskModeHandler::Keys() const { |
| 148 return supported_keys_; | 159 return supported_keys_; |
| 149 } | 160 } |
| 150 | 161 |
| 151 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |