Chromium Code Reviews| Index: chrome/browser/extensions/extension_management_internal.cc |
| diff --git a/chrome/browser/extensions/extension_management_internal.cc b/chrome/browser/extensions/extension_management_internal.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..32e25042b678863d6ff48526b179ba1b9816b44a |
| --- /dev/null |
| +++ b/chrome/browser/extensions/extension_management_internal.cc |
| @@ -0,0 +1,93 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/extension_management_internal.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/values.h" |
| +#include "chrome/browser/extensions/extension_management_constants.h" |
| +#include "extensions/common/url_pattern_set.h" |
| +#include "url/gurl.h" |
| + |
| +namespace extensions { |
| + |
| +namespace internal { |
| + |
| +namespace { |
| +const char kMalformedPreferenceWarning[] = |
| + "Malformed extension management preference."; |
| +} // namespace |
| + |
| +IndividualSettings::IndividualSettings() { |
| + Reset(); |
| +} |
| + |
| +IndividualSettings::~IndividualSettings() { |
| +} |
| + |
| +bool IndividualSettings::Parse(const base::DictionaryValue* dict, |
| + ParsingScope scope) { |
| + std::string installation_mode; |
| + if (dict->GetStringWithoutPathExpansion(schema_constants::kInstallationMode, |
| + &installation_mode)) { |
| + if (installation_mode == schema_constants::kAllowed) { |
| + this->installation_mode = ExtensionManagement::INSTALLATION_ALLOWED; |
| + } else if (installation_mode == schema_constants::kBlocked) { |
| + this->installation_mode = ExtensionManagement::INSTALLATION_BLOCKED; |
| + } else if (installation_mode == schema_constants::kForceInstalled) { |
| + this->installation_mode = ExtensionManagement::INSTALLATION_FORCED; |
| + } else if (installation_mode == schema_constants::kNormalInstalled) { |
| + this->installation_mode = ExtensionManagement::INSTALLATION_RECOMMENDED; |
| + } else { |
| + // Invalid value for 'installation_mode'. |
| + LOG(WARNING) << kMalformedPreferenceWarning; |
| + return false; |
| + } |
| + } |
| + |
| + if (this->installation_mode == ExtensionManagement::INSTALLATION_FORCED || |
|
Joao da Silva
2014/09/25 14:09:41
Remove this-> (it's not used above either)
binjin
2014/09/25 14:17:23
Done.
|
| + this->installation_mode == |
| + ExtensionManagement::INSTALLATION_RECOMMENDED) { |
| + if (scope != SCOPE_INDIVIDUAL) { |
| + // Only individual extensions are allowed to be automatically installed. |
| + LOG(WARNING) << kMalformedPreferenceWarning; |
| + return false; |
| + } |
| + std::string update_url; |
| + if (dict->GetStringWithoutPathExpansion(schema_constants::kUpdateUrl, |
| + &update_url) && |
| + GURL(update_url).is_valid()) { |
| + this->update_url = update_url; |
| + } else { |
| + // No valid update URL for extension. |
| + LOG(WARNING) << kMalformedPreferenceWarning; |
| + return false; |
| + } |
| + } |
| + |
| + return true; |
| +} |
| + |
| +void IndividualSettings::Reset() { |
| + installation_mode = ExtensionManagement::INSTALLATION_ALLOWED; |
| + update_url.clear(); |
| +} |
| + |
| +GlobalSettings::GlobalSettings() { |
| + Reset(); |
| +} |
| + |
| +GlobalSettings::~GlobalSettings() { |
| +} |
| + |
| +void GlobalSettings::Reset() { |
| + has_restricted_install_sources = false; |
| + install_sources.ClearPatterns(); |
| + has_restricted_allowed_types = false; |
| + allowed_types.clear(); |
| +} |
| + |
| +} // namespace internal |
| + |
| +} // namespace extensions |