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 "base/base_paths_posix.h" | 7 #include "base/base_paths_posix.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 if (!profile) | 89 if (!profile) |
90 return count; | 90 return count; |
91 ExtensionService* extension_service = | 91 ExtensionService* extension_service = |
92 extensions::ExtensionSystem::Get(profile)->extension_service(); | 92 extensions::ExtensionSystem::Get(profile)->extension_service(); |
93 if (!extension_service) | 93 if (!extension_service) |
94 return count; | 94 return count; |
95 | 95 |
96 const extensions::ExtensionSet* extensions = extension_service->extensions(); | 96 const extensions::ExtensionSet* extensions = extension_service->extensions(); |
97 for (extensions::ExtensionSet::const_iterator i = extensions->begin(); | 97 for (extensions::ExtensionSet::const_iterator i = extensions->begin(); |
98 i != extensions->end(); ++i) { | 98 i != extensions->end(); ++i) { |
99 if (extensions::PermissionsData::HasAPIPermission( | 99 if (extensions::PermissionsData::ForExtension(*i) |
Lei Zhang
2014/06/02 22:40:31
I'm only looking at the media galleries bits.
Her
Devlin
2014/06/03 15:28:21
Happy to do both. As Kalman points out, git cl fo
| |
100 *i, extensions::APIPermission::kMediaGalleries) || | 100 ->HasAPIPermission(extensions::APIPermission::kMediaGalleries) || |
101 extensions::PermissionsData::HasAPIPermission( | 101 extensions::PermissionsData::ForExtension(*i)->HasAPIPermission( |
102 *i, extensions::APIPermission::kMediaGalleriesPrivate)) { | 102 extensions::APIPermission::kMediaGalleriesPrivate)) { |
103 count++; | 103 count++; |
104 } | 104 } |
105 } | 105 } |
106 return count; | 106 return count; |
107 } | 107 } |
108 | 108 |
109 bool GetPrefId(const base::DictionaryValue& dict, MediaGalleryPrefId* value) { | 109 bool GetPrefId(const base::DictionaryValue& dict, MediaGalleryPrefId* value) { |
110 std::string string_id; | 110 std::string string_id; |
111 if (!dict.GetString(kMediaGalleriesPrefIdKey, &string_id) || | 111 if (!dict.GetString(kMediaGalleriesPrefIdKey, &string_id) || |
112 !base::StringToUint64(string_id, value)) { | 112 !base::StringToUint64(string_id, value)) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 // means it may be overwritten simply by getting new volume metadata. | 270 // means it may be overwritten simply by getting new volume metadata. |
271 // A display_name with version 1 should not be overwritten. | 271 // A display_name with version 1 should not be overwritten. |
272 dict->SetInteger(kMediaGalleriesPrefsVersionKey, gallery.prefs_version); | 272 dict->SetInteger(kMediaGalleriesPrefsVersionKey, gallery.prefs_version); |
273 | 273 |
274 return dict; | 274 return dict; |
275 } | 275 } |
276 | 276 |
277 bool HasAutoDetectedGalleryPermission(const extensions::Extension& extension) { | 277 bool HasAutoDetectedGalleryPermission(const extensions::Extension& extension) { |
278 extensions::MediaGalleriesPermission::CheckParam param( | 278 extensions::MediaGalleriesPermission::CheckParam param( |
279 extensions::MediaGalleriesPermission::kAllAutoDetectedPermission); | 279 extensions::MediaGalleriesPermission::kAllAutoDetectedPermission); |
280 return extensions::PermissionsData::CheckAPIPermissionWithParam( | 280 return extensions::PermissionsData::ForExtension(&extension) |
281 &extension, extensions::APIPermission::kMediaGalleries, ¶m); | 281 ->CheckAPIPermissionWithParam(extensions::APIPermission::kMediaGalleries, |
282 ¶m); | |
282 } | 283 } |
283 | 284 |
284 // Retrieves the MediaGalleryPermission from the given dictionary; DCHECKs on | 285 // Retrieves the MediaGalleryPermission from the given dictionary; DCHECKs on |
285 // failure. | 286 // failure. |
286 bool GetMediaGalleryPermissionFromDictionary( | 287 bool GetMediaGalleryPermissionFromDictionary( |
287 const base::DictionaryValue* dict, | 288 const base::DictionaryValue* dict, |
288 MediaGalleryPermission* out_permission) { | 289 MediaGalleryPermission* out_permission) { |
289 std::string string_id; | 290 std::string string_id; |
290 if (dict->GetString(kMediaGalleryIdKey, &string_id) && | 291 if (dict->GetString(kMediaGalleryIdKey, &string_id) && |
291 base::StringToUint64(string_id, &out_permission->pref_id) && | 292 base::StringToUint64(string_id, &out_permission->pref_id) && |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1236 if (extension_prefs_for_testing_) | 1237 if (extension_prefs_for_testing_) |
1237 return extension_prefs_for_testing_; | 1238 return extension_prefs_for_testing_; |
1238 return extensions::ExtensionPrefs::Get(profile_); | 1239 return extensions::ExtensionPrefs::Get(profile_); |
1239 } | 1240 } |
1240 | 1241 |
1241 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( | 1242 void MediaGalleriesPreferences::SetExtensionPrefsForTesting( |
1242 extensions::ExtensionPrefs* extension_prefs) { | 1243 extensions::ExtensionPrefs* extension_prefs) { |
1243 DCHECK(IsInitialized()); | 1244 DCHECK(IsInitialized()); |
1244 extension_prefs_for_testing_ = extension_prefs; | 1245 extension_prefs_for_testing_ = extension_prefs; |
1245 } | 1246 } |
OLD | NEW |