Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. 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 "chrome/browser/extensions/extension_management_internal.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/values.h" | |
| 9 #include "chrome/browser/extensions/extension_management_constants.h" | |
| 10 #include "extensions/common/url_pattern_set.h" | |
| 11 #include "url/gurl.h" | |
| 12 | |
| 13 namespace extensions { | |
| 14 | |
| 15 namespace internal { | |
| 16 | |
| 17 namespace { | |
| 18 const char kMalformedPreferenceWarning[] = | |
| 19 "Malformed extension management preference."; | |
| 20 } // namespace | |
| 21 | |
| 22 IndividualSettings::IndividualSettings() { | |
| 23 Reset(); | |
| 24 } | |
| 25 | |
| 26 IndividualSettings::~IndividualSettings() { | |
| 27 } | |
| 28 | |
| 29 bool IndividualSettings::Parse(const base::DictionaryValue* dict, | |
| 30 ParsingScope scope) { | |
| 31 std::string installation_mode; | |
| 32 if (dict->GetStringWithoutPathExpansion(schema_constants::kInstallationMode, | |
| 33 &installation_mode)) { | |
| 34 if (installation_mode == schema_constants::kAllowed) { | |
| 35 this->installation_mode = ExtensionManagement::INSTALLATION_ALLOWED; | |
| 36 } else if (installation_mode == schema_constants::kBlocked) { | |
| 37 this->installation_mode = ExtensionManagement::INSTALLATION_BLOCKED; | |
| 38 } else if (installation_mode == schema_constants::kForceInstalled) { | |
| 39 this->installation_mode = ExtensionManagement::INSTALLATION_FORCED; | |
| 40 } else if (installation_mode == schema_constants::kNormalInstalled) { | |
| 41 this->installation_mode = ExtensionManagement::INSTALLATION_RECOMMENDED; | |
| 42 } else { | |
| 43 // Invalid value for 'installation_mode'. | |
| 44 LOG(WARNING) << kMalformedPreferenceWarning; | |
| 45 return false; | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 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.
| |
| 50 this->installation_mode == | |
| 51 ExtensionManagement::INSTALLATION_RECOMMENDED) { | |
| 52 if (scope != SCOPE_INDIVIDUAL) { | |
| 53 // Only individual extensions are allowed to be automatically installed. | |
| 54 LOG(WARNING) << kMalformedPreferenceWarning; | |
| 55 return false; | |
| 56 } | |
| 57 std::string update_url; | |
| 58 if (dict->GetStringWithoutPathExpansion(schema_constants::kUpdateUrl, | |
| 59 &update_url) && | |
| 60 GURL(update_url).is_valid()) { | |
| 61 this->update_url = update_url; | |
| 62 } else { | |
| 63 // No valid update URL for extension. | |
| 64 LOG(WARNING) << kMalformedPreferenceWarning; | |
| 65 return false; | |
| 66 } | |
| 67 } | |
| 68 | |
| 69 return true; | |
| 70 } | |
| 71 | |
| 72 void IndividualSettings::Reset() { | |
| 73 installation_mode = ExtensionManagement::INSTALLATION_ALLOWED; | |
| 74 update_url.clear(); | |
| 75 } | |
| 76 | |
| 77 GlobalSettings::GlobalSettings() { | |
| 78 Reset(); | |
| 79 } | |
| 80 | |
| 81 GlobalSettings::~GlobalSettings() { | |
| 82 } | |
| 83 | |
| 84 void GlobalSettings::Reset() { | |
| 85 has_restricted_install_sources = false; | |
| 86 install_sources.ClearPatterns(); | |
| 87 has_restricted_allowed_types = false; | |
| 88 allowed_types.clear(); | |
| 89 } | |
| 90 | |
| 91 } // namespace internal | |
| 92 | |
| 93 } // namespace extensions | |
| OLD | NEW |