| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_prefs.h" | 5 #include "chrome/browser/extensions/extension_prefs.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_pref_store.h" | 10 #include "chrome/browser/extensions/extension_pref_store.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // The path to the current version's manifest file. | 36 // The path to the current version's manifest file. |
| 37 const char kPrefPath[] = "path"; | 37 const char kPrefPath[] = "path"; |
| 38 | 38 |
| 39 // The dictionary containing the extension's manifest. | 39 // The dictionary containing the extension's manifest. |
| 40 const char kPrefManifest[] = "manifest"; | 40 const char kPrefManifest[] = "manifest"; |
| 41 | 41 |
| 42 // The version number. | 42 // The version number. |
| 43 const char kPrefVersion[] = "manifest.version"; | 43 const char kPrefVersion[] = "manifest.version"; |
| 44 | 44 |
| 45 // Indicates if an extension is blacklisted: | 45 // Indicates whether an extension is blacklisted. |
| 46 const char kPrefBlacklist[] = "blacklist"; | 46 const char kPrefBlacklist[] = "blacklist"; |
| 47 | 47 |
| 48 // Indicates whether the user has acknowledged various types of extensions. |
| 49 const char kPrefExternalAcknowledged[] = "ack_external"; |
| 50 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; |
| 51 const char kPrefOrphanAcknowledged[] = "ack_orphan"; |
| 52 |
| 48 // Indicates whether to show an install warning when the user enables. | 53 // Indicates whether to show an install warning when the user enables. |
| 49 const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable"; | 54 const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable"; |
| 50 | 55 |
| 51 // A preference that tracks browser action toolbar configuration. This is a list | 56 // A preference that tracks browser action toolbar configuration. This is a list |
| 52 // object stored in the Preferences file. The extensions are stored by ID. | 57 // object stored in the Preferences file. The extensions are stored by ID. |
| 53 const char kExtensionToolbar[] = "extensions.toolbar"; | 58 const char kExtensionToolbar[] = "extensions.toolbar"; |
| 54 | 59 |
| 55 // The key for a serialized Time value indicating the start of the day (from the | 60 // The key for a serialized Time value indicating the start of the day (from the |
| 56 // server's perspective) an extension last included a "ping" parameter during | 61 // server's perspective) an extension last included a "ping" parameter during |
| 57 // its update check. | 62 // its update check. |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 522 |
| 518 // static | 523 // static |
| 519 bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) { | 524 bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) { |
| 520 return ReadBooleanFromPref(ext, kPrefBlacklist); | 525 return ReadBooleanFromPref(ext, kPrefBlacklist); |
| 521 } | 526 } |
| 522 | 527 |
| 523 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) { | 528 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) { |
| 524 return ReadExtensionPrefBoolean(extension_id, kPrefBlacklist); | 529 return ReadExtensionPrefBoolean(extension_id, kPrefBlacklist); |
| 525 } | 530 } |
| 526 | 531 |
| 532 bool ExtensionPrefs::IsExtensionOrphaned(const std::string& extension_id) { |
| 533 // TODO(miket): we believe that this test will hinge on the number of |
| 534 // consecutive times that an update check has returned a certain response |
| 535 // versus a success response. For now nobody is orphaned. |
| 536 return false; |
| 537 } |
| 538 |
| 539 bool ExtensionPrefs::IsExternalExtensionAcknowledged( |
| 540 const std::string& extension_id) { |
| 541 return ReadExtensionPrefBoolean(extension_id, kPrefExternalAcknowledged); |
| 542 } |
| 543 |
| 544 void ExtensionPrefs::AcknowledgeExternalExtension( |
| 545 const std::string& extension_id) { |
| 546 DCHECK(Extension::IdIsValid(extension_id)); |
| 547 UpdateExtensionPref(extension_id, kPrefExternalAcknowledged, |
| 548 Value::CreateBooleanValue(true)); |
| 549 } |
| 550 |
| 551 bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged( |
| 552 const std::string& extension_id) { |
| 553 return ReadExtensionPrefBoolean(extension_id, kPrefBlacklistAcknowledged); |
| 554 } |
| 555 |
| 556 void ExtensionPrefs::AcknowledgeBlacklistedExtension( |
| 557 const std::string& extension_id) { |
| 558 DCHECK(Extension::IdIsValid(extension_id)); |
| 559 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, |
| 560 Value::CreateBooleanValue(true)); |
| 561 } |
| 562 |
| 563 bool ExtensionPrefs::IsOrphanedExtensionAcknowledged( |
| 564 const std::string& extension_id) { |
| 565 return ReadExtensionPrefBoolean(extension_id, kPrefOrphanAcknowledged); |
| 566 } |
| 567 |
| 568 void ExtensionPrefs::AcknowledgeOrphanedExtension( |
| 569 const std::string& extension_id) { |
| 570 DCHECK(Extension::IdIsValid(extension_id)); |
| 571 UpdateExtensionPref(extension_id, kPrefOrphanAcknowledged, |
| 572 Value::CreateBooleanValue(true)); |
| 573 } |
| 574 |
| 575 bool ExtensionPrefs::SetAlertSystemFirstRun() { |
| 576 if (prefs_->GetBoolean(prefs::kExtensionAlertsInitializedPref)) { |
| 577 return true; |
| 578 } |
| 579 prefs_->SetBoolean(prefs::kExtensionAlertsInitializedPref, true); |
| 580 return false; |
| 581 } |
| 582 |
| 527 bool ExtensionPrefs::IsExtensionAllowedByPolicy( | 583 bool ExtensionPrefs::IsExtensionAllowedByPolicy( |
| 528 const std::string& extension_id) { | 584 const std::string& extension_id) { |
| 529 std::string string_value; | 585 std::string string_value; |
| 530 | 586 |
| 531 const ListValue* blacklist = | 587 const ListValue* blacklist = |
| 532 prefs_->GetList(prefs::kExtensionInstallDenyList); | 588 prefs_->GetList(prefs::kExtensionInstallDenyList); |
| 533 if (!blacklist || blacklist->empty()) | 589 if (!blacklist || blacklist->empty()) |
| 534 return true; | 590 return true; |
| 535 | 591 |
| 536 // Check the whitelist first. | 592 // Check the whitelist first. |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1766 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
| 1711 PrefService::UNSYNCABLE_PREF); | 1767 PrefService::UNSYNCABLE_PREF); |
| 1712 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1768 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
| 1713 PrefService::UNSYNCABLE_PREF); | 1769 PrefService::UNSYNCABLE_PREF); |
| 1714 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1770 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
| 1715 PrefService::UNSYNCABLE_PREF); | 1771 PrefService::UNSYNCABLE_PREF); |
| 1716 prefs->RegisterStringPref(kWebStoreLogin, | 1772 prefs->RegisterStringPref(kWebStoreLogin, |
| 1717 std::string() /* default_value */, | 1773 std::string() /* default_value */, |
| 1718 PrefService::UNSYNCABLE_PREF); | 1774 PrefService::UNSYNCABLE_PREF); |
| 1719 } | 1775 } |
| OLD | NEW |