diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-24 00:15:50 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-24 00:15:50 +0000 |
commit | 4d5843ce942b8df8d5b098a431aee5ba87aca6ac (patch) | |
tree | d680365932ce62eafc04eea385d81e452dc9f137 | |
parent | fe098abb2738d1abdc089d080343626cc276bab7 (diff) | |
download | chromium_src-4d5843ce942b8df8d5b098a431aee5ba87aca6ac.zip chromium_src-4d5843ce942b8df8d5b098a431aee5ba87aca6ac.tar.gz chromium_src-4d5843ce942b8df8d5b098a431aee5ba87aca6ac.tar.bz2 |
Revert 93813 - Re-landing for tbarzic@ - r93754:
Adding support for mount point different from removable devices to MountLibrary
(work in progress..have to add GetMountPoints support)
tested on ChromeOS with these three patches: http://gerrit.chromium.org/gerrit/#change,4447
http://gerrit.chromium.org/gerrit/#change,4449
http://gerrit.chromium.org/gerrit/#change,4544
BUG=chromium-os:17673,chromium-os:17783
TEST=Made sure mounting devices still works and that
MountCompleted event gets through to
file_browser_event_router (checking ui and chrome logs
for mount completed entries)
TBR=tbarzic
Review URL: http://codereview.chromium.org/7492038
TBR=zelidrag@chromium.org
Review URL: http://codereview.chromium.org/7488043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93815 0039d316-1c4b-4281-b951-d872f2087c98
15 files changed, 92 insertions, 525 deletions
diff --git a/chrome/browser/chromeos/cros/mock_mount_library.cc b/chrome/browser/chromeos/cros/mock_mount_library.cc index eca06db..3e826a3 100644 --- a/chrome/browser/chromeos/cros/mock_mount_library.cc +++ b/chrome/browser/chromeos/cros/mock_mount_library.cc @@ -40,8 +40,6 @@ MockMountLibrary::MockMountLibrary() { .WillByDefault(Invoke(this, &MockMountLibrary::RemoveObserverInternal)); ON_CALL(*this, disks()) .WillByDefault(Invoke(this, &MockMountLibrary::disksInternal)); - ON_CALL(*this, mount_points()) - .WillByDefault(Invoke(this, &MockMountLibrary::mountPointsInternal)); } MockMountLibrary::~MockMountLibrary() { @@ -130,7 +128,7 @@ void MockMountLibrary::SetupDefaultReplies() { .WillRepeatedly(ReturnRef(disks_)); EXPECT_CALL(*this, RequestMountInfoRefresh()) .Times(AnyNumber()); - EXPECT_CALL(*this, MountPath(_, _, _)) + EXPECT_CALL(*this, MountPath(_)) .Times(AnyNumber()); EXPECT_CALL(*this, UnmountPath(_)) .Times(AnyNumber()); diff --git a/chrome/browser/chromeos/cros/mock_mount_library.h b/chrome/browser/chromeos/cros/mock_mount_library.h index 34d06e4..c648569 100644 --- a/chrome/browser/chromeos/cros/mock_mount_library.h +++ b/chrome/browser/chromeos/cros/mock_mount_library.h @@ -25,15 +25,9 @@ class MockMountLibrary : public MountLibrary { MOCK_METHOD1(AddObserver, void(MountLibrary::Observer*)); MOCK_METHOD1(RemoveObserver, void(MountLibrary::Observer*)); MOCK_CONST_METHOD0(disks, const MountLibrary::DiskMap&(void)); - MOCK_CONST_METHOD0(mount_points, const MountLibrary::MountPointMap&(void)); - - MOCK_CONST_METHOD1(MountTypeToString, std::string(MountType)); - MOCK_CONST_METHOD1(MountTypeFromString, MountType(const std::string&)); MOCK_METHOD0(RequestMountInfoRefresh, void(void)); - MOCK_METHOD3(MountPath, void(const char*, - MountType, - const MountPathOptions&)); + MOCK_METHOD1(MountPath, void(const char*)); MOCK_METHOD1(UnmountPath, void(const char*)); MOCK_METHOD3(UnmountDeviceRecursive, void(const char*, MountLibrary::UnmountDeviceRecursiveCallbackType, void*)); @@ -47,9 +41,6 @@ class MockMountLibrary : public MountLibrary { void AddObserverInternal(MountLibrary::Observer* observer); void RemoveObserverInternal(MountLibrary::Observer* observer); const MountLibrary::DiskMap& disksInternal() const { return disks_; } - const MountLibrary::MountPointMap& mountPointsInternal() const { - return mount_points_; - } void UpdateDeviceChanged(MountLibraryEventType evt, @@ -61,7 +52,6 @@ class MockMountLibrary : public MountLibrary { // The list of disks found. MountLibrary::DiskMap disks_; - MountLibrary::MountPointMap mount_points_; DISALLOW_COPY_AND_ASSIGN(MockMountLibrary); }; diff --git a/chrome/browser/chromeos/cros/mount_library.cc b/chrome/browser/chromeos/cros/mount_library.cc index 17f6583..79e723a 100644 --- a/chrome/browser/chromeos/cros/mount_library.cc +++ b/chrome/browser/chromeos/cros/mount_library.cc @@ -90,56 +90,31 @@ class MountLibraryImpl : public MountLibrary { observers_.RemoveObserver(observer); } - virtual std::string MountTypeToString(MountType type) const OVERRIDE { - switch (type) { - case MOUNT_TYPE_DEVICE: - return "device"; - case MOUNT_TYPE_ARCHIVE: - return "file"; - case MOUNT_TYPE_NETWORK_STORAGE: - return "network"; - case MOUNT_TYPE_INVALID: - return "invalid"; - default: - NOTREACHED(); - } - return ""; - } - - virtual MountType MountTypeFromString(const std::string& type_str) const - OVERRIDE { - if (type_str == "device") { - return MOUNT_TYPE_DEVICE; - } else if (type_str == "network") { - return MOUNT_TYPE_NETWORK_STORAGE; - } else if (type_str == "file") { - return MOUNT_TYPE_ARCHIVE; - } else { - return MOUNT_TYPE_INVALID; - } - } - - virtual void MountPath(const char* source_path, - MountType type, - const MountPathOptions& options) OVERRIDE { + virtual void MountPath(const char* device_path) OVERRIDE { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!CrosLibrary::Get()->EnsureLoaded()) { - OnMountCompleted(MOUNT_ERROR_LIBRARY_NOT_LOADED, - MountPointInfo(source_path, NULL, type)); + OnMountRemovableDevice(device_path, + NULL, + MOUNT_METHOD_ERROR_LOCAL, + kLibraryNotLoaded); return; } - MountSourcePath(source_path, type, options, &MountCompletedHandler, this); + MountRemovableDevice(device_path, + &MountLibraryImpl::MountRemovableDeviceCallback, + this); } - virtual void UnmountPath(const char* path) OVERRIDE { + virtual void UnmountPath(const char* device_path) OVERRIDE { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!CrosLibrary::Get()->EnsureLoaded()) { - OnUnmountPath(path, - MOUNT_METHOD_ERROR_LOCAL, - kLibraryNotLoaded); + OnUnmountRemovableDevice(device_path, + MOUNT_METHOD_ERROR_LOCAL, + kLibraryNotLoaded); return; } - UnmountMountPoint(path, &MountLibraryImpl::UnmountMountPointCallback, this); + UnmountRemovableDevice(device_path, + &MountLibraryImpl::UnmountRemovableDeviceCallback, + this); } virtual void UnmountDeviceRecursive(const char* device_path, @@ -176,10 +151,9 @@ class MountLibraryImpl : public MountLibrary { cb_data = new UnmountDeviceRecursiveCallbackData(this, user_data, callback, devices_to_unmount.size()); for (std::vector<const char*>::iterator it = devices_to_unmount.begin(); - it != devices_to_unmount.end(); - ++it) { - UnmountMountPoint( - *it, + it != devices_to_unmount.end(); + ++it) { + UnmountRemovableDevice(*it, &MountLibraryImpl::UnmountDeviceRecursiveCallback, cb_data); } @@ -204,34 +178,39 @@ class MountLibraryImpl : public MountLibrary { } const DiskMap& disks() const OVERRIDE { return disks_; } - const MountPointMap& mount_points() const OVERRIDE { return mount_points_; } private: - // Callback for MountComplete signal and MountSourcePath method. - static void MountCompletedHandler(void* object, - MountError error_code, - const char* source_path, - MountType type, - const char* mount_path) { + // Callback for MountRemovableDevice method. + static void MountRemovableDeviceCallback(void* object, + const char* device_path, + const char* mount_path, + MountMethodErrorType error, + const char* error_message) { DCHECK(object); MountLibraryImpl* self = static_cast<MountLibraryImpl*>(object); - self->OnMountCompleted(static_cast<MountError>(error_code), - MountPointInfo(source_path, mount_path, type)); + self->OnMountRemovableDevice(device_path, + mount_path, + error, + error_message); } // Callback for UnmountRemovableDevice method. - static void UnmountMountPointCallback(void* object, - const char* device_path, - MountMethodErrorType error, - const char* error_message) { + static void UnmountRemovableDeviceCallback(void* object, + const char* device_path, + const char* mount_path, + MountMethodErrorType error, + const char* error_message) { DCHECK(object); MountLibraryImpl* self = static_cast<MountLibraryImpl*>(object); - self->OnUnmountPath(device_path, error, error_message); + self->OnUnmountRemovableDevice(device_path, + error, + error_message); } // Callback for UnmountDeviceRecursive. static void UnmountDeviceRecursiveCallback(void* object, const char* device_path, + const char* mount_path, MountMethodErrorType error, const char* error_message) { DCHECK(object); @@ -239,9 +218,9 @@ class MountLibraryImpl : public MountLibrary { static_cast<UnmountDeviceRecursiveCallbackData*>(object); // Do standard processing for Unmount event. - cb_data->object->OnUnmountPath(device_path, - error, - error_message); + cb_data->object->OnUnmountRemovableDevice(device_path, + error, + error_message); if (error == MOUNT_METHOD_ERROR_LOCAL) { cb_data->success = false; } else if (error == MOUNT_METHOD_ERROR_NONE) { @@ -296,26 +275,14 @@ class MountLibraryImpl : public MountLibrary { } - void OnMountCompleted(MountError error_code, - const MountPointInfo& mount_info) { - DCHECK(!mount_info.source_path.empty()); - - FireMountCompleted(MOUNTING, - error_code, - mount_info); - - if (error_code == MOUNT_ERROR_NONE && - mount_points_.find(mount_info.source_path) == mount_points_.end()) { - mount_points_.insert(MountPointMap::value_type( - mount_info.source_path.c_str(), - mount_info)); - } + void OnMountRemovableDevice(const char* device_path, + const char* mount_path, + MountMethodErrorType error, + const char* error_message) { + DCHECK(device_path); - if (error_code == MOUNT_ERROR_NONE && - mount_info.mount_type == MOUNT_TYPE_DEVICE && - !mount_info.source_path.empty() && - !mount_info.mount_path.empty()) { - std::string path(mount_info.source_path); + if (error == MOUNT_METHOD_ERROR_NONE && device_path && mount_path) { + std::string path(device_path); DiskMap::iterator iter = disks_.find(path); if (iter == disks_.end()) { // disk might have been removed by now? @@ -323,30 +290,21 @@ class MountLibraryImpl : public MountLibrary { } Disk* disk = iter->second; DCHECK(disk); - disk->set_mount_path(mount_info.mount_path.c_str()); + disk->set_mount_path(mount_path); FireDiskStatusUpdate(MOUNT_DISK_MOUNTED, disk); + } else { + LOG(WARNING) << "Mount request failed for device " + << device_path << ", with error: " + << (error_message ? error_message : "Unknown"); } } - void OnUnmountPath(const char* source_path, - MountMethodErrorType error, - const char* error_message) { - DCHECK(source_path); - - if (error == MOUNT_METHOD_ERROR_NONE && source_path) { - MountPointMap::iterator mount_points_it = mount_points_.find(source_path); - if (mount_points_it == mount_points_.end()) - return; - // TODO(tbarzic): Add separate, PathUnmounted event to Observer. - FireMountCompleted( - UNMOUNTING, - MOUNT_ERROR_NONE, - MountPointInfo(mount_points_it->second.source_path.c_str(), - mount_points_it->second.mount_path.c_str(), - mount_points_it->second.mount_type)); - mount_points_.erase(mount_points_it); - - std::string path(source_path); + void OnUnmountRemovableDevice(const char* device_path, + MountMethodErrorType error, + const char* error_message) { + DCHECK(device_path); + if (error == MOUNT_METHOD_ERROR_NONE && device_path) { + std::string path(device_path); DiskMap::iterator iter = disks_.find(path); if (iter == disks_.end()) { // disk might have been removed by now? @@ -358,7 +316,7 @@ class MountLibraryImpl : public MountLibrary { FireDiskStatusUpdate(MOUNT_DISK_UNMOUNTED, disk); } else { LOG(WARNING) << "Unmount request failed for device " - << source_path << ", with error: " + << device_path << ", with error: " << (error_message ? error_message : "Unknown"); } } @@ -518,17 +476,16 @@ class MountLibraryImpl : public MountLibrary { type = MOUNT_DEVICE_SCANNED; break; } - default: { + default: return; - } } FireDeviceStatusUpdate(type, std::string(device_path)); } void Init() { // Getting the monitor status so that the daemon starts up. - mount_status_connection_ = MonitorAllMountEvents( - &MonitorMountEventsHandler, &MountCompletedHandler, this); + mount_status_connection_ = MonitorMountEvents( + &MonitorMountEventsHandler, this); } void FireDiskStatusUpdate(MountLibraryEventType evt, @@ -547,17 +504,6 @@ class MountLibraryImpl : public MountLibrary { Observer, observers_, DeviceChanged(evt, device_path)); } - void FireMountCompleted(MountEvent event_type, - MountError error_code, - const MountPointInfo& mount_info) { - // Make sure we run on UI thread. - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - FOR_EACH_OBSERVER( - Observer, observers_, MountCompleted(event_type, - error_code, - mount_info)); - } - // Mount event change observers. ObserverList<Observer> observers_; @@ -568,8 +514,6 @@ class MountLibraryImpl : public MountLibrary { // The list of disks found. MountLibrary::DiskMap disks_; - MountLibrary::MountPointMap mount_points_; - DISALLOW_COPY_AND_ASSIGN(MountLibraryImpl); }; @@ -582,20 +526,9 @@ class MountLibraryStubImpl : public MountLibrary { virtual void AddObserver(Observer* observer) OVERRIDE {} virtual void RemoveObserver(Observer* observer) OVERRIDE {} virtual const DiskMap& disks() const OVERRIDE { return disks_; } - virtual const MountPointMap& mount_points() const OVERRIDE { - return mount_points_; - } - virtual std::string MountTypeToString(MountType type) const OVERRIDE { - return ""; - } - virtual MountType MountTypeFromString(const std::string& type_str) const - OVERRIDE { - return MOUNT_TYPE_INVALID; - } virtual void RequestMountInfoRefresh() OVERRIDE {} - virtual void MountPath(const char* source_path, MountType type, - const MountPathOptions& options) OVERRIDE {} - virtual void UnmountPath(const char* path) OVERRIDE {} + virtual void MountPath(const char* device_path) OVERRIDE {} + virtual void UnmountPath(const char* device_path) OVERRIDE {} virtual void UnmountDeviceRecursive(const char* device_path, UnmountDeviceRecursiveCallbackType callback, void* user_data) OVERRIDE {} @@ -603,7 +536,6 @@ class MountLibraryStubImpl : public MountLibrary { private: // The list of disks found. DiskMap disks_; - MountPointMap mount_points_; DISALLOW_COPY_AND_ASSIGN(MountLibraryStubImpl); }; diff --git a/chrome/browser/chromeos/cros/mount_library.h b/chrome/browser/chromeos/cros/mount_library.h index c6dc15e..b735d3d 100644 --- a/chrome/browser/chromeos/cros/mount_library.h +++ b/chrome/browser/chromeos/cros/mount_library.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ #pragma once -#include <map> #include <string> +#include <map> #include "base/memory/singleton.h" #include "base/observer_list.h" @@ -32,10 +32,6 @@ typedef enum MountLibraryEventType { // library class like this: chromeos::CrosLibrary::Get()->GetMountLibrary() class MountLibrary { public: - enum MountEvent { - MOUNTING, - UNMOUNTING - }; // Used to house an instance of each found mount device. class Disk { public: @@ -101,22 +97,6 @@ class MountLibrary { }; typedef std::map<std::string, Disk*> DiskMap; - // MountPointInfo: {mount_path, mount_type}. - struct MountPointInfo { - std::string source_path; - std::string mount_path; - MountType mount_type; - - MountPointInfo(const char* source, const char* mount, const MountType type) - : source_path(source ? source : ""), - mount_path(mount ? mount : ""), - mount_type(type) { - } - }; - - // MountPointMap key is source_path. - typedef std::map<std::string, MountPointInfo> MountPointMap; - typedef void(*UnmountDeviceRecursiveCallbackType)(void*, bool); class Observer { @@ -127,26 +107,16 @@ class MountLibrary { const Disk* disk) = 0; virtual void DeviceChanged(MountLibraryEventType event, const std::string& device_path ) = 0; - virtual void MountCompleted(MountEvent event_type, - MountError error_code, - const MountPointInfo& mount_info) = 0; }; virtual ~MountLibrary() {} virtual void AddObserver(Observer* observer) = 0; virtual void RemoveObserver(Observer* observer) = 0; virtual const DiskMap& disks() const = 0; - virtual const MountPointMap& mount_points() const = 0; - - virtual std::string MountTypeToString(MountType type) const = 0; - virtual MountType MountTypeFromString(const std::string& type_str) const = 0; virtual void RequestMountInfoRefresh() = 0; - virtual void MountPath(const char* source_path, - MountType type, - const MountPathOptions& options) = 0; - // |path| may be source od mount path. - virtual void UnmountPath(const char* path) = 0; + virtual void MountPath(const char* device_path) = 0; + virtual void UnmountPath(const char* device_path) = 0; // Unmounts device_poath and all of its known children. virtual void UnmountDeviceRecursive(const char* device_path, diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc index 91d7216..df0d61e 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc @@ -54,28 +54,6 @@ DictionaryValue* DiskToDictionaryValue( return result; } -const char* MountErrorToString(chromeos::MountError error) { - switch (error) { - case chromeos::MOUNT_ERROR_NONE: - return "success"; - case chromeos::MOUNT_ERROR_UNKNOWN: - return "error_unknown"; - case chromeos::MOUNT_ERROR_INTERNAL: - return "error_internal"; - case chromeos::MOUNT_ERROR_UNKNOWN_FILESYSTEM: - return "error_unknown_filesystem"; - case chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM: - return "error_unsuported_filesystem"; - case chromeos::MOUNT_ERROR_INVALID_ARCHIVE: - return "error_invalid_archive"; - case chromeos::MOUNT_ERROR_LIBRARY_NOT_LOADED: - return "error_libcros_missing"; - default: - NOTREACHED(); - } - return ""; -} - ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter( Profile* profile) : delegate_(new ExtensionFileBrowserEventRouter::FileWatcherDelegate(this)), @@ -175,13 +153,6 @@ void ExtensionFileBrowserEventRouter::DeviceChanged( } } -void ExtensionFileBrowserEventRouter::MountCompleted( - chromeos::MountLibrary::MountEvent event_type, - chromeos::MountError error_code, - const chromeos::MountLibrary::MountPointInfo& mount_info) { - DispatchMountCompletedEvent(event_type, error_code, mount_info); -} - void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( const FilePath& local_path, bool got_error) { base::AutoLock lock(lock_); @@ -247,37 +218,6 @@ void ExtensionFileBrowserEventRouter::DispatchMountEvent( GURL()); } -void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( - chromeos::MountLibrary::MountEvent event, - chromeos::MountError error_code, - const chromeos::MountLibrary::MountPointInfo& mount_info) { - if (!profile_ || mount_info.mount_type == chromeos::MOUNT_TYPE_INVALID) { - NOTREACHED(); - return; - } - - ListValue args; - DictionaryValue* mount_info_value = new DictionaryValue(); - args.Append(mount_info_value); - mount_info_value->SetString("sourcePath", mount_info.source_path); - if (event == chromeos::MountLibrary::MOUNTING) { - mount_info_value->SetString("eventType", "mount"); - } else { - mount_info_value->SetString("eventType", "unmount"); - } - mount_info_value->SetString("status", MountErrorToString(error_code)); - chromeos::MountLibrary* lib = chromeos::CrosLibrary::Get()->GetMountLibrary(); - mount_info_value->SetString("mountType", - lib->MountTypeToString(mount_info.mount_type)); - mount_info_value->SetString("mountPath", mount_info.mount_path); - - std::string args_json; - base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); - profile_->GetExtensionEventRouter()->DispatchEventToRenderers( - extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, - GURL()); -} - void ExtensionFileBrowserEventRouter::OnDiskAdded( const chromeos::MountLibrary::Disk* disk) { VLOG(1) << "Disk added: " << disk->device_path(); @@ -297,9 +237,7 @@ void ExtensionFileBrowserEventRouter::OnDiskAdded( // Initiate disk mount operation. chromeos::MountLibrary* lib = chromeos::CrosLibrary::Get()->GetMountLibrary(); - lib->MountPath(disk->device_path().c_str(), - chromeos::MOUNT_TYPE_DEVICE, - chromeos::MountPathOptions()); // Unused. + lib->MountPath(disk->device_path().c_str()); } } diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.h b/chrome/browser/chromeos/extensions/file_browser_event_router.h index 5378372..fb8047d 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.h +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.h @@ -46,10 +46,6 @@ class ExtensionFileBrowserEventRouter const chromeos::MountLibrary::Disk* disk) OVERRIDE; virtual void DeviceChanged(chromeos::MountLibraryEventType event, const std::string& device_path) OVERRIDE; - virtual void MountCompleted(chromeos::MountLibrary::MountEvent event_type, - chromeos::MountError error_code, - const chromeos::MountLibrary::MountPointInfo& mount_info) - OVERRIDE; private: typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > @@ -107,10 +103,6 @@ class ExtensionFileBrowserEventRouter // Sends filesystem changed extension message to all renderers. void DispatchMountEvent(const chromeos::MountLibrary::Disk* disk, bool added); - void DispatchMountCompletedEvent(chromeos::MountLibrary::MountEvent event, - chromeos::MountError error_code, - const chromeos::MountLibrary::MountPointInfo& mount_info); - void RemoveBrowserFromVector(const std::string& path); // Used to create a window of a standard size, and add it to a list diff --git a/chrome/browser/chromeos/status/clock_menu_button.cc b/chrome/browser/chromeos/status/clock_menu_button.cc index af4579e..5361bbd 100644 --- a/chrome/browser/chromeos/status/clock_menu_button.cc +++ b/chrome/browser/chromeos/status/clock_menu_button.cc @@ -83,7 +83,6 @@ void ClockMenuButton::UpdateTextAndSetNextTimer() { } void ClockMenuButton::UpdateText() { - return; base::Time time(base::Time::Now()); // If the profie is present, check the use 24-hour clock preference. const bool use_24hour_clock = diff --git a/chrome/browser/extensions/extension_event_names.cc b/chrome/browser/extensions/extension_event_names.cc index fc226f3..76c0d8f 100644 --- a/chrome/browser/extensions/extension_event_names.cc +++ b/chrome/browser/extensions/extension_event_names.cc @@ -25,8 +25,6 @@ const char kOnExtensionDisabled[] = "management.onDisabled"; const char kOnFileBrowserDiskChanged[] = "fileBrowserPrivate.onDiskChanged"; const char kOnFileChanged[] = "fileBrowserPrivate.onFileChanged"; -const char kOnFileBrowserMountCompleted[] = - "fileBrowserPrivate.onMountCompleted"; const char kOnInputMethodChanged[] = "inputMethodPrivate.onChanged"; } // namespace extension_event_names diff --git a/chrome/browser/extensions/extension_event_names.h b/chrome/browser/extensions/extension_event_names.h index 0b26e4f..b6958e2 100644 --- a/chrome/browser/extensions/extension_event_names.h +++ b/chrome/browser/extensions/extension_event_names.h @@ -33,7 +33,6 @@ extern const char kOnExtensionDisabled[]; // FileBrowser. extern const char kOnFileBrowserDiskChanged[]; extern const char kOnFileChanged[]; -extern const char kOnFileBrowserMountCompleted[]; // InputMethod. extern const char kOnInputMethodChanged[]; diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc index 9549c78..3f0cb0e 100644 --- a/chrome/browser/extensions/extension_file_browser_private_api.cc +++ b/chrome/browser/extensions/extension_file_browser_private_api.cc @@ -1075,141 +1075,31 @@ bool CancelFileDialogFunction::RunImpl() { return true; } -AddMountFunction::AddMountFunction() { +UnmountVolumeFunction::UnmountVolumeFunction() { } -AddMountFunction::~AddMountFunction() { +UnmountVolumeFunction::~UnmountVolumeFunction() { } -bool AddMountFunction::RunImpl() { - if (args_->GetSize() != 2 && args_->GetSize() != 3) { - error_ = "Invalid argument count"; - return false; - } - - std::string source; - if (!args_->GetString(0, &source)) { - return false; - } - - std::string mount_type_str; - if (!args_->GetString(1, &mount_type_str)) { - return false; - } - -#ifdef OS_CHROMEOS - chromeos::MountLibrary *mount_lib = - chromeos::CrosLibrary::Get()->GetMountLibrary(); - - chromeos::MountType mount_type = - mount_lib->MountTypeFromString(mount_type_str); - if (mount_type == chromeos::MOUNT_TYPE_INVALID) { - error_ = "Invalid mount type"; - return false; - } - - chromeos::MountPathOptions options; - - if (args_->GetSize() == 3) { - DictionaryValue *dict; - if (!args_->GetDictionary(2, &dict)) { - NOTREACHED(); - } - - for (base::DictionaryValue::key_iterator it = dict->begin_keys(); - it != dict->end_keys(); - ++it) { - std::string value; - if (!dict->GetString(*it, &value)) { - NOTREACHED(); - } - - options.push_back(chromeos::MountPathOptions::value_type((*it).c_str(), - value.c_str())); - } - } - - mount_lib->MountPath(source.c_str(), mount_type, options); -#endif - - return true; -} - -RemoveMountFunction::RemoveMountFunction() { -} - -RemoveMountFunction::~RemoveMountFunction() { -} - -bool RemoveMountFunction::RunImpl() { +bool UnmountVolumeFunction::RunImpl() { if (args_->GetSize() != 1) { return false; } - std::string mount_path; - if (!args_->GetString(0, &mount_path)) { - return false; + std::string volume_device_path; + if (!args_->GetString(0, &volume_device_path)) { + NOTREACHED(); } #ifdef OS_CHROMEOS chromeos::CrosLibrary::Get()->GetMountLibrary()->UnmountPath( - mount_path.c_str()); + volume_device_path.c_str()); #endif SendResponse(true); return true; } -GetMountPointsFunction::GetMountPointsFunction() { -} - -GetMountPointsFunction::~GetMountPointsFunction() { -} - -bool GetMountPointsFunction::RunImpl() { - if (args_->GetSize() != 0) - return false; - -#ifdef OS_CHROMEOS - chromeos::MountLibrary *mount_lib = - chromeos::CrosLibrary::Get()->GetMountLibrary(); - chromeos::MountLibrary::MountPointMap mount_points = - mount_lib->mount_points(); - - base::DictionaryValue *mounts = new base::DictionaryValue(); - - for (chromeos::MountLibrary::MountPointMap::const_iterator it = - mount_points.begin(); - it != mount_points.end(); - ++it) { - chromeos::MountLibrary::MountPointInfo mount_point_info = it->second; - - mounts->Set(mount_point_info.mount_path, - MountPointToValue(mount_point_info, mount_lib)); - } - - result_.reset(mounts); -#endif - - return true; -} - -#ifdef OS_CHROMEOS -base::DictionaryValue* GetMountPointsFunction::MountPointToValue( - const chromeos::MountLibrary::MountPointInfo& mount_point_info, - chromeos::MountLibrary* mount_lib) { - - base::DictionaryValue *mount_info = new base::DictionaryValue(); - - mount_info->SetString("mountPath", mount_point_info.mount_path); - mount_info->SetString( - "mountType", - mount_lib->MountTypeToString(mount_point_info.mount_type)); - mount_info->SetString("sourcePath", mount_point_info.source_path); - return mount_info; -} -#endif - GetVolumeMetadataFunction::GetVolumeMetadataFunction() { } diff --git a/chrome/browser/extensions/extension_file_browser_private_api.h b/chrome/browser/extensions/extension_file_browser_private_api.h index 90d44f3..065b9e2 100644 --- a/chrome/browser/extensions/extension_file_browser_private_api.h +++ b/chrome/browser/extensions/extension_file_browser_private_api.h @@ -217,54 +217,19 @@ class CancelFileDialogFunction DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.cancelDialog"); }; -// Mount a device or a file. -class AddMountFunction +// Unmounts selected device. Expects volume's device path as an argument. +class UnmountVolumeFunction : public SyncExtensionFunction { - public: - AddMountFunction(); - - protected: - virtual ~AddMountFunction(); - - virtual bool RunImpl() OVERRIDE; - - private: - DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.addMount"); -}; - -// Unmounts selected device. Expects mount point path as an argument. -class RemoveMountFunction - : public SyncExtensionFunction { - public: - RemoveMountFunction(); - - protected: - virtual ~RemoveMountFunction(); - - virtual bool RunImpl() OVERRIDE; - - private: - DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.removeMount"); -}; - -class GetMountPointsFunction - : public SyncExtensionFunction { - public: - GetMountPointsFunction(); + public: + UnmountVolumeFunction(); protected: - virtual ~GetMountPointsFunction(); + virtual ~UnmountVolumeFunction(); virtual bool RunImpl() OVERRIDE; private: -#ifdef OS_CHROMEOS - base::DictionaryValue* MountPointToValue( - const chromeos::MountLibrary::MountPointInfo& mount_point_info, - chromeos::MountLibrary* mount_lib); -#endif - - DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getMountPoints"); + DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.unmountVolume"); }; // Retrieves devices meta-data. Expects volume's device path as an argument. diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index 640492f..e3ce123 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -347,9 +347,7 @@ void FactoryRegistry::ResetFunctions() { RegisterFunction<RemoveFileWatchBrowserFunction>(); RegisterFunction<SelectFileFunction>(); RegisterFunction<SelectFilesFunction>(); - RegisterFunction<AddMountFunction>(); - RegisterFunction<RemoveMountFunction>(); - RegisterFunction<GetMountPointsFunction>(); + RegisterFunction<UnmountVolumeFunction>(); RegisterFunction<ViewFilesFunction>(); // Mediaplayer diff --git a/chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h b/chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h index dee9f72..c75bb2b 100644 --- a/chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h +++ b/chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h @@ -95,10 +95,6 @@ class WebUIHandler virtual void DeviceChanged(chromeos::MountLibraryEventType event, const std::string& device_path) OVERRIDE { } - virtual void MountCompleted(chromeos::MountLibrary::MountEvent event_type, - chromeos::MountError error_code, - const chromeos::MountLibrary::MountPointInfo& mount_info) OVERRIDE { - } // chromeos::BurnLibrary::Observer interface. virtual void BurnProgressUpdated(chromeos::BurnLibrary* object, diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 6c49f53..d341192 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -5176,26 +5176,6 @@ } }, { - "id": "MountPointInfo", - "type": "object", - "description": "Mounted point information.", - "properties": { - "mountPath": { - "type": "string", - "description": "Disk volume mount point path. The value corresponds to its Entry.fullPath in File API." - }, - "sourcePath": { - "type": "string", - "description": "The path to the mounted resource. Either a device path, or a path to an archive file." - }, - "mountType": { - "type": "string", - "enum": ["device", "file", "network"], - "description": "Type of the mount." - } - } - }, - { "id": "VolumeMetadata", "type": "object", "description": "Mounted disk volume metadata.", @@ -5268,39 +5248,6 @@ } }, { - "id": "MountCompletedEvent", - "type": "object", - "description": "Payload data for mount event.", - "properties": { - "eventType": { - "type": "string", - "enum": ["mount", "unmount"], - "description": "Is the event raised for mounting or unmounting." - }, - "status": { - "type": "string", - "enum": ["success", "error_unknown", "error_internal", - "error_unknown_filesystem", "error_unsuported_filesystem", - "error_invalid_archive", "error_libcros_missing"], - "description": "Event type that tells listeners if mount was successfull or an error occurred. It also specifies the error." - }, - "sourcePath": { - "type": "string", - "description": "Path that has been mounted." - }, - "mountPath": { - "type": "string", - "optional": true, - "description": "Path that sourcePath was mounted to." - }, - "mountType": { - "type": "string", - "enum": ["device", "file", "network"], - "description": "Type of the mount." - } - } - }, - { "id": "FileWatchEvent", "type": "object", "description": "Payload data for disk mount / unmount event.", @@ -5534,48 +5481,15 @@ ] }, { - "name": "addMount", - "type": "function", - "description": "Mount a resource or a file.", - "parameters": [ - { - "name": "source", - "type": "string", - "description": "Mount point source. For compressed files it is relative file path within external file system" - }, - { - "name": "mountType", - "type": "string", - "enum": ["device", "file", "network"], - "description": "Mount point type. 'file' for compressed files" - }, - { - "name": "options", - "type": "object", - "description": "Name/value pairs for source specific options", - "optional": "true" - } - ] - }, - { - "name": "removeMount", - "description": "Unmounts a mounted resource.", + "name": "unmountVolume", + "description": "Unmounts specified volume", "parameters": [ { - "name": "mountPath", + "name": "devicePath", "type": "string", - "description": "A path of the mount." + "description": "Device path of the volume." } ] - }, - { - "name": "getMountPoints", - "description": "Get the list of mount points.", - "returns": { - "type": "object", - "items": {"$ref": "MountPointInfo"}, - "description": "The dictionary with mount point paths as elements and MountPointInfo as values." - } } ], "events": [ @@ -5592,18 +5506,6 @@ ] }, { - "name": "onMountCompleted", - "type": "function", - "description": "Fired when mount event is detected.", - "parameters": [ - { - "$ref": "MountCompletedEvent", - "name": "event", - "description": "MountCompleted event information." - } - ] - }, - { "name": "onFileChanged", "type": "function", "description": "Fired when watched file change event is detected.", @@ -6483,7 +6385,7 @@ "title": { "type": "string", "optional": true, - "description": "The title of the notification." + "description": "The title of the notification." }, "bodyText": { "type": "string", diff --git a/chrome/test/data/extensions/api_test/filebrowser_mount/test.html b/chrome/test/data/extensions/api_test/filebrowser_mount/test.html index b644d31..1e5c4f0 100644 --- a/chrome/test/data/extensions/api_test/filebrowser_mount/test.html +++ b/chrome/test/data/extensions/api_test/filebrowser_mount/test.html @@ -62,9 +62,9 @@ function validateVolume(volume, expected) { }; chrome.test.runTests([ - function removeMount() { - chrome.fileBrowserPrivate.removeMount("devicePath1"); - // We actually check this one on C++ side. If MountLibrary.RemoveMount + function unmountVolume() { + chrome.fileBrowserPrivate.unmountVolume("devicePath1"); + // We actually check this one on C++ side. If MountLibrary.UnmountPath // doesn't get called, test will fail. chrome.test.succeed(); }, |