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

Unified Diff: chrome/browser/chromeos/file_manager/volume_manager.cc

Issue 289443002: Files.app+MTP: Simply show the device model name as a label of the volume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/file_manager/volume_manager.cc
diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc
index 636138957595ff3cafc7b4445918e23bdbc759da..1d3ea1e5287cb38f475aa892557f03a689a0a25e 100644
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc
@@ -13,6 +13,7 @@
#include "base/memory/singleton.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_errors.h"
@@ -44,6 +45,7 @@ namespace {
const bool kNotRemounting = false;
const char kFileManagerMTPMountNamePrefix[] = "fileman-mtp-";
+const char kMtpVolumeIdPrefix [] = "mtp:";
// Registers |path| as the "Downloads" folder to the FileSystem API backend.
// If another folder is already mounted. It revokes and overrides the old one.
@@ -721,7 +723,12 @@ void VolumeManager::OnRemovableStorageAttached(
const base::FilePath path = base::FilePath::FromUTF8Unsafe(info.location());
const std::string fsid = GetMountPointNameForMediaStorage(info);
- const std::string name = base::UTF16ToUTF8(info.GetDisplayName(false));
+ const std::string base_name = base::UTF16ToUTF8(info.model_name());
+
+ // Assign a fresh volume ID based on the volume name.
+ std::string id = kMtpVolumeIdPrefix + base_name;
+ for (int i = 2; mounted_volumes_.count(id); ++i)
+ id = kMtpVolumeIdPrefix + base_name + base::StringPrintf(" (%d)", i);
bool result =
fileapi::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
@@ -740,7 +747,7 @@ void VolumeManager::OnRemovableStorageAttached(
volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE;
volume_info.is_parent = true;
volume_info.is_read_only = true;
- volume_info.volume_id = "mtp:" + name;
+ volume_info.volume_id = id;
volume_info.source_path = path;
volume_info.device_type = chromeos::DEVICE_TYPE_MOBILE;
DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, false);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698