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

Unified Diff: chrome/browser/media_galleries/media_galleries_preferences.cc

Issue 19489006: Media Galleries: Move gallery name generation back to StorageMonitor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 7 years, 4 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
Index: chrome/browser/media_galleries/media_galleries_preferences.cc
===================================================================
--- chrome/browser/media_galleries/media_galleries_preferences.cc (revision 218837)
+++ chrome/browser/media_galleries/media_galleries_preferences.cc (working copy)
@@ -33,7 +33,6 @@
#include "components/user_prefs/pref_registry_syncable.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/text/bytes_formatting.h"
using base::DictionaryValue;
using base::ListValue;
@@ -221,13 +220,6 @@
return false;
}
-string16 GetDisplayNameForDevice(uint64 storage_size_in_bytes,
- const string16& name) {
- DCHECK(!name.empty());
- return (storage_size_in_bytes == 0) ?
- name : ui::FormatBytes(storage_size_in_bytes) + ASCIIToUTF16(" ") + name;
-}
-
// For a device with |device_name| and a relative path |sub_folder|, construct
// a display name. If |sub_folder| is empty, then just return |device_name|.
string16 GetDisplayNameForSubFolder(const string16& device_name,
@@ -235,26 +227,10 @@
if (sub_folder.empty())
return device_name;
return (sub_folder.BaseName().LossyDisplayName() +
- ASCIIToUTF16(" - ") +
+ base::ASCIIToUTF16(" - ") +
device_name);
}
-string16 GetFullProductName(const string16& vendor_name,
- const string16& model_name) {
- if (vendor_name.empty() && model_name.empty())
- return string16();
-
- string16 product_name;
- if (vendor_name.empty())
- product_name = model_name;
- else if (model_name.empty())
- product_name = vendor_name;
- else if (!vendor_name.empty() && !model_name.empty())
- product_name = vendor_name + UTF8ToUTF16(", ") + model_name;
-
- return product_name;
-}
-
} // namespace
MediaGalleryPrefInfo::MediaGalleryPrefInfo()
@@ -279,28 +255,19 @@
// of a root directory, the root directory name.
// TODO(gbillock): Using only the BaseName can lead to ambiguity. The
// tooltip resolves it. Is that enough?
- base::FilePath path = AbsolutePath();
+ base::FilePath abspath = AbsolutePath();
if (!display_name.empty())
return display_name;
- if (path == path.DirName())
- return path.LossyDisplayName();
- return path.BaseName().LossyDisplayName();
+ if (abspath == abspath.DirName())
+ return abspath.LossyDisplayName();
+ return abspath.BaseName().LossyDisplayName();
}
- string16 name = display_name;
- if (name.empty())
- name = volume_label;
- if (name.empty())
- name = GetFullProductName(vendor_name, model_name);
- if (name.empty())
- name = l10n_util::GetStringUTF16(IDS_MEDIA_GALLERIES_UNLABELED_DEVICE);
-
- name = GetDisplayNameForDevice(total_size_in_bytes, name);
-
- if (!path.empty())
- name = GetDisplayNameForSubFolder(name, path);
-
- return name;
+ StorageInfo info(device_id,
+ MediaStorageUtil::FindDevicePathById(device_id).value(),
+ volume_label, vendor_name, model_name, total_size_in_bytes);
+ base::string16 name = info.GetDisplayNameWithOverride(display_name, true);
+ return GetDisplayNameForSubFolder(name, path);
}
string16 MediaGalleryPrefInfo::GetGalleryTooltip() const {
@@ -381,8 +348,8 @@
base::FilePath relative_path;
StorageInfo info;
if (MediaStorageUtil::GetDeviceInfoFromPath(path, &info, &relative_path)) {
- AddGalleryInternal(info.device_id(), info.name(), relative_path, false,
- info.storage_label(), info.vendor_name(),
+ AddGalleryInternal(info.device_id(), base::string16(), relative_path,
+ false, info.storage_label(), info.vendor_name(),
info.model_name(), info.total_size_in_bytes(),
base::Time(), true, 2);
}

Powered by Google App Engine
This is Rietveld 408576698