| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 } // namespace | 138 } // namespace |
| 139 | 139 |
| 140 MediaGalleryPrefInfo::MediaGalleryPrefInfo() | 140 MediaGalleryPrefInfo::MediaGalleryPrefInfo() |
| 141 : pref_id(kInvalidMediaGalleryPrefId) { | 141 : pref_id(kInvalidMediaGalleryPrefId) { |
| 142 } | 142 } |
| 143 MediaGalleryPrefInfo::~MediaGalleryPrefInfo() {} | 143 MediaGalleryPrefInfo::~MediaGalleryPrefInfo() {} |
| 144 | 144 |
| 145 MediaGalleriesPreferences::MediaGalleriesPreferences(Profile* profile) | 145 MediaGalleriesPreferences::MediaGalleriesPreferences(Profile* profile) |
| 146 : profile_(profile) { | 146 : profile_(profile) { |
| 147 DCHECK(UserInteractionIsEnabled()); | |
| 148 | |
| 149 // Populate the default galleries if this is a fresh profile. | 147 // Populate the default galleries if this is a fresh profile. |
| 150 MediaGalleryPrefId current_id = | 148 MediaGalleryPrefId current_id = |
| 151 profile_->GetPrefs()->GetUint64(prefs::kMediaGalleriesUniqueId); | 149 profile_->GetPrefs()->GetUint64(prefs::kMediaGalleriesUniqueId); |
| 152 if (current_id == kInvalidMediaGalleryPrefId + 1) { | 150 if (current_id == kInvalidMediaGalleryPrefId + 1) { |
| 153 FilePath pictures_path; | 151 FilePath pictures_path; |
| 154 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path)) { | 152 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path)) { |
| 155 std::string device_id = MediaFileSystemRegistry::GetInstance()-> | 153 std::string device_id = MediaFileSystemRegistry::GetInstance()-> |
| 156 GetDeviceIdFromPath(pictures_path); | 154 GetDeviceIdFromPath(pictures_path); |
| 157 string16 display_name = ComputeDisplayName(pictures_path); | 155 string16 display_name = ComputeDisplayName(pictures_path); |
| 158 AddGallery(device_id, display_name, pictures_path, false /*user added*/); | 156 AddGallery(device_id, display_name, pictures_path, false /*user added*/); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } | 390 } |
| 393 | 391 |
| 394 // static | 392 // static |
| 395 string16 MediaGalleriesPreferences::ComputeDisplayName(const FilePath& path) { | 393 string16 MediaGalleriesPreferences::ComputeDisplayName(const FilePath& path) { |
| 396 // Assumes that path is a directory and not a file. | 394 // Assumes that path is a directory and not a file. |
| 397 return path.BaseName().LossyDisplayName(); | 395 return path.BaseName().LossyDisplayName(); |
| 398 } | 396 } |
| 399 | 397 |
| 400 // static | 398 // static |
| 401 void MediaGalleriesPreferences::RegisterUserPrefs(PrefService* prefs) { | 399 void MediaGalleriesPreferences::RegisterUserPrefs(PrefService* prefs) { |
| 402 if (!UserInteractionIsEnabled()) | |
| 403 return; | |
| 404 | |
| 405 prefs->RegisterListPref(prefs::kMediaGalleriesRememberedGalleries, | 400 prefs->RegisterListPref(prefs::kMediaGalleriesRememberedGalleries, |
| 406 PrefService::UNSYNCABLE_PREF); | 401 PrefService::UNSYNCABLE_PREF); |
| 407 prefs->RegisterUint64Pref(prefs::kMediaGalleriesUniqueId, | 402 prefs->RegisterUint64Pref(prefs::kMediaGalleriesUniqueId, |
| 408 kInvalidMediaGalleryPrefId + 1, | 403 kInvalidMediaGalleryPrefId + 1, |
| 409 PrefService::UNSYNCABLE_PREF); | 404 PrefService::UNSYNCABLE_PREF); |
| 410 } | 405 } |
| 411 | 406 |
| 412 extensions::ExtensionPrefs* | 407 extensions::ExtensionPrefs* |
| 413 MediaGalleriesPreferences::GetExtensionPrefs() const { | 408 MediaGalleriesPreferences::GetExtensionPrefs() const { |
| 414 ExtensionService* extension_service = | 409 ExtensionService* extension_service = |
| 415 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 410 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 416 return extension_service->extension_prefs(); | 411 return extension_service->extension_prefs(); |
| 417 } | 412 } |
| 418 | 413 |
| 419 } // namespace chrome | 414 } // namespace chrome |
| OLD | NEW |