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/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/admin_policy.h" | 10 #include "chrome/browser/extensions/admin_policy.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 const char kPrefInstallTime[] = "install_time"; | 159 const char kPrefInstallTime[] = "install_time"; |
160 | 160 |
161 // A preference that indicates whether the extension was installed from the | 161 // A preference that indicates whether the extension was installed from the |
162 // Chrome Web Store. | 162 // Chrome Web Store. |
163 const char kPrefFromWebStore[] = "from_webstore"; | 163 const char kPrefFromWebStore[] = "from_webstore"; |
164 | 164 |
165 // A preference that indicates whether the extension was installed from a | 165 // A preference that indicates whether the extension was installed from a |
166 // mock App created from a bookmark. | 166 // mock App created from a bookmark. |
167 const char kPrefFromBookmark[] = "from_bookmark"; | 167 const char kPrefFromBookmark[] = "from_bookmark"; |
168 | 168 |
| 169 // A prefrence that indicates whethere the extension was installed as |
| 170 // default apps. |
| 171 const char kPrefFromDefault[] = "from_default"; |
| 172 |
169 // A preference that contains any extension-controlled preferences. | 173 // A preference that contains any extension-controlled preferences. |
170 const char kPrefPreferences[] = "preferences"; | 174 const char kPrefPreferences[] = "preferences"; |
171 | 175 |
172 // A preference that contains any extension-controlled incognito preferences. | 176 // A preference that contains any extension-controlled incognito preferences. |
173 const char kPrefIncognitoPreferences[] = "incognito_preferences"; | 177 const char kPrefIncognitoPreferences[] = "incognito_preferences"; |
174 | 178 |
175 // A preference that contains any extension-controlled regular-only preferences. | 179 // A preference that contains any extension-controlled regular-only preferences. |
176 const char kPrefRegularOnlyPreferences[] = "regular_only_preferences"; | 180 const char kPrefRegularOnlyPreferences[] = "regular_only_preferences"; |
177 | 181 |
178 // A preference that contains extension-set content settings. | 182 // A preference that contains extension-set content settings. |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 ScopedExtensionPrefUpdate update(prefs_, id); | 1406 ScopedExtensionPrefUpdate update(prefs_, id); |
1403 DictionaryValue* extension_dict = update.Get(); | 1407 DictionaryValue* extension_dict = update.Get(); |
1404 const base::Time install_time = GetCurrentTime(); | 1408 const base::Time install_time = GetCurrentTime(); |
1405 extension_dict->Set(kPrefState, Value::CreateIntegerValue(initial_state)); | 1409 extension_dict->Set(kPrefState, Value::CreateIntegerValue(initial_state)); |
1406 extension_dict->Set(kPrefLocation, | 1410 extension_dict->Set(kPrefLocation, |
1407 Value::CreateIntegerValue(extension->location())); | 1411 Value::CreateIntegerValue(extension->location())); |
1408 extension_dict->Set(kPrefFromWebStore, | 1412 extension_dict->Set(kPrefFromWebStore, |
1409 Value::CreateBooleanValue(from_webstore)); | 1413 Value::CreateBooleanValue(from_webstore)); |
1410 extension_dict->Set(kPrefFromBookmark, | 1414 extension_dict->Set(kPrefFromBookmark, |
1411 Value::CreateBooleanValue(extension->from_bookmark())); | 1415 Value::CreateBooleanValue(extension->from_bookmark())); |
| 1416 extension_dict->Set(kPrefFromDefault, |
| 1417 Value::CreateBooleanValue(extension->from_default())); |
1412 extension_dict->Set(kPrefInstallTime, | 1418 extension_dict->Set(kPrefInstallTime, |
1413 Value::CreateStringValue( | 1419 Value::CreateStringValue( |
1414 base::Int64ToString(install_time.ToInternalValue()))); | 1420 base::Int64ToString(install_time.ToInternalValue()))); |
1415 extension_dict->Set(kPrefPreferences, new DictionaryValue()); | 1421 extension_dict->Set(kPrefPreferences, new DictionaryValue()); |
1416 extension_dict->Set(kPrefIncognitoPreferences, new DictionaryValue()); | 1422 extension_dict->Set(kPrefIncognitoPreferences, new DictionaryValue()); |
1417 extension_dict->Set(kPrefRegularOnlyPreferences, new DictionaryValue()); | 1423 extension_dict->Set(kPrefRegularOnlyPreferences, new DictionaryValue()); |
1418 extension_dict->Set(kPrefContentSettings, new ListValue()); | 1424 extension_dict->Set(kPrefContentSettings, new ListValue()); |
1419 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue()); | 1425 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue()); |
1420 | 1426 |
1421 FilePath::StringType path = MakePathRelative(install_directory_, | 1427 FilePath::StringType path = MakePathRelative(install_directory_, |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 | 1817 |
1812 bool ExtensionPrefs::IsFromBookmark( | 1818 bool ExtensionPrefs::IsFromBookmark( |
1813 const std::string& extension_id) const { | 1819 const std::string& extension_id) const { |
1814 const DictionaryValue* dictionary = GetExtensionPref(extension_id); | 1820 const DictionaryValue* dictionary = GetExtensionPref(extension_id); |
1815 bool result = false; | 1821 bool result = false; |
1816 if (dictionary && dictionary->GetBoolean(kPrefFromBookmark, &result)) | 1822 if (dictionary && dictionary->GetBoolean(kPrefFromBookmark, &result)) |
1817 return result; | 1823 return result; |
1818 return false; | 1824 return false; |
1819 } | 1825 } |
1820 | 1826 |
| 1827 bool ExtensionPrefs::IsFromDefault( |
| 1828 const std::string& extension_id) const { |
| 1829 const DictionaryValue* dictionary = GetExtensionPref(extension_id); |
| 1830 bool result = false; |
| 1831 if (dictionary && dictionary->GetBoolean(kPrefFromDefault, &result)) |
| 1832 return result; |
| 1833 return false; |
| 1834 } |
| 1835 |
1821 base::Time ExtensionPrefs::GetInstallTime( | 1836 base::Time ExtensionPrefs::GetInstallTime( |
1822 const std::string& extension_id) const { | 1837 const std::string& extension_id) const { |
1823 const DictionaryValue* extension = GetExtensionPref(extension_id); | 1838 const DictionaryValue* extension = GetExtensionPref(extension_id); |
1824 if (!extension) { | 1839 if (!extension) { |
1825 NOTREACHED(); | 1840 NOTREACHED(); |
1826 return base::Time(); | 1841 return base::Time(); |
1827 } | 1842 } |
1828 std::string install_time_str; | 1843 std::string install_time_str; |
1829 if (!extension->GetString(kPrefInstallTime, &install_time_str)) | 1844 if (!extension->GetString(kPrefInstallTime, &install_time_str)) |
1830 return base::Time(); | 1845 return base::Time(); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 const ExtensionIds& strings) { | 2154 const ExtensionIds& strings) { |
2140 ListPrefUpdate update(prefs_, pref); | 2155 ListPrefUpdate update(prefs_, pref); |
2141 ListValue* list_of_values = update.Get(); | 2156 ListValue* list_of_values = update.Get(); |
2142 list_of_values->Clear(); | 2157 list_of_values->Clear(); |
2143 for (ExtensionIds::const_iterator iter = strings.begin(); | 2158 for (ExtensionIds::const_iterator iter = strings.begin(); |
2144 iter != strings.end(); ++iter) | 2159 iter != strings.end(); ++iter) |
2145 list_of_values->Append(new StringValue(*iter)); | 2160 list_of_values->Append(new StringValue(*iter)); |
2146 } | 2161 } |
2147 | 2162 |
2148 } // namespace extensions | 2163 } // namespace extensions |
OLD | NEW |