| 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // ] | 607 // ] |
| 608 template <typename T> | 608 template <typename T> |
| 609 static std::unique_ptr<base::ListValue> CreatePermissionList( | 609 static std::unique_ptr<base::ListValue> CreatePermissionList( |
| 610 const T& permissions) { | 610 const T& permissions) { |
| 611 auto values = base::MakeUnique<base::ListValue>(); | 611 auto values = base::MakeUnique<base::ListValue>(); |
| 612 for (typename T::const_iterator i = permissions.begin(); | 612 for (typename T::const_iterator i = permissions.begin(); |
| 613 i != permissions.end(); ++i) { | 613 i != permissions.end(); ++i) { |
| 614 std::unique_ptr<base::Value> detail(i->ToValue()); | 614 std::unique_ptr<base::Value> detail(i->ToValue()); |
| 615 if (detail) { | 615 if (detail) { |
| 616 auto tmp(base::MakeUnique<base::DictionaryValue>()); | 616 auto tmp(base::MakeUnique<base::DictionaryValue>()); |
| 617 tmp->Set(i->name(), detail.release()); | 617 tmp->Set(i->name(), std::move(detail)); |
| 618 values->Append(std::move(tmp)); | 618 values->Append(std::move(tmp)); |
| 619 } else { | 619 } else { |
| 620 values->AppendString(i->name()); | 620 values->AppendString(i->name()); |
| 621 } | 621 } |
| 622 } | 622 } |
| 623 return values; | 623 return values; |
| 624 } | 624 } |
| 625 | 625 |
| 626 void ExtensionPrefs::SetExtensionPrefPermissionSet( | 626 void ExtensionPrefs::SetExtensionPrefPermissionSet( |
| 627 const std::string& extension_id, | 627 const std::string& extension_id, |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 pending_install_dict->Remove(kDelayedInstallReason, NULL); | 1344 pending_install_dict->Remove(kDelayedInstallReason, NULL); |
| 1345 | 1345 |
| 1346 const base::Time install_time = time_provider_->GetCurrentTime(); | 1346 const base::Time install_time = time_provider_->GetCurrentTime(); |
| 1347 pending_install_dict->SetString( | 1347 pending_install_dict->SetString( |
| 1348 kPrefInstallTime, base::Int64ToString(install_time.ToInternalValue())); | 1348 kPrefInstallTime, base::Int64ToString(install_time.ToInternalValue())); |
| 1349 | 1349 |
| 1350 // Commit the delayed install data. | 1350 // Commit the delayed install data. |
| 1351 for (base::DictionaryValue::Iterator it( | 1351 for (base::DictionaryValue::Iterator it( |
| 1352 *pending_install_dict->AsConstDictionary()); | 1352 *pending_install_dict->AsConstDictionary()); |
| 1353 !it.IsAtEnd(); it.Advance()) { | 1353 !it.IsAtEnd(); it.Advance()) { |
| 1354 extension_dict->Set(it.key(), it.value().CreateDeepCopy()); | 1354 extension_dict->Set(it.key(), base::MakeUnique<base::Value>(it.value())); |
| 1355 } | 1355 } |
| 1356 FinishExtensionInfoPrefs(extension_id, install_time, needs_sort_ordinal, | 1356 FinishExtensionInfoPrefs(extension_id, install_time, needs_sort_ordinal, |
| 1357 suggested_page_ordinal, extension_dict.get()); | 1357 suggested_page_ordinal, extension_dict.get()); |
| 1358 return true; | 1358 return true; |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 std::unique_ptr<ExtensionInfo> ExtensionPrefs::GetDelayedInstallInfo( | 1361 std::unique_ptr<ExtensionInfo> ExtensionPrefs::GetDelayedInstallInfo( |
| 1362 const std::string& extension_id) const { | 1362 const std::string& extension_id) const { |
| 1363 const base::DictionaryValue* extension_prefs = | 1363 const base::DictionaryValue* extension_prefs = |
| 1364 GetExtensionPref(extension_id); | 1364 GetExtensionPref(extension_id); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1834 | 1834 |
| 1835 base::FilePath::StringType path = MakePathRelative(install_directory_, | 1835 base::FilePath::StringType path = MakePathRelative(install_directory_, |
| 1836 extension->path()); | 1836 extension->path()); |
| 1837 extension_dict->SetString(kPrefPath, path); | 1837 extension_dict->SetString(kPrefPath, path); |
| 1838 if (!install_parameter.empty()) { | 1838 if (!install_parameter.empty()) { |
| 1839 extension_dict->SetString(kPrefInstallParam, install_parameter); | 1839 extension_dict->SetString(kPrefInstallParam, install_parameter); |
| 1840 } | 1840 } |
| 1841 // We store prefs about LOAD extensions, but don't cache their manifest | 1841 // We store prefs about LOAD extensions, but don't cache their manifest |
| 1842 // since it may change on disk. | 1842 // since it may change on disk. |
| 1843 if (!Manifest::IsUnpackedLocation(extension->location())) { | 1843 if (!Manifest::IsUnpackedLocation(extension->location())) { |
| 1844 extension_dict->Set(kPrefManifest, | 1844 extension_dict->Set(kPrefManifest, base::MakeUnique<base::Value>( |
| 1845 extension->manifest()->value()->CreateDeepCopy()); | 1845 *extension->manifest()->value())); |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 // Only writes kPrefDoNotSync when it is not the default. | 1848 // Only writes kPrefDoNotSync when it is not the default. |
| 1849 if (install_flags & kInstallFlagDoNotSync) | 1849 if (install_flags & kInstallFlagDoNotSync) |
| 1850 extension_dict->SetBoolean(kPrefDoNotSync, true); | 1850 extension_dict->SetBoolean(kPrefDoNotSync, true); |
| 1851 else | 1851 else |
| 1852 extension_dict->Remove(kPrefDoNotSync, NULL); | 1852 extension_dict->Remove(kPrefDoNotSync, NULL); |
| 1853 } | 1853 } |
| 1854 | 1854 |
| 1855 void ExtensionPrefs::InitExtensionControlledPrefs( | 1855 void ExtensionPrefs::InitExtensionControlledPrefs( |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1943 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); | 1943 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); |
| 1944 | 1944 |
| 1945 extension_pref_value_map_->RegisterExtension( | 1945 extension_pref_value_map_->RegisterExtension( |
| 1946 extension_id, install_time, is_enabled, is_incognito_enabled); | 1946 extension_id, install_time, is_enabled, is_incognito_enabled); |
| 1947 | 1947 |
| 1948 for (auto& observer : observer_list_) | 1948 for (auto& observer : observer_list_) |
| 1949 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); | 1949 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); |
| 1950 } | 1950 } |
| 1951 | 1951 |
| 1952 } // namespace extensions | 1952 } // namespace extensions |
| OLD | NEW |