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/media_galleries/media_galleries_preferences.h" | 5 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
| 10 #include <utility> |
| 11 |
9 #include "base/base_paths_posix.h" | 12 #include "base/base_paths_posix.h" |
10 #include "base/callback.h" | 13 #include "base/callback.h" |
11 #include "base/i18n/time_formatting.h" | 14 #include "base/i18n/time_formatting.h" |
12 #include "base/macros.h" | 15 #include "base/macros.h" |
13 #include "base/path_service.h" | 16 #include "base/path_service.h" |
14 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
15 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
16 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
18 #include "base/values.h" | 21 #include "base/values.h" |
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 if (has_access != perm.has_permission) { | 1346 if (has_access != perm.has_permission) { |
1344 dict->SetBoolean(kMediaGalleryHasPermissionKey, has_access); | 1347 dict->SetBoolean(kMediaGalleryHasPermissionKey, has_access); |
1345 return true; | 1348 return true; |
1346 } else { | 1349 } else { |
1347 return false; | 1350 return false; |
1348 } | 1351 } |
1349 } | 1352 } |
1350 } | 1353 } |
1351 } | 1354 } |
1352 // ...Otherwise, add a new entry for the gallery. | 1355 // ...Otherwise, add a new entry for the gallery. |
1353 base::DictionaryValue* dict = new base::DictionaryValue; | 1356 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
1354 dict->SetString(kMediaGalleryIdKey, base::Uint64ToString(gallery_id)); | 1357 dict->SetString(kMediaGalleryIdKey, base::Uint64ToString(gallery_id)); |
1355 dict->SetBoolean(kMediaGalleryHasPermissionKey, has_access); | 1358 dict->SetBoolean(kMediaGalleryHasPermissionKey, has_access); |
1356 permissions->Append(dict); | 1359 permissions->Append(std::move(dict)); |
1357 return true; | 1360 return true; |
1358 } | 1361 } |
1359 | 1362 |
1360 bool MediaGalleriesPreferences::UnsetGalleryPermissionInPrefs( | 1363 bool MediaGalleriesPreferences::UnsetGalleryPermissionInPrefs( |
1361 const std::string& extension_id, | 1364 const std::string& extension_id, |
1362 MediaGalleryPrefId gallery_id) { | 1365 MediaGalleryPrefId gallery_id) { |
1363 DCHECK(IsInitialized()); | 1366 DCHECK(IsInitialized()); |
1364 ExtensionPrefs::ScopedListUpdate update(GetExtensionPrefs(), | 1367 ExtensionPrefs::ScopedListUpdate update(GetExtensionPrefs(), |
1365 extension_id, | 1368 extension_id, |
1366 kMediaGalleriesPermissions); | 1369 kMediaGalleriesPermissions); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 if (extension_prefs_for_testing_) | 1437 if (extension_prefs_for_testing_) |
1435 return extension_prefs_for_testing_; | 1438 return extension_prefs_for_testing_; |
1436 return extensions::ExtensionPrefs::Get(profile_); | 1439 return extensions::ExtensionPrefs::Get(profile_); |
1437 } | 1440 } |
1438 | 1441 |
1439 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( | 1442 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( |
1440 extensions::ExtensionPrefs* extension_prefs) { | 1443 extensions::ExtensionPrefs* extension_prefs) { |
1441 DCHECK(IsInitialized()); | 1444 DCHECK(IsInitialized()); |
1442 extension_prefs_for_testing_ = extension_prefs; | 1445 extension_prefs_for_testing_ = extension_prefs; |
1443 } | 1446 } |
OLD | NEW |