| 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_gallery/media_galleries_preferences.h" | 5 #include "chrome/browser/media_gallery/media_galleries_preferences.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 } // namespace | 155 } // namespace |
| 156 | 156 |
| 157 MediaGalleryPrefInfo::MediaGalleryPrefInfo() | 157 MediaGalleryPrefInfo::MediaGalleryPrefInfo() |
| 158 : pref_id(kInvalidMediaGalleryPrefId) { | 158 : pref_id(kInvalidMediaGalleryPrefId) { |
| 159 } | 159 } |
| 160 MediaGalleryPrefInfo::~MediaGalleryPrefInfo() {} | 160 MediaGalleryPrefInfo::~MediaGalleryPrefInfo() {} |
| 161 | 161 |
| 162 MediaGalleriesPreferences::MediaGalleriesPreferences(Profile* profile) | 162 MediaGalleriesPreferences::MediaGalleriesPreferences(Profile* profile) |
| 163 : profile_(profile) { | 163 : profile_(profile) { |
| 164 DCHECK(UserInteractionIsEnabled()); | |
| 165 | |
| 166 // Populate the default galleries if this is a fresh profile. | 164 // Populate the default galleries if this is a fresh profile. |
| 167 MediaGalleryPrefId current_id = | 165 MediaGalleryPrefId current_id = |
| 168 profile_->GetPrefs()->GetUint64(prefs::kMediaGalleriesUniqueId); | 166 profile_->GetPrefs()->GetUint64(prefs::kMediaGalleriesUniqueId); |
| 169 if (current_id == kInvalidMediaGalleryPrefId + 1) { | 167 if (current_id == kInvalidMediaGalleryPrefId + 1) { |
| 170 FilePath pictures_path; | 168 FilePath pictures_path; |
| 171 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path)) { | 169 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path)) { |
| 172 std::string device_id = MediaFileSystemRegistry::GetInstance()-> | 170 std::string device_id = MediaFileSystemRegistry::GetInstance()-> |
| 173 GetDeviceIdFromPath(pictures_path); | 171 GetDeviceIdFromPath(pictures_path); |
| 174 string16 display_name = ComputeDisplayName(pictures_path); | 172 string16 display_name = ComputeDisplayName(pictures_path); |
| 175 AddGallery(device_id, display_name, pictures_path, false /*user added*/); | 173 AddGallery(device_id, display_name, pictures_path, false /*user added*/); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 377 } |
| 380 | 378 |
| 381 // static | 379 // static |
| 382 string16 MediaGalleriesPreferences::ComputeDisplayName(const FilePath& path) { | 380 string16 MediaGalleriesPreferences::ComputeDisplayName(const FilePath& path) { |
| 383 // Assumes that path is a directory and not a file. | 381 // Assumes that path is a directory and not a file. |
| 384 return path.BaseName().LossyDisplayName(); | 382 return path.BaseName().LossyDisplayName(); |
| 385 } | 383 } |
| 386 | 384 |
| 387 // static | 385 // static |
| 388 void MediaGalleriesPreferences::RegisterUserPrefs(PrefService* prefs) { | 386 void MediaGalleriesPreferences::RegisterUserPrefs(PrefService* prefs) { |
| 389 if (!UserInteractionIsEnabled()) | |
| 390 return; | |
| 391 | |
| 392 prefs->RegisterListPref(prefs::kMediaGalleriesRememberedGalleries, | 387 prefs->RegisterListPref(prefs::kMediaGalleriesRememberedGalleries, |
| 393 PrefService::UNSYNCABLE_PREF); | 388 PrefService::UNSYNCABLE_PREF); |
| 394 prefs->RegisterUint64Pref(prefs::kMediaGalleriesUniqueId, | 389 prefs->RegisterUint64Pref(prefs::kMediaGalleriesUniqueId, |
| 395 kInvalidMediaGalleryPrefId + 1, | 390 kInvalidMediaGalleryPrefId + 1, |
| 396 PrefService::UNSYNCABLE_PREF); | 391 PrefService::UNSYNCABLE_PREF); |
| 397 } | 392 } |
| 398 | 393 |
| 399 extensions::ExtensionPrefs* | 394 extensions::ExtensionPrefs* |
| 400 MediaGalleriesPreferences::GetExtensionPrefs() const { | 395 MediaGalleriesPreferences::GetExtensionPrefs() const { |
| 401 ExtensionService* extension_service = | 396 ExtensionService* extension_service = |
| 402 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 397 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 403 return extension_service->extension_prefs(); | 398 return extension_service->extension_prefs(); |
| 404 } | 399 } |
| 405 | 400 |
| 406 } // namespace chrome | 401 } // namespace chrome |
| OLD | NEW |