Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chrome/browser/media_gallery/media_galleries_preferences.cc

Issue 10913290: Clean up MediaStorageUtil (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_galleries_preferences_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 }; 148 };
149 149
150 for (size_t i = 0; i < arraysize(kDirectoryKeys); ++i) { 150 for (size_t i = 0; i < arraysize(kDirectoryKeys); ++i) {
151 FilePath path; 151 FilePath path;
152 if (!PathService::Get(kDirectoryKeys[i], &path)) 152 if (!PathService::Get(kDirectoryKeys[i], &path))
153 continue; 153 continue;
154 154
155 std::string device_id; 155 std::string device_id;
156 string16 display_name; 156 string16 display_name;
157 FilePath relative_path; 157 FilePath relative_path;
158 MediaStorageUtil::GetDeviceInfoFromPath( 158 if (MediaStorageUtil::GetDeviceInfoFromPath(path, &device_id, &display_name,
159 path, &device_id, &display_name, &relative_path); 159 &relative_path)) {
160 AddGallery(device_id, display_name, relative_path, false /*user added*/); 160 AddGallery(device_id, display_name, relative_path, false /*user added*/);
161 }
161 } 162 }
162 } 163 }
163 164
164 void MediaGalleriesPreferences::InitFromPrefs() { 165 void MediaGalleriesPreferences::InitFromPrefs() {
165 known_galleries_.clear(); 166 known_galleries_.clear();
166 device_map_.clear(); 167 device_map_.clear();
167 168
168 PrefService* prefs = profile_->GetPrefs(); 169 PrefService* prefs = profile_->GetPrefs();
169 const ListValue* list = prefs->GetList( 170 const ListValue* list = prefs->GetList(
170 prefs::kMediaGalleriesRememberedGalleries); 171 prefs::kMediaGalleriesRememberedGalleries);
(...skipping 12 matching lines...) Expand all
183 } 184 }
184 } 185 }
185 } 186 }
186 187
187 bool MediaGalleriesPreferences::LookUpGalleryByPath( 188 bool MediaGalleriesPreferences::LookUpGalleryByPath(
188 const FilePath& path, 189 const FilePath& path,
189 MediaGalleryPrefInfo* gallery_info) const { 190 MediaGalleryPrefInfo* gallery_info) const {
190 std::string device_id; 191 std::string device_id;
191 string16 device_name; 192 string16 device_name;
192 FilePath relative_path; 193 FilePath relative_path;
193 MediaStorageUtil::GetDeviceInfoFromPath(path, &device_id, &device_name, 194 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &device_id, &device_name,
194 &relative_path); 195 &relative_path)) {
196 if (gallery_info) {
197 gallery_info->pref_id = kInvalidMediaGalleryPrefId;
198 gallery_info->display_name = string16();
199 gallery_info->device_id = std::string();
200 gallery_info->path = FilePath();
201 gallery_info->type = MediaGalleryPrefInfo::kBlackListed;
202 }
203 return false;
204 }
195 relative_path = relative_path.NormalizePathSeparators(); 205 relative_path = relative_path.NormalizePathSeparators();
196 MediaGalleryPrefIdSet galleries_on_device = 206 MediaGalleryPrefIdSet galleries_on_device =
197 LookUpGalleriesByDeviceId(device_id); 207 LookUpGalleriesByDeviceId(device_id);
198 for (MediaGalleryPrefIdSet::const_iterator it = galleries_on_device.begin(); 208 for (MediaGalleryPrefIdSet::const_iterator it = galleries_on_device.begin();
199 it != galleries_on_device.end(); 209 it != galleries_on_device.end();
200 ++it) { 210 ++it) {
201 const MediaGalleryPrefInfo& gallery = known_galleries_.find(*it)->second; 211 const MediaGalleryPrefInfo& gallery = known_galleries_.find(*it)->second;
202 if (gallery.path != relative_path) 212 if (gallery.path != relative_path)
203 continue; 213 continue;
204 214
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 415 }
406 416
407 extensions::ExtensionPrefs* 417 extensions::ExtensionPrefs*
408 MediaGalleriesPreferences::GetExtensionPrefs() const { 418 MediaGalleriesPreferences::GetExtensionPrefs() const {
409 ExtensionService* extension_service = 419 ExtensionService* extension_service =
410 extensions::ExtensionSystem::Get(profile_)->extension_service(); 420 extensions::ExtensionSystem::Get(profile_)->extension_service();
411 return extension_service->extension_prefs(); 421 return extension_service->extension_prefs();
412 } 422 }
413 423
414 } // namespace chrome 424 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_galleries_preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698