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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 const char kPrefIncognitoEnabled[] = "incognito"; | 82 const char kPrefIncognitoEnabled[] = "incognito"; |
83 | 83 |
84 // A preference to control whether an extension is allowed to inject script in | 84 // A preference to control whether an extension is allowed to inject script in |
85 // pages with file URLs. | 85 // pages with file URLs. |
86 const char kPrefAllowFileAccess[] = "newAllowFileAccess"; | 86 const char kPrefAllowFileAccess[] = "newAllowFileAccess"; |
87 // TODO(jstritar): As part of fixing http://crbug.com/91577, we revoked all | 87 // TODO(jstritar): As part of fixing http://crbug.com/91577, we revoked all |
88 // extension file access by renaming the pref. We should eventually clean up | 88 // extension file access by renaming the pref. We should eventually clean up |
89 // the old flag and possibly go back to that name. | 89 // the old flag and possibly go back to that name. |
90 // const char kPrefAllowFileAccessOld[] = "allowFileAccess"; | 90 // const char kPrefAllowFileAccessOld[] = "allowFileAccess"; |
91 | 91 |
92 // A preference indicating that the extension wants to delay network requests | |
93 // on browser launch until it indicates it's ready. For example, an extension | |
94 // using the webRequest API might want to ensure that no requests are sent | |
95 // before it has registered its event handlers. | |
96 const char kPrefDelayNetworkRequests[] = "delayNetworkRequests"; | |
97 | |
98 // A preference set by the web store to indicate login information for | 92 // A preference set by the web store to indicate login information for |
99 // purchased apps. | 93 // purchased apps. |
100 const char kWebStoreLogin[] = "extensions.webstore_login"; | 94 const char kWebStoreLogin[] = "extensions.webstore_login"; |
101 | 95 |
102 // A preference set by the the NTP to persist the desired launch container type | 96 // A preference set by the the NTP to persist the desired launch container type |
103 // used for apps. | 97 // used for apps. |
104 const char kPrefLaunchType[] = "launchType"; | 98 const char kPrefLaunchType[] = "launchType"; |
105 | 99 |
106 // A preference determining the order of which the apps appear on the NTP. | 100 // A preference determining the order of which the apps appear on the NTP. |
107 const char kPrefAppLaunchIndex[] = "app_launcher_index"; | 101 const char kPrefAppLaunchIndex[] = "app_launcher_index"; |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, | 870 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, |
877 Value::CreateBooleanValue(allow)); | 871 Value::CreateBooleanValue(allow)); |
878 } | 872 } |
879 | 873 |
880 bool ExtensionPrefs::HasAllowFileAccessSetting( | 874 bool ExtensionPrefs::HasAllowFileAccessSetting( |
881 const std::string& extension_id) const { | 875 const std::string& extension_id) const { |
882 const DictionaryValue* ext = GetExtensionPref(extension_id); | 876 const DictionaryValue* ext = GetExtensionPref(extension_id); |
883 return ext && ext->HasKey(kPrefAllowFileAccess); | 877 return ext && ext->HasKey(kPrefAllowFileAccess); |
884 } | 878 } |
885 | 879 |
886 void ExtensionPrefs::SetDelaysNetworkRequests(const std::string& extension_id, | |
887 bool does_delay) { | |
888 if (does_delay) { | |
889 UpdateExtensionPref(extension_id, kPrefDelayNetworkRequests, | |
890 Value::CreateBooleanValue(true)); | |
891 } else { | |
892 // Remove the pref. | |
893 UpdateExtensionPref(extension_id, kPrefDelayNetworkRequests, NULL); | |
894 } | |
895 } | |
896 | |
897 bool ExtensionPrefs::DelaysNetworkRequests(const std::string& extension_id) { | |
898 return ReadExtensionPrefBoolean(extension_id, kPrefDelayNetworkRequests); | |
899 } | |
900 | |
901 ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType( | 880 ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType( |
902 const std::string& extension_id, | 881 const std::string& extension_id, |
903 ExtensionPrefs::LaunchType default_pref_value) { | 882 ExtensionPrefs::LaunchType default_pref_value) { |
904 int value = -1; | 883 int value = -1; |
905 LaunchType result = LAUNCH_REGULAR; | 884 LaunchType result = LAUNCH_REGULAR; |
906 | 885 |
907 if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) && | 886 if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) && |
908 (value == LAUNCH_PINNED || | 887 (value == LAUNCH_PINNED || |
909 value == LAUNCH_REGULAR || | 888 value == LAUNCH_REGULAR || |
910 value == LAUNCH_FULLSCREEN || | 889 value == LAUNCH_FULLSCREEN || |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 for (DictionaryValue::key_iterator i = prefs->begin_keys(); | 1634 for (DictionaryValue::key_iterator i = prefs->begin_keys(); |
1656 i != prefs->end_keys(); ++i) { | 1635 i != prefs->end_keys(); ++i) { |
1657 Value* value; | 1636 Value* value; |
1658 if (!prefs->GetWithoutPathExpansion(*i, &value)) | 1637 if (!prefs->GetWithoutPathExpansion(*i, &value)) |
1659 continue; | 1638 continue; |
1660 extension_pref_value_map_->SetExtensionPref( | 1639 extension_pref_value_map_->SetExtensionPref( |
1661 *ext_id, *i, kExtensionPrefsScopeIncognitoPersistent, | 1640 *ext_id, *i, kExtensionPrefsScopeIncognitoPersistent, |
1662 value->DeepCopy()); | 1641 value->DeepCopy()); |
1663 } | 1642 } |
1664 | 1643 |
1665 // Set content settings. | |
1666 const DictionaryValue* extension_prefs = GetExtensionPref(*ext_id); | 1644 const DictionaryValue* extension_prefs = GetExtensionPref(*ext_id); |
1667 DCHECK(extension_prefs); | 1645 DCHECK(extension_prefs); |
1668 ListValue* content_settings = NULL; | 1646 ListValue* content_settings = NULL; |
1669 if (extension_prefs->GetList(kPrefContentSettings, | 1647 if (extension_prefs->GetList(kPrefContentSettings, |
1670 &content_settings)) { | 1648 &content_settings)) { |
1671 content_settings_store_->SetExtensionContentSettingsFromList( | 1649 content_settings_store_->SetExtensionContentSettingsFromList( |
1672 *ext_id, content_settings, | 1650 *ext_id, content_settings, |
1673 kExtensionPrefsScopeRegular); | 1651 kExtensionPrefsScopeRegular); |
1674 } | 1652 } |
1675 if (extension_prefs->GetList(kPrefIncognitoContentSettings, | 1653 if (extension_prefs->GetList(kPrefIncognitoContentSettings, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1770 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
1793 PrefService::UNSYNCABLE_PREF); | 1771 PrefService::UNSYNCABLE_PREF); |
1794 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1772 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
1795 PrefService::UNSYNCABLE_PREF); | 1773 PrefService::UNSYNCABLE_PREF); |
1796 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1774 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
1797 PrefService::UNSYNCABLE_PREF); | 1775 PrefService::UNSYNCABLE_PREF); |
1798 prefs->RegisterStringPref(kWebStoreLogin, | 1776 prefs->RegisterStringPref(kWebStoreLogin, |
1799 std::string() /* default_value */, | 1777 std::string() /* default_value */, |
1800 PrefService::UNSYNCABLE_PREF); | 1778 PrefService::UNSYNCABLE_PREF); |
1801 } | 1779 } |
OLD | NEW |