diff options
author | sidor@chromium.org <sidor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-24 08:10:46 +0000 |
---|---|---|
committer | sidor@chromium.org <sidor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-24 08:10:46 +0000 |
commit | 3b6190fc87f8c40bdd553d0cbf607bbf596f9278 (patch) | |
tree | efb62bc0535a554b64e6fd4a8c03cf81767e2b96 | |
parent | c866f5d328386101f7f884375ce1d7f63d45bc64 (diff) | |
download | chromium_src-3b6190fc87f8c40bdd553d0cbf607bbf596f9278.zip chromium_src-3b6190fc87f8c40bdd553d0cbf607bbf596f9278.tar.gz chromium_src-3b6190fc87f8c40bdd553d0cbf607bbf596f9278.tar.bz2 |
Formatting error fix.
BUG=None.
TEST=Try to format read-only device and see if error appears
Review URL: http://codereview.chromium.org/7719017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98010 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 35 insertions, 21 deletions
diff --git a/chrome/browser/chromeos/cros/mount_library.cc b/chrome/browser/chromeos/cros/mount_library.cc index 6fcbdb0..952f1dd 100644 --- a/chrome/browser/chromeos/cros/mount_library.cc +++ b/chrome/browser/chromeos/cros/mount_library.cc @@ -728,10 +728,16 @@ class MountLibraryImpl : public MountLibrary { } const char* FilePathToDevicePath(const char* file_path) { + int failed = (file_path[0] == '!') ? 1 : 0; for (MountLibrary::DiskMap::iterator it = disks_.begin(); it != disks_.end(); ++it) { - if (it->second->file_path().compare(file_path) == 0) - return it->second->device_path().c_str(); + if (it->second->file_path().compare(file_path + failed) == 0) { + if (failed) { + return (std::string("!") + it->second->device_path()).c_str(); + } else { + return it->second->device_path().c_str(); + } + } } return NULL; } diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc index a9084fd..b33912f 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc @@ -182,9 +182,17 @@ void ExtensionFileBrowserEventRouter::DeviceChanged( } else if (event == chromeos::MOUNT_DEVICE_SCANNED) { OnDeviceScanned(device_path); } else if (event == chromeos::MOUNT_FORMATTING_STARTED) { - OnFormattingStarted(device_path); + if (device_path[0] == '!') { + OnFormattingStarted(device_path.substr(1), false); + } else { + OnFormattingStarted(device_path, true); + } } else if (event == chromeos::MOUNT_FORMATTING_FINISHED) { - OnFormattingFinished(device_path); + if (device_path[0] == '!') { + OnFormattingFinished(device_path.substr(1), false); + } else { + OnFormattingFinished(device_path, true); + } } } void ExtensionFileBrowserEventRouter::MountCompleted( @@ -421,28 +429,22 @@ void ExtensionFileBrowserEventRouter::OnDeviceScanned( } void ExtensionFileBrowserEventRouter::OnFormattingStarted( - const std::string& device_path) { - if (device_path[0] == '!') { - ShowFileBrowserNotification("FORMAT_FINISHED", device_path.substr(1), - IDR_PAGEINFO_WARNING_MAJOR, - l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_FINISHED_TITLE), - l10n_util::GetStringUTF16(IDS_FORMATTING_STARTED_FAILURE_MESSAGE)); - } else { + const std::string& device_path, bool success) { + if (success) { ShowFileBrowserNotification("FORMAT", device_path, IDR_PAGEINFO_INFO, l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_PENDING_TITLE), l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_PENDING_MESSAGE)); + } else { + ShowFileBrowserNotification("FORMAT_FINISHED", device_path, + IDR_PAGEINFO_WARNING_MAJOR, + l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_FINISHED_TITLE), + l10n_util::GetStringUTF16(IDS_FORMATTING_STARTED_FAILURE_MESSAGE)); } } void ExtensionFileBrowserEventRouter::OnFormattingFinished( - const std::string& device_path) { - if (device_path[0] == '!') { - HideFileBrowserNotification("FORMAT", device_path.substr(1)); - ShowFileBrowserNotification("FORMAT_FINISHED", device_path.substr(1), - IDR_PAGEINFO_WARNING_MAJOR, - l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_FINISHED_TITLE), - l10n_util::GetStringUTF16(IDS_FORMATTING_FINISHED_FAILURE_MESSAGE)); - } else { + const std::string& device_path, bool success) { + if (success) { HideFileBrowserNotification("FORMAT", device_path); ShowFileBrowserNotification("FORMAT_FINISHED", device_path, IDR_PAGEINFO_INFO, @@ -459,6 +461,12 @@ void ExtensionFileBrowserEventRouter::OnFormattingFinished( lib->MountPath(device_path.c_str(), chromeos::MOUNT_TYPE_DEVICE, chromeos::MountPathOptions()); // Unused. + } else { + HideFileBrowserNotification("FORMAT", device_path); + ShowFileBrowserNotification("FORMAT_FINISHED", device_path, + IDR_PAGEINFO_WARNING_MAJOR, + l10n_util::GetStringUTF16(IDS_FORMATTING_OF_DEVICE_FINISHED_TITLE), + l10n_util::GetStringUTF16(IDS_FORMATTING_FINISHED_FAILURE_MESSAGE)); } } diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.h b/chrome/browser/chromeos/extensions/file_browser_event_router.h index cbb0cd7..86058db 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.h +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.h @@ -97,8 +97,8 @@ class ExtensionFileBrowserEventRouter void OnDeviceAdded(const std::string& device_path); void OnDeviceRemoved(const std::string& device_path); void OnDeviceScanned(const std::string& device_path); - void OnFormattingStarted(const std::string& device_path); - void OnFormattingFinished(const std::string& device_path); + void OnFormattingStarted(const std::string& device_path, bool success); + void OnFormattingFinished(const std::string& device_path, bool success); // Finds first notifications corresponding to the same device. Ensures that // we don't pop up multiple notifications for the same device. |