| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_notifier.h" | 8 #include "base/prefs/pref_notifier.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 // The dictionary containing the extension's manifest. | 67 // The dictionary containing the extension's manifest. |
| 68 const char kPrefManifest[] = "manifest"; | 68 const char kPrefManifest[] = "manifest"; |
| 69 | 69 |
| 70 // The version number. | 70 // The version number. |
| 71 const char kPrefVersion[] = "manifest.version"; | 71 const char kPrefVersion[] = "manifest.version"; |
| 72 | 72 |
| 73 // Indicates whether an extension is blacklisted. | 73 // Indicates whether an extension is blacklisted. |
| 74 const char kPrefBlacklist[] = "blacklist"; | 74 const char kPrefBlacklist[] = "blacklist"; |
| 75 | 75 |
| 76 // The oauth client id used for app notification setup. | |
| 77 const char kPrefAppNotificationClientId[] = "app_notif_client_id"; | |
| 78 | |
| 79 // Indicates whether the user has disabled notifications or not. | |
| 80 const char kPrefAppNotificationDisbaled[] = "app_notif_disabled"; | |
| 81 | |
| 82 // The count of how many times we prompted the user to acknowledge an | 76 // The count of how many times we prompted the user to acknowledge an |
| 83 // extension. | 77 // extension. |
| 84 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count"; | 78 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count"; |
| 85 | 79 |
| 86 // If true, this extension should be excluded from the sideload wipeout UI. | 80 // If true, this extension should be excluded from the sideload wipeout UI. |
| 87 const char kPrefExcludeFromSideloadWipeout[] = "exclude_from_sideload_wipeout"; | 81 const char kPrefExcludeFromSideloadWipeout[] = "exclude_from_sideload_wipeout"; |
| 88 | 82 |
| 89 // Indicates whether the user has acknowledged various types of extensions. | 83 // Indicates whether the user has acknowledged various types of extensions. |
| 90 const char kPrefExternalAcknowledged[] = "ack_external"; | 84 const char kPrefExternalAcknowledged[] = "ack_external"; |
| 91 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; | 85 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 } | 651 } |
| 658 | 652 |
| 659 bool ExtensionPrefs::SetAlertSystemFirstRun() { | 653 bool ExtensionPrefs::SetAlertSystemFirstRun() { |
| 660 if (prefs_->GetBoolean(prefs::kExtensionAlertsInitializedPref)) { | 654 if (prefs_->GetBoolean(prefs::kExtensionAlertsInitializedPref)) { |
| 661 return true; | 655 return true; |
| 662 } | 656 } |
| 663 prefs_->SetBoolean(prefs::kExtensionAlertsInitializedPref, true); | 657 prefs_->SetBoolean(prefs::kExtensionAlertsInitializedPref, true); |
| 664 return false; | 658 return false; |
| 665 } | 659 } |
| 666 | 660 |
| 667 std::string ExtensionPrefs::GetAppNotificationClientId( | |
| 668 const std::string& extension_id) const { | |
| 669 const DictionaryValue* dict = GetExtensionPref(extension_id); | |
| 670 if (!dict || !dict->HasKey(kPrefAppNotificationClientId)) | |
| 671 return std::string(); | |
| 672 | |
| 673 std::string tmp; | |
| 674 dict->GetString(kPrefAppNotificationClientId, &tmp); | |
| 675 return tmp; | |
| 676 } | |
| 677 | |
| 678 void ExtensionPrefs::SetAppNotificationClientId( | |
| 679 const std::string& extension_id, | |
| 680 const std::string& oauth_client_id) { | |
| 681 DCHECK(Extension::IdIsValid(extension_id)); | |
| 682 UpdateExtensionPref(extension_id, kPrefAppNotificationClientId, | |
| 683 Value::CreateStringValue(oauth_client_id)); | |
| 684 } | |
| 685 | |
| 686 bool ExtensionPrefs::IsAppNotificationDisabled( | |
| 687 const std::string& extension_id) const { | |
| 688 return ReadExtensionPrefBoolean(extension_id, kPrefAppNotificationDisbaled); | |
| 689 } | |
| 690 | |
| 691 void ExtensionPrefs::SetAppNotificationDisabled( | |
| 692 const std::string& extension_id, bool value) { | |
| 693 DCHECK(Extension::IdIsValid(extension_id)); | |
| 694 UpdateExtensionPref(extension_id, kPrefAppNotificationDisbaled, | |
| 695 Value::CreateBooleanValue(value)); | |
| 696 } | |
| 697 | |
| 698 bool ExtensionPrefs::ExtensionsBlacklistedByDefault() const { | 661 bool ExtensionPrefs::ExtensionsBlacklistedByDefault() const { |
| 699 return admin_policy::BlacklistedByDefault( | 662 return admin_policy::BlacklistedByDefault( |
| 700 prefs_->GetList(prefs::kExtensionInstallDenyList)); | 663 prefs_->GetList(prefs::kExtensionInstallDenyList)); |
| 701 } | 664 } |
| 702 | 665 |
| 703 bool ExtensionPrefs::DidExtensionEscalatePermissions( | 666 bool ExtensionPrefs::DidExtensionEscalatePermissions( |
| 704 const std::string& extension_id) { | 667 const std::string& extension_id) { |
| 705 return ReadExtensionPrefBoolean(extension_id, | 668 return ReadExtensionPrefBoolean(extension_id, |
| 706 kExtensionDidEscalatePermissions); | 669 kExtensionDidEscalatePermissions); |
| 707 } | 670 } |
| (...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2434 is_enabled = initial_state == Extension::ENABLED; | 2397 is_enabled = initial_state == Extension::ENABLED; |
| 2435 } | 2398 } |
| 2436 | 2399 |
| 2437 extension_pref_value_map_->RegisterExtension(extension_id, install_time, | 2400 extension_pref_value_map_->RegisterExtension(extension_id, install_time, |
| 2438 is_enabled); | 2401 is_enabled); |
| 2439 content_settings_store_->RegisterExtension(extension_id, install_time, | 2402 content_settings_store_->RegisterExtension(extension_id, install_time, |
| 2440 is_enabled); | 2403 is_enabled); |
| 2441 } | 2404 } |
| 2442 | 2405 |
| 2443 } // namespace extensions | 2406 } // namespace extensions |
| OLD | NEW |