Index: chrome/browser/media_gallery/media_file_system_registry.cc |
=================================================================== |
--- chrome/browser/media_gallery/media_file_system_registry.cc (revision 173002) |
+++ chrome/browser/media_gallery/media_file_system_registry.cc (working copy) |
@@ -278,9 +278,7 @@ |
DCHECK(!fsid.empty()); |
MediaFileSystemInfo new_entry( |
- MakeJSONFileSystemName(gallery_info.display_name, |
- pref_id, |
- device_id), |
+ MakeJSONFileSystemName(gallery_info, pref_id, device_id), |
path, |
fsid); |
result.push_back(new_entry); |
@@ -306,9 +304,10 @@ |
return registry->GetTransientIdForDeviceId(device_id); |
} |
- // Make a JSON string out of |name|, |pref_id| and |device_id|. The IDs makes |
- // the combined name unique. The JSON string should not contain any slashes. |
- std::string MakeJSONFileSystemName(const string16& name, |
+ // Make a JSON string out of |gallery_info|, |pref_id| and |device_id|. |
+ // The IDs makes the combined name unique. |
+ // The JSON string should not contain any slashes. |
+ std::string MakeJSONFileSystemName(const MediaGalleryPrefInfo& gallery_info, |
const MediaGalleryPrefId& pref_id, |
const std::string& device_id) { |
string16 sanitized_name; |
@@ -319,20 +318,31 @@ |
ASCIIToUTF16(FilePath::kSeparators) |
#endif |
; // NOLINT |
+ const string16& name = gallery_info.display_name; |
ReplaceChars(name, separators.c_str(), ASCIIToUTF16("_"), &sanitized_name); |
base::DictionaryValue dict_value; |
- dict_value.SetStringWithoutPathExpansion("name", sanitized_name); |
+ dict_value.SetStringWithoutPathExpansion( |
+ MediaFileSystemRegistry::kNameKey, sanitized_name); |
// This should have been a StringValue, but it's a bit late to change it. |
- dict_value.SetIntegerWithoutPathExpansion("galleryId", pref_id); |
+ dict_value.SetIntegerWithoutPathExpansion( |
+ MediaFileSystemRegistry::kGalleryIdKey, pref_id); |
// |device_id| can be empty, in which case, just omit it. |
std::string transient_device_id = |
GetTransientIdForRemovableDeviceId(device_id); |
- if (!transient_device_id.empty()) |
- dict_value.SetStringWithoutPathExpansion("deviceId", transient_device_id); |
+ if (!transient_device_id.empty()) { |
+ dict_value.SetStringWithoutPathExpansion( |
+ MediaFileSystemRegistry::kDeviceIdKey, transient_device_id); |
+ } |
+ DCHECK(gallery_info.type == MediaGalleryPrefInfo::kAutoDetected || |
+ gallery_info.type == MediaGalleryPrefInfo::kUserAdded); |
+ dict_value.SetBooleanWithoutPathExpansion( |
+ MediaFileSystemRegistry::kUserAddedKey, |
+ gallery_info.type == MediaGalleryPrefInfo::kUserAdded); |
+ |
std::string json_string; |
base::JSONWriter::Write(&dict_value, &json_string); |
return json_string; |
@@ -423,6 +433,11 @@ |
* Public methods |
******************/ |
+const char MediaFileSystemRegistry::kDeviceIdKey[] = "deviceId"; |
+const char MediaFileSystemRegistry::kGalleryIdKey[] = "galleryId"; |
+const char MediaFileSystemRegistry::kNameKey[] = "name"; |
+const char MediaFileSystemRegistry::kUserAddedKey[] = "userAdded"; |
+ |
void MediaFileSystemRegistry::GetMediaFileSystemsForExtension( |
const content::RenderViewHost* rvh, |
const extensions::Extension* extension, |
@@ -698,10 +713,13 @@ |
mtp_device_delegate_map_.find(device_location); |
if (delegate_it != mtp_device_delegate_map_.end()) |
return delegate_it->second; |
- ScopedMTPDeviceMapEntry* mtp_device_host = new ScopedMTPDeviceMapEntry( |
- device_location, base::Bind( |
- &MediaFileSystemRegistry::RemoveScopedMTPDeviceMapEntry, |
- base::Unretained(this), device_location)); |
+ ScopedMTPDeviceMapEntry* mtp_device_host = |
+ new ScopedMTPDeviceMapEntry( |
+ device_location, |
+ base::Bind( |
+ &MediaFileSystemRegistry::RemoveScopedMTPDeviceMapEntry, |
+ base::Unretained(this), |
+ device_location)); |
mtp_device_delegate_map_[device_location] = mtp_device_host; |
return mtp_device_host; |
} |