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

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

Issue 10911234: Update Windows System Monitor Removable Device Impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Win compile 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
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 : profile_(profile) { 130 : profile_(profile) {
131 // Populate the default galleries if this is a fresh profile. 131 // Populate the default galleries if this is a fresh profile.
132 MediaGalleryPrefId current_id = 132 MediaGalleryPrefId current_id =
133 profile_->GetPrefs()->GetUint64(prefs::kMediaGalleriesUniqueId); 133 profile_->GetPrefs()->GetUint64(prefs::kMediaGalleriesUniqueId);
134 if (current_id == kInvalidMediaGalleryPrefId + 1) { 134 if (current_id == kInvalidMediaGalleryPrefId + 1) {
135 FilePath pictures_path; 135 FilePath pictures_path;
136 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path)) { 136 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path)) {
137 std::string device_id; 137 std::string device_id;
138 string16 display_name; 138 string16 display_name;
139 FilePath relative_path; 139 FilePath relative_path;
140 MediaStorageUtil::GetDeviceInfoFromPath(pictures_path, &device_id, 140 if (MediaStorageUtil::GetDeviceInfoFromPath(pictures_path, &device_id,
141 &display_name, &relative_path); 141 &display_name,
142 AddGallery(device_id, display_name, relative_path, false /*user added*/); 142 &relative_path)) {
143 AddGallery(device_id, display_name, relative_path,
144 false /*user added*/);
145 }
143 } 146 }
144 } 147 }
145 InitFromPrefs(); 148 InitFromPrefs();
146 } 149 }
147 150
148 MediaGalleriesPreferences::~MediaGalleriesPreferences() {} 151 MediaGalleriesPreferences::~MediaGalleriesPreferences() {}
149 152
150 void MediaGalleriesPreferences::InitFromPrefs() { 153 void MediaGalleriesPreferences::InitFromPrefs() {
151 known_galleries_.clear(); 154 known_galleries_.clear();
152 device_map_.clear(); 155 device_map_.clear();
(...skipping 15 matching lines...) Expand all
168 device_map_[gallery_info.device_id].insert(gallery_info.pref_id); 171 device_map_[gallery_info.device_id].insert(gallery_info.pref_id);
169 } 172 }
170 } 173 }
171 174
172 bool MediaGalleriesPreferences::LookUpGalleryByPath( 175 bool MediaGalleriesPreferences::LookUpGalleryByPath(
173 const FilePath& path, 176 const FilePath& path,
174 MediaGalleryPrefInfo* gallery_info) const { 177 MediaGalleryPrefInfo* gallery_info) const {
175 std::string device_id; 178 std::string device_id;
176 string16 device_name; 179 string16 device_name;
177 FilePath relative_path; 180 FilePath relative_path;
178 MediaStorageUtil::GetDeviceInfoFromPath(path, &device_id, &device_name, 181 if (!MediaStorageUtil::GetDeviceInfoFromPath(path, &device_id, &device_name,
179 &relative_path); 182 &relative_path)) {
183 if (gallery_info) {
184 gallery_info->pref_id = kInvalidMediaGalleryPrefId;
185 gallery_info->display_name = string16();
186 gallery_info->device_id = std::string();
187 gallery_info->path = FilePath();
188 gallery_info->type = MediaGalleryPrefInfo::kBlackListed;
189 }
190 return false;
191 }
180 relative_path = relative_path.NormalizePathSeparators(); 192 relative_path = relative_path.NormalizePathSeparators();
181 MediaGalleryPrefIdSet galleries_on_device = 193 MediaGalleryPrefIdSet galleries_on_device =
182 LookUpGalleriesByDeviceId(device_id); 194 LookUpGalleriesByDeviceId(device_id);
183 for (MediaGalleryPrefIdSet::const_iterator it = galleries_on_device.begin(); 195 for (MediaGalleryPrefIdSet::const_iterator it = galleries_on_device.begin();
184 it != galleries_on_device.end(); 196 it != galleries_on_device.end();
185 ++it) { 197 ++it) {
186 const MediaGalleryPrefInfo& gallery = known_galleries_.find(*it)->second; 198 const MediaGalleryPrefInfo& gallery = known_galleries_.find(*it)->second;
187 if (gallery.path != relative_path) 199 if (gallery.path != relative_path)
188 continue; 200 continue;
189 201
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 402 }
391 403
392 extensions::ExtensionPrefs* 404 extensions::ExtensionPrefs*
393 MediaGalleriesPreferences::GetExtensionPrefs() const { 405 MediaGalleriesPreferences::GetExtensionPrefs() const {
394 ExtensionService* extension_service = 406 ExtensionService* extension_service =
395 extensions::ExtensionSystem::Get(profile_)->extension_service(); 407 extensions::ExtensionSystem::Get(profile_)->extension_service();
396 return extension_service->extension_prefs(); 408 return extension_service->extension_prefs();
397 } 409 }
398 410
399 } // namespace chrome 411 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698