OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "extensions/browser/extension_prefs.h" | 5 #include "extensions/browser/extension_prefs.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 &serialized_ordinal)) { | 1354 &serialized_ordinal)) { |
1355 suggested_page_ordinal = syncer::StringOrdinal(serialized_ordinal); | 1355 suggested_page_ordinal = syncer::StringOrdinal(serialized_ordinal); |
1356 needs_sort_ordinal = true; | 1356 needs_sort_ordinal = true; |
1357 pending_install_dict->Remove(kPrefSuggestedPageOrdinal, NULL); | 1357 pending_install_dict->Remove(kPrefSuggestedPageOrdinal, NULL); |
1358 } | 1358 } |
1359 pending_install_dict->Remove(kDelayedInstallReason, NULL); | 1359 pending_install_dict->Remove(kDelayedInstallReason, NULL); |
1360 | 1360 |
1361 const base::Time install_time = time_provider_->GetCurrentTime(); | 1361 const base::Time install_time = time_provider_->GetCurrentTime(); |
1362 pending_install_dict->Set( | 1362 pending_install_dict->Set( |
1363 kPrefInstallTime, | 1363 kPrefInstallTime, |
1364 new base::StringValue( | 1364 new base::Value(base::Int64ToString(install_time.ToInternalValue()))); |
1365 base::Int64ToString(install_time.ToInternalValue()))); | |
1366 | 1365 |
1367 // Commit the delayed install data. | 1366 // Commit the delayed install data. |
1368 for (base::DictionaryValue::Iterator it(*pending_install_dict); !it.IsAtEnd(); | 1367 for (base::DictionaryValue::Iterator it(*pending_install_dict); !it.IsAtEnd(); |
1369 it.Advance()) { | 1368 it.Advance()) { |
1370 extension_dict->Set(it.key(), it.value().DeepCopy()); | 1369 extension_dict->Set(it.key(), it.value().DeepCopy()); |
1371 } | 1370 } |
1372 FinishExtensionInfoPrefs(extension_id, install_time, needs_sort_ordinal, | 1371 FinishExtensionInfoPrefs(extension_id, install_time, needs_sort_ordinal, |
1373 suggested_page_ordinal, extension_dict); | 1372 suggested_page_ordinal, extension_dict); |
1374 return true; | 1373 return true; |
1375 } | 1374 } |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 if (!extension) // Expected during unit testing. | 1686 if (!extension) // Expected during unit testing. |
1688 return std::string(); | 1687 return std::string(); |
1689 std::string install_parameter; | 1688 std::string install_parameter; |
1690 if (!extension->GetString(kPrefInstallParam, &install_parameter)) | 1689 if (!extension->GetString(kPrefInstallParam, &install_parameter)) |
1691 return std::string(); | 1690 return std::string(); |
1692 return install_parameter; | 1691 return install_parameter; |
1693 } | 1692 } |
1694 | 1693 |
1695 void ExtensionPrefs::SetInstallParam(const std::string& extension_id, | 1694 void ExtensionPrefs::SetInstallParam(const std::string& extension_id, |
1696 const std::string& install_parameter) { | 1695 const std::string& install_parameter) { |
1697 UpdateExtensionPref(extension_id, | 1696 UpdateExtensionPref(extension_id, kPrefInstallParam, |
1698 kPrefInstallParam, | 1697 new base::Value(install_parameter)); |
1699 new base::StringValue(install_parameter)); | |
1700 } | 1698 } |
1701 | 1699 |
1702 int ExtensionPrefs::GetCorruptedDisableCount() const { | 1700 int ExtensionPrefs::GetCorruptedDisableCount() const { |
1703 return prefs_->GetInteger(kCorruptedDisableCount); | 1701 return prefs_->GetInteger(kCorruptedDisableCount); |
1704 } | 1702 } |
1705 | 1703 |
1706 void ExtensionPrefs::IncrementCorruptedDisableCount() { | 1704 void ExtensionPrefs::IncrementCorruptedDisableCount() { |
1707 int count = prefs_->GetInteger(kCorruptedDisableCount); | 1705 int count = prefs_->GetInteger(kCorruptedDisableCount); |
1708 prefs_->SetInteger(kCorruptedDisableCount, count + 1); | 1706 prefs_->SetInteger(kCorruptedDisableCount, count + 1); |
1709 } | 1707 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1837 extension_dict->Set(kPrefCreationFlags, | 1835 extension_dict->Set(kPrefCreationFlags, |
1838 new base::Value(extension->creation_flags())); | 1836 new base::Value(extension->creation_flags())); |
1839 extension_dict->Set(kPrefFromWebStore, | 1837 extension_dict->Set(kPrefFromWebStore, |
1840 new base::Value(extension->from_webstore())); | 1838 new base::Value(extension->from_webstore())); |
1841 extension_dict->Set(kPrefFromBookmark, | 1839 extension_dict->Set(kPrefFromBookmark, |
1842 new base::Value(extension->from_bookmark())); | 1840 new base::Value(extension->from_bookmark())); |
1843 extension_dict->Set(kPrefWasInstalledByDefault, | 1841 extension_dict->Set(kPrefWasInstalledByDefault, |
1844 new base::Value(extension->was_installed_by_default())); | 1842 new base::Value(extension->was_installed_by_default())); |
1845 extension_dict->Set(kPrefWasInstalledByOem, | 1843 extension_dict->Set(kPrefWasInstalledByOem, |
1846 new base::Value(extension->was_installed_by_oem())); | 1844 new base::Value(extension->was_installed_by_oem())); |
1847 extension_dict->Set(kPrefInstallTime, | 1845 extension_dict->Set( |
1848 new base::StringValue( | 1846 kPrefInstallTime, |
1849 base::Int64ToString(install_time.ToInternalValue()))); | 1847 new base::Value(base::Int64ToString(install_time.ToInternalValue()))); |
1850 if (install_flags & kInstallFlagIsBlacklistedForMalware) | 1848 if (install_flags & kInstallFlagIsBlacklistedForMalware) |
1851 extension_dict->Set(kPrefBlacklist, new base::Value(true)); | 1849 extension_dict->Set(kPrefBlacklist, new base::Value(true)); |
1852 | 1850 |
1853 base::FilePath::StringType path = MakePathRelative(install_directory_, | 1851 base::FilePath::StringType path = MakePathRelative(install_directory_, |
1854 extension->path()); | 1852 extension->path()); |
1855 extension_dict->Set(kPrefPath, new base::StringValue(path)); | 1853 extension_dict->Set(kPrefPath, new base::Value(path)); |
1856 if (!install_parameter.empty()) { | 1854 if (!install_parameter.empty()) { |
1857 extension_dict->Set(kPrefInstallParam, | 1855 extension_dict->Set(kPrefInstallParam, new base::Value(install_parameter)); |
1858 new base::StringValue(install_parameter)); | |
1859 } | 1856 } |
1860 // We store prefs about LOAD extensions, but don't cache their manifest | 1857 // We store prefs about LOAD extensions, but don't cache their manifest |
1861 // since it may change on disk. | 1858 // since it may change on disk. |
1862 if (!Manifest::IsUnpackedLocation(extension->location())) { | 1859 if (!Manifest::IsUnpackedLocation(extension->location())) { |
1863 extension_dict->Set(kPrefManifest, | 1860 extension_dict->Set(kPrefManifest, |
1864 extension->manifest()->value()->DeepCopy()); | 1861 extension->manifest()->value()->DeepCopy()); |
1865 } | 1862 } |
1866 | 1863 |
1867 // Only writes kPrefDoNotSync when it is not the default. | 1864 // Only writes kPrefDoNotSync when it is not the default. |
1868 if (install_flags & kInstallFlagDoNotSync) | 1865 if (install_flags & kInstallFlagDoNotSync) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); | 1958 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); |
1962 | 1959 |
1963 extension_pref_value_map_->RegisterExtension( | 1960 extension_pref_value_map_->RegisterExtension( |
1964 extension_id, install_time, is_enabled, is_incognito_enabled); | 1961 extension_id, install_time, is_enabled, is_incognito_enabled); |
1965 | 1962 |
1966 for (auto& observer : observer_list_) | 1963 for (auto& observer : observer_list_) |
1967 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); | 1964 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); |
1968 } | 1965 } |
1969 | 1966 |
1970 } // namespace extensions | 1967 } // namespace extensions |
OLD | NEW |