diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-17 02:54:27 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-17 02:54:27 +0000 |
commit | 07f11f842675a0c9ccbc3ebb19d4c395ea907754 (patch) | |
tree | 5ab82aed645408d9b9cf995ba79d9088bfb3c4ec | |
parent | fe72fa7abb8f92d130346d1fe2c9609ed5260ac4 (diff) | |
download | chromium_src-07f11f842675a0c9ccbc3ebb19d4c395ea907754.zip chromium_src-07f11f842675a0c9ccbc3ebb19d4c395ea907754.tar.gz chromium_src-07f11f842675a0c9ccbc3ebb19d4c395ea907754.tar.bz2 |
Revert 127317 - Implemented API for tracking ongoing file transfers from file manager.
new method:
chrome.fileManagerPrivate.getFileTransfers(function(transfers) {
});
new event:
chrome.fileManagerPrivate.onFileTransfersUpdated.addListener(function(transfers) {
});
where:
transfers = [
{
'fileUrl': 'filesystem://.../external/gdata/myfile.txt',
'transferState': 'started|in_progress|completed|failed',
'transferType': 'upload|download',
'processed': 1234,
'total': 54331
},
...
]
BUG=chromium-os:27819
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9703042
TBR=zelidrag@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9719012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127331 0039d316-1c4b-4281-b951-d872f2087c98
17 files changed, 69 insertions, 370 deletions
diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc index 0d8f91e..e16ff38 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc @@ -16,9 +16,6 @@ #include "chrome/browser/extensions/extension_event_router.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_dependency_manager.h" -#include "chrome/common/chrome_notification_types.h" -#include "content/public/browser/notification_source.h" #include "grit/generated_resources.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/file_system_util.h" @@ -26,8 +23,6 @@ using chromeos::disks::DiskMountManager; using chromeos::disks::DiskMountManagerEventType; using content::BrowserThread; -using gdata::GDataFileSystem; -using gdata::GDataFileSystemFactory; namespace { const char kDiskAddedEventType[] = "added"; @@ -78,56 +73,40 @@ const char* MountErrorToString(chromeos::MountError error) { return ""; } -FileBrowserEventRouter::FileBrowserEventRouter( +ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter( Profile* profile) - : delegate_(new FileBrowserEventRouter::FileWatcherDelegate(this)), + : delegate_(new ExtensionFileBrowserEventRouter::FileWatcherDelegate(this)), notifications_(new FileBrowserNotifications(profile)), profile_(profile) { } -FileBrowserEventRouter::~FileBrowserEventRouter() { -} - -void FileBrowserEventRouter::Shutdown() { +ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { DCHECK(file_watchers_.empty()); STLDeleteValues(&file_watchers_); + if (!profile_) { NOTREACHED(); return; } - DiskMountManager::GetInstance()->RemoveObserver(this); - - GDataFileSystem* file_system = - GDataFileSystemFactory::GetForProfile(profile_); - file_system->RemoveOperationObserver(this); - profile_ = NULL; + DiskMountManager::GetInstance()->RemoveObserver(this); } -void FileBrowserEventRouter::ObserveFileSystemEvents() { +void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() { if (!profile_) { NOTREACHED(); return; } - if (!chromeos::UserManager::Get()->IsUserLoggedIn()) - return; - - DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); - disk_mount_manager->RemoveObserver(this); - disk_mount_manager->AddObserver(this); - disk_mount_manager->RequestMountInfoRefresh(); - - GDataFileSystem* file_system = - GDataFileSystemFactory::GetForProfile(profile_); - if (!file_system) { - NOTREACHED(); - return; + if (chromeos::UserManager::Get()->IsUserLoggedIn()) { + DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); + disk_mount_manager->RemoveObserver(this); + disk_mount_manager->AddObserver(this); + disk_mount_manager->RequestMountInfoRefresh(); } - file_system->AddOperationObserver(this); } // File watch setup routines. -bool FileBrowserEventRouter::AddFileWatch( +bool ExtensionFileBrowserEventRouter::AddFileWatch( const FilePath& local_path, const FilePath& virtual_path, const std::string& extension_id) { @@ -147,7 +126,7 @@ bool FileBrowserEventRouter::AddFileWatch( return true; } -void FileBrowserEventRouter::RemoveFileWatch( +void ExtensionFileBrowserEventRouter::RemoveFileWatch( const FilePath& local_path, const std::string& extension_id) { base::AutoLock lock(lock_); @@ -162,7 +141,7 @@ void FileBrowserEventRouter::RemoveFileWatch( } } -void FileBrowserEventRouter::DiskChanged( +void ExtensionFileBrowserEventRouter::DiskChanged( DiskMountManagerEventType event, const DiskMountManager::Disk* disk) { // Disregard hidden devices. @@ -175,7 +154,7 @@ void FileBrowserEventRouter::DiskChanged( } } -void FileBrowserEventRouter::DeviceChanged( +void ExtensionFileBrowserEventRouter::DeviceChanged( DiskMountManagerEventType event, const std::string& device_path) { if (event == chromeos::disks::MOUNT_DEVICE_ADDED) { @@ -200,7 +179,7 @@ void FileBrowserEventRouter::DeviceChanged( } } -void FileBrowserEventRouter::MountCompleted( +void ExtensionFileBrowserEventRouter::MountCompleted( DiskMountManager::MountEvent event_type, chromeos::MountError error_code, const DiskMountManager::MountPointInfo& mount_info) { @@ -223,26 +202,7 @@ void FileBrowserEventRouter::MountCompleted( } } -void FileBrowserEventRouter::OnProgressUpdate( - const std::vector<gdata::GDataOperationRegistry::ProgressStatus>& list) { - scoped_ptr<ListValue> event_list( - file_manager_util::ProgressStatusVectorToListValue( - profile_, - file_manager_util::GetFileBrowserExtensionUrl().GetOrigin(), - list)); - - std::string args_json; - base::JSONWriter::Write(event_list.get(), - &args_json); - - profile_->GetExtensionEventRouter()->DispatchEventToExtension( - std::string(kFileBrowserDomain), - extension_event_names::kOnFileTransfersUpdated, args_json, - NULL, GURL()); -} - - -void FileBrowserEventRouter::HandleFileWatchNotification( +void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( const FilePath& local_path, bool got_error) { base::AutoLock lock(lock_); WatcherMap::const_iterator iter = file_watchers_.find(local_path); @@ -254,9 +214,9 @@ void FileBrowserEventRouter::HandleFileWatchNotification( iter->second->GetExtensions()); } -void FileBrowserEventRouter::DispatchFolderChangeEvent( +void ExtensionFileBrowserEventRouter::DispatchFolderChangeEvent( const FilePath& virtual_path, bool got_error, - const FileBrowserEventRouter::ExtensionUsageRegistry& extensions) { + const ExtensionFileBrowserEventRouter::ExtensionUsageRegistry& extensions) { if (!profile_) { NOTREACHED(); return; @@ -285,7 +245,7 @@ void FileBrowserEventRouter::DispatchFolderChangeEvent( } } -void FileBrowserEventRouter::DispatchDiskEvent( +void ExtensionFileBrowserEventRouter::DispatchDiskEvent( const DiskMountManager::Disk* disk, bool added) { if (!profile_) { NOTREACHED(); @@ -307,7 +267,7 @@ void FileBrowserEventRouter::DispatchDiskEvent( GURL()); } -void FileBrowserEventRouter::DispatchMountCompletedEvent( +void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( DiskMountManager::MountEvent event, chromeos::MountError error_code, const DiskMountManager::MountPointInfo& mount_info) { @@ -371,7 +331,7 @@ void FileBrowserEventRouter::DispatchMountCompletedEvent( } } -void FileBrowserEventRouter::OnDiskAdded( +void ExtensionFileBrowserEventRouter::OnDiskAdded( const DiskMountManager::Disk* disk) { VLOG(1) << "Disk added: " << disk->device_path(); if (disk->device_path().empty()) { @@ -388,7 +348,7 @@ void FileBrowserEventRouter::OnDiskAdded( DispatchDiskEvent(disk, true); } -void FileBrowserEventRouter::OnDiskRemoved( +void ExtensionFileBrowserEventRouter::OnDiskRemoved( const DiskMountManager::Disk* disk) { VLOG(1) << "Disk removed: " << disk->device_path(); @@ -398,7 +358,7 @@ void FileBrowserEventRouter::OnDiskRemoved( DispatchDiskEvent(disk, false); } -void FileBrowserEventRouter::OnDeviceAdded( +void ExtensionFileBrowserEventRouter::OnDeviceAdded( const std::string& device_path) { VLOG(1) << "Device added : " << device_path; @@ -408,7 +368,7 @@ void FileBrowserEventRouter::OnDeviceAdded( 4000); } -void FileBrowserEventRouter::OnDeviceRemoved( +void ExtensionFileBrowserEventRouter::OnDeviceRemoved( const std::string& device_path) { VLOG(1) << "Device removed : " << device_path; notifications_->HideNotification(FileBrowserNotifications::DEVICE, @@ -418,12 +378,12 @@ void FileBrowserEventRouter::OnDeviceRemoved( notifications_->UnregisterDevice(device_path); } -void FileBrowserEventRouter::OnDeviceScanned( +void ExtensionFileBrowserEventRouter::OnDeviceScanned( const std::string& device_path) { VLOG(1) << "Device scanned : " << device_path; } -void FileBrowserEventRouter::OnFormattingStarted( +void ExtensionFileBrowserEventRouter::OnFormattingStarted( const std::string& device_path, bool success) { if (success) { notifications_->ShowNotification(FileBrowserNotifications::FORMAT_START, @@ -434,7 +394,7 @@ void FileBrowserEventRouter::OnFormattingStarted( } } -void FileBrowserEventRouter::OnFormattingFinished( +void ExtensionFileBrowserEventRouter::OnFormattingFinished( const std::string& device_path, bool success) { if (success) { notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, @@ -455,12 +415,12 @@ void FileBrowserEventRouter::OnFormattingFinished( } } -// FileBrowserEventRouter::WatcherDelegate methods. -FileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( - FileBrowserEventRouter* router) : router_(router) { +// ExtensionFileBrowserEventRouter::WatcherDelegate methods. +ExtensionFileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( + ExtensionFileBrowserEventRouter* router) : router_(router) { } -void FileBrowserEventRouter::FileWatcherDelegate::OnFilePathChanged( +void ExtensionFileBrowserEventRouter::FileWatcherDelegate::OnFilePathChanged( const FilePath& local_path) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -468,7 +428,7 @@ void FileBrowserEventRouter::FileWatcherDelegate::OnFilePathChanged( this, local_path, false)); } -void FileBrowserEventRouter::FileWatcherDelegate::OnFilePathError( +void ExtensionFileBrowserEventRouter::FileWatcherDelegate::OnFilePathError( const FilePath& local_path) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -477,14 +437,14 @@ void FileBrowserEventRouter::FileWatcherDelegate::OnFilePathError( } void -FileBrowserEventRouter::FileWatcherDelegate::HandleFileWatchOnUIThread( +ExtensionFileBrowserEventRouter::FileWatcherDelegate::HandleFileWatchOnUIThread( const FilePath& local_path, bool got_error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); router_->HandleFileWatchNotification(local_path, got_error); } -FileBrowserEventRouter::FileWatcherExtensions::FileWatcherExtensions( +ExtensionFileBrowserEventRouter::FileWatcherExtensions::FileWatcherExtensions( const FilePath& path, const std::string& extension_id) : ref_count(0) { file_watcher.reset(new base::files::FilePathWatcher()); @@ -492,7 +452,7 @@ FileBrowserEventRouter::FileWatcherExtensions::FileWatcherExtensions( AddExtension(extension_id); } -void FileBrowserEventRouter::FileWatcherExtensions::AddExtension( +void ExtensionFileBrowserEventRouter::FileWatcherExtensions::AddExtension( const std::string& extension_id) { ExtensionUsageRegistry::iterator it = extensions.find(extension_id); if (it != extensions.end()) { @@ -504,7 +464,7 @@ void FileBrowserEventRouter::FileWatcherExtensions::AddExtension( ref_count++; } -void FileBrowserEventRouter::FileWatcherExtensions::RemoveExtension( +void ExtensionFileBrowserEventRouter::FileWatcherExtensions::RemoveExtension( const std::string& extension_id) { ExtensionUsageRegistry::iterator it = extensions.find(extension_id); @@ -525,49 +485,22 @@ void FileBrowserEventRouter::FileWatcherExtensions::RemoveExtension( } } -const FileBrowserEventRouter::ExtensionUsageRegistry& -FileBrowserEventRouter::FileWatcherExtensions::GetExtensions() const { +const ExtensionFileBrowserEventRouter::ExtensionUsageRegistry& +ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetExtensions() const { return extensions; } unsigned int -FileBrowserEventRouter::FileWatcherExtensions::GetRefCount() const { +ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetRefCount() const { return ref_count; } const FilePath& -FileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { +ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { return virtual_path; } -bool FileBrowserEventRouter::FileWatcherExtensions::Watch +bool ExtensionFileBrowserEventRouter::FileWatcherExtensions::Watch (const FilePath& path, FileWatcherDelegate* delegate) { return file_watcher->Watch(path, delegate); } - -// static -FileBrowserEventRouter* -FileBrowserEventRouterFactory::GetForProfile(Profile* profile) { - return static_cast<FileBrowserEventRouter*>( - GetInstance()->GetServiceForProfile(profile, true)); -} - -// static -FileBrowserEventRouterFactory* -FileBrowserEventRouterFactory::GetInstance() { - return Singleton<FileBrowserEventRouterFactory>::get(); -} - -FileBrowserEventRouterFactory::FileBrowserEventRouterFactory() - : ProfileKeyedServiceFactory("FileBrowserEventRouter", - ProfileDependencyManager::GetInstance()) { - DependsOn(GDataFileSystemFactory::GetInstance()); -} - -FileBrowserEventRouterFactory::~FileBrowserEventRouterFactory() { -} - -ProfileKeyedService* FileBrowserEventRouterFactory::BuildServiceInstanceFor( - Profile* profile) const { - return new FileBrowserEventRouter(profile); -} diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.h b/chrome/browser/chromeos/extensions/file_browser_event_router.h index 199338d..e546455 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.h +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,24 +16,17 @@ #include "base/string16.h" #include "base/synchronization/lock.h" #include "chrome/browser/chromeos/disks/disk_mount_manager.h" -#include "chrome/browser/chromeos/gdata/gdata_file_system.h" -#include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" -#include "chrome/browser/profiles/profile_keyed_service.h" -#include "chrome/browser/profiles/profile_keyed_service_factory.h" class FileBrowserNotifications; class Profile; // Used to monitor disk mount changes and signal when new mounted usb device is // found. -class FileBrowserEventRouter - : public ProfileKeyedService, - public chromeos::disks::DiskMountManager::Observer, - public gdata::GDataOperationRegistry::Observer { +class ExtensionFileBrowserEventRouter + : public chromeos::disks::DiskMountManager::Observer { public: - // ProfileKeyedService overrides. - virtual void Shutdown() OVERRIDE; - + explicit ExtensionFileBrowserEventRouter(Profile* profile); + virtual ~ExtensionFileBrowserEventRouter(); // Starts observing file system change events. Currently only // CrosDisksClient events are being observed. void ObserveFileSystemEvents(); @@ -57,18 +50,11 @@ class FileBrowserEventRouter const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) OVERRIDE; - // GDataOperationRegistry::Observer overrides. - virtual void OnProgressUpdate( - const std::vector<gdata::GDataOperationRegistry::ProgressStatus>& list) - OVERRIDE; - private: - friend class FileBrowserEventRouterFactory; - // Helper class for passing through file watch notification events. class FileWatcherDelegate : public base::files::FilePathWatcher::Delegate { public: - explicit FileWatcherDelegate(FileBrowserEventRouter* router); + explicit FileWatcherDelegate(ExtensionFileBrowserEventRouter* router); private: // base::files::FilePathWatcher::Delegate overrides. @@ -77,7 +63,7 @@ class FileBrowserEventRouter void HandleFileWatchOnUIThread(const FilePath& local_path, bool got_error); - FileBrowserEventRouter* router_; + ExtensionFileBrowserEventRouter* router_; }; typedef std::map<std::string, int> ExtensionUsageRegistry; @@ -111,9 +97,6 @@ class FileBrowserEventRouter typedef std::map<FilePath, FileWatcherExtensions*> WatcherMap; - explicit FileBrowserEventRouter(Profile* profile); - virtual ~FileBrowserEventRouter(); - // USB mount event handlers. void OnDiskAdded(const chromeos::disks::DiskMountManager::Disk* disk); void OnDiskRemoved(const chromeos::disks::DiskMountManager::Disk* disk); @@ -156,30 +139,7 @@ class FileBrowserEventRouter Profile* profile_; base::Lock lock_; - DISALLOW_COPY_AND_ASSIGN(FileBrowserEventRouter); -}; - -// Singleton that owns all FileBrowserEventRouter and associates -// them with Profiles. -class FileBrowserEventRouterFactory - : public ProfileKeyedServiceFactory { - public: - // Returns the FileBrowserEventRouter for |profile|, creating it if - // it is not yet created. - static FileBrowserEventRouter* GetForProfile(Profile* profile); - - // Returns the FileBrowserEventRouterFactory instance. - static FileBrowserEventRouterFactory* GetInstance(); - - private: - friend struct DefaultSingletonTraits<FileBrowserEventRouterFactory>; - - FileBrowserEventRouterFactory(); - virtual ~FileBrowserEventRouterFactory(); - - // ProfileKeyedServiceFactory: - virtual ProfileKeyedService* BuildServiceInstanceFor( - Profile* profile) const OVERRIDE; + DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); }; #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc index 7941ca2..3326e28 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc @@ -18,7 +18,6 @@ #include "chrome/browser/chromeos/extensions/file_handler_util.h" #include "chrome/browser/chromeos/extensions/file_manager_util.h" #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h" -#include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" #include "chrome/browser/chromeos/gdata/gdata_util.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/browser/extensions/extension_process_manager.h" @@ -62,7 +61,6 @@ using content::ChildProcessSecurityPolicy; using content::SiteInstance; using content::WebContents; using file_handler_util::FileTaskExecutor; -using gdata::GDataOperationRegistry; namespace { @@ -565,7 +563,7 @@ bool AddFileWatchBrowserFunction::PerformFileWatchOperation( const FilePath& local_path, const FilePath& virtual_path, const std::string& extension_id) { #if defined(OS_CHROMEOS) - return FileBrowserEventRouterFactory::GetForProfile(profile_)-> + return profile_->GetExtensionService()->file_browser_event_router()-> AddFileWatch(local_path, virtual_path, extension_id); #else return true; @@ -576,7 +574,7 @@ bool RemoveFileWatchBrowserFunction::PerformFileWatchOperation( const FilePath& local_path, const FilePath& unused, const std::string& extension_id) { #if defined(OS_CHROMEOS) - FileBrowserEventRouterFactory::GetForProfile(profile_)-> + profile_->GetExtensionService()->file_browser_event_router()-> RemoveFileWatch(local_path, extension_id); #endif return true; @@ -1047,8 +1045,10 @@ void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) { chromeos::MOUNT_TYPE_GDATA, chromeos::disks::MOUNT_CONDITION_NONE); // Raise mount event - FileBrowserEventRouterFactory::GetForProfile(profile_)-> - MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); + profile_->GetExtensionService()->file_browser_event_router()->MountCompleted( + DiskMountManager::MOUNTING, + error_code, + mount_info); } void AddMountFunction::OnGDataAuthentication(gdata::GDataErrorCode error, @@ -1755,32 +1755,3 @@ void GetGDataFilesFunction::OnFileReady( // Start getting the next file. GetFileOrSendResponse(); } - -GetFileTransfersFunction::GetFileTransfersFunction() {} - -GetFileTransfersFunction::~GetFileTransfersFunction() {} - -ListValue* GetFileTransfersFunction::GetFileTransfersList() { - gdata::GDataFileSystem* file_system = - gdata::GDataFileSystemFactory::GetForProfile(profile_); - if (!file_system) - return NULL; - - std::vector<gdata::GDataOperationRegistry::ProgressStatus> - list = file_system->GetProgressStatusList(); - return file_manager_util::ProgressStatusVectorToListValue( - profile_, source_url_.GetOrigin(), list); -} - -bool GetFileTransfersFunction::RunImpl() { - scoped_ptr<ListValue> progress_status_list(GetFileTransfersList()); - if (!progress_status_list.get()) { - SendResponse(false); - return false; - } - - result_.reset(progress_status_list.release()); - SendResponse(true); - return true; -} - diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.h b/chrome/browser/chromeos/extensions/file_browser_private_api.h index 747eb03..6d2bffc 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_api.h +++ b/chrome/browser/chromeos/extensions/file_browser_private_api.h @@ -481,20 +481,4 @@ class GetGDataFilesFunction : public FileBrowserFunction { DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataFiles"); }; -// Implements the chrome.fileBrowserPrivate.executeTask method. -class GetFileTransfersFunction : public AsyncExtensionFunction { - public: - GetFileTransfersFunction(); - virtual ~GetFileTransfersFunction(); - - protected: - // AsyncExtensionFunction overrides. - virtual bool RunImpl() OVERRIDE; - - private: - ListValue* GetFileTransfersList(); - - DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileTransfers"); -}; - #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ diff --git a/chrome/browser/chromeos/extensions/file_manager_util.cc b/chrome/browser/chromeos/extensions/file_manager_util.cc index caee01b..509a4d3 100644 --- a/chrome/browser/chromeos/extensions/file_manager_util.cc +++ b/chrome/browser/chromeos/extensions/file_manager_util.cc @@ -12,7 +12,6 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/chromeos/extensions/file_handler_util.h" -#include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_install_ui.h" #include "chrome/browser/extensions/extension_service.h" @@ -41,17 +40,14 @@ #include "chrome/browser/chromeos/media/media_player.h" #endif -using base::DictionaryValue; -using base::ListValue; using content::BrowserContext; using content::BrowserThread; using content::PluginService; using content::UserMetricsAction; using file_handler_util::FileTaskExecutor; -using gdata::GDataOperationRegistry; -#define FILEBROWSER_EXTENSON_ID "hhaomjibdihmijegdhdafkllkbggdgoj" -const char kFileBrowserDomain[] = FILEBROWSER_EXTENSON_ID; +#define FILEBROWSER_DOMAIN "hhaomjibdihmijegdhdafkllkbggdgoj" +const char kFileBrowserDomain[] = FILEBROWSER_DOMAIN; const char kFileBrowserGalleryTaskId[] = "gallery"; const char kFileBrowserMountArchiveTaskId[] = "mount-archive"; @@ -60,7 +56,7 @@ namespace file_manager_util { namespace { #define FILEBROWSER_URL(PATH) \ - ("chrome-extension://" FILEBROWSER_EXTENSON_ID "/" PATH) + ("chrome-extension://" FILEBROWSER_DOMAIN "/" PATH) // This is the "well known" url for the file manager extension from // browser/resources/file_manager. In the future we may provide a way to swap // out this file manager for an aftermarket part, but not yet. @@ -69,7 +65,7 @@ const char kBaseFileBrowserUrl[] = FILEBROWSER_URL("main.html"); const char kMediaPlayerUrl[] = FILEBROWSER_URL("mediaplayer.html"); const char kMediaPlayerPlaylistUrl[] = FILEBROWSER_URL("playlist.html"); #undef FILEBROWSER_URL -#undef FILEBROWSER_EXTENSON_ID +#undef FILEBROWSER_DOMAIN const char kCRXExtension[] = ".crx"; const char kPdfExtension[] = ".pdf"; @@ -168,29 +164,6 @@ std::string GetDialogTypeAsString( return type_str; } -DictionaryValue* ProgessStatusToDictionaryValue( - Profile* profile, - const GURL& origin_url, - const GDataOperationRegistry::ProgressStatus& status) { - scoped_ptr<DictionaryValue> result(new DictionaryValue()); - GURL file_url; - if (file_manager_util::ConvertFileToFileSystemUrl(profile, - FilePath(status.file_path), - origin_url, - &file_url)) { - result->SetString("fileUrl", file_url.spec()); - } - - result->SetString("transferState", - GDataOperationRegistry::OperationTransferStateToString( - status.transfer_state)); - result->SetString("transferType", - GDataOperationRegistry::OperationTypeToString(status.operation_type)); - result->SetInteger("processed", static_cast<int>(status.progress_current)); - result->SetInteger("total", static_cast<int>(status.progress_total)); - return result.release(); -} - } // namespace GURL GetFileBrowserExtensionUrl() { @@ -522,18 +495,4 @@ bool ShouldBeOpenedWithPdfPlugin(const char* file_extension) { return plugin_prefs->IsPluginEnabled(plugin); } -ListValue* ProgressStatusVectorToListValue( - Profile* profile, const GURL& origin_url, - const std::vector<GDataOperationRegistry::ProgressStatus>& list) { - scoped_ptr<ListValue> result_list(new ListValue()); - for (std::vector< - GDataOperationRegistry::ProgressStatus>::const_iterator iter = - list.begin(); - iter != list.end(); ++iter) { - result_list->Append( - ProgessStatusToDictionaryValue(profile, origin_url, *iter)); - } - return result_list.release(); -} - } // namespace file_manager_util diff --git a/chrome/browser/chromeos/extensions/file_manager_util.h b/chrome/browser/chromeos/extensions/file_manager_util.h index 9645b8a..7e520ef 100644 --- a/chrome/browser/chromeos/extensions/file_manager_util.h +++ b/chrome/browser/chromeos/extensions/file_manager_util.h @@ -7,19 +7,13 @@ #pragma once #include <string> -#include <vector> #include "base/file_path.h" -#include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" #include "chrome/browser/ui/select_file_dialog.h" #include "googleurl/src/gurl.h" class Profile; -namespace base { -class ListValue; -} - extern const char kFileBrowserDomain[]; // File manager helper methods. @@ -74,11 +68,6 @@ void InstallCRX(Profile* profile, const FilePath& full_path); bool ShouldBeOpenedWithPdfPlugin(const char* file_extension); -// Converts the vector of progress status to their JSON (Value) form. -base::ListValue* ProgressStatusVectorToListValue( - Profile* profile, const GURL& origin_url, - const std::vector<gdata::GDataOperationRegistry::ProgressStatus>& list); - } // namespace file_manager_util #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_UTIL_H_ diff --git a/chrome/browser/chromeos/gdata/gdata.cc b/chrome/browser/chromeos/gdata/gdata.cc index 7bffcb7..9b7d666 100644 --- a/chrome/browser/chromeos/gdata/gdata.cc +++ b/chrome/browser/chromeos/gdata/gdata.cc @@ -196,10 +196,6 @@ void DocumentsService::Initialize(Profile* profile) { gdata_auth_service_->Initialize(profile); } -GDataOperationRegistry* DocumentsService::operation_registry() const { - return operation_registry_.get(); -} - void DocumentsService::CancelAll() { operation_registry_->CancelAll(); } diff --git a/chrome/browser/chromeos/gdata/gdata.h b/chrome/browser/chromeos/gdata/gdata.h index 81295cd..1bf4219 100644 --- a/chrome/browser/chromeos/gdata/gdata.h +++ b/chrome/browser/chromeos/gdata/gdata.h @@ -144,9 +144,6 @@ class DocumentsServiceInterface { // Initializes the documents service tied with |profile|. virtual void Initialize(Profile* profile) = 0; - // Retrieves the operation registry. - virtual GDataOperationRegistry* operation_registry() const = 0; - // Cancels all in-flight operations. virtual void CancelAll() = 0; @@ -272,7 +269,6 @@ class DocumentsService // DocumentsServiceInterface Overrides virtual void Initialize(Profile* profile) OVERRIDE; - virtual GDataOperationRegistry* operation_registry() const OVERRIDE; virtual void CancelAll() OVERRIDE; virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; virtual void GetDocuments(const GURL& feed_url, diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc index d2e9f4f..6abc551 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system.cc +++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc @@ -19,6 +19,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/gdata/gdata.h" #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" +#include "chrome/browser/chromeos/gdata/gdata_parser.h" #include "chrome/browser/download/download_service.h" #include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/profiles/profile.h" @@ -1264,22 +1265,6 @@ void GDataFileSystem::OnGetAvailableSpace( feed->quota_bytes_used()); } -std::vector<GDataOperationRegistry::ProgressStatus> - GDataFileSystem::GetProgressStatusList() { - return documents_service_->operation_registry()->GetProgressStatusList(); -} - -void GDataFileSystem::AddOperationObserver( - GDataOperationRegistry::Observer* observer) { - return documents_service_->operation_registry()->AddObserver(observer); -} - -void GDataFileSystem::RemoveOperationObserver( - GDataOperationRegistry::Observer* observer) { - return documents_service_->operation_registry()->RemoveObserver(observer); -} - - void GDataFileSystem::OnCreateDirectoryCompleted( const CreateDirectoryParams& params, GDataErrorCode status, diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.h b/chrome/browser/chromeos/gdata/gdata_file_system.h index cb9dbb1..e9fe0dd 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system.h +++ b/chrome/browser/chromeos/gdata/gdata_file_system.h @@ -19,7 +19,6 @@ #include "base/platform_file.h" #include "base/synchronization/lock.h" #include "chrome/browser/chromeos/gdata/gdata_files.h" -#include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" #include "chrome/browser/chromeos/gdata/gdata_params.h" #include "chrome/browser/chromeos/gdata/gdata_parser.h" #include "chrome/browser/chromeos/gdata/gdata_uploader.h" @@ -243,12 +242,6 @@ class GDataFileSystem : public ProfileKeyedService { void GetCacheState(const std::string& resource_id, const std::string& md5, const GetCacheStateCallback& callback); - // Obtains the list of currently active operations. - std::vector<GDataOperationRegistry::ProgressStatus> GetProgressStatusList(); - // Add operation observer. - void AddOperationObserver(GDataOperationRegistry::Observer* observer); - // Remove operation observer. - void RemoveOperationObserver(GDataOperationRegistry::Observer* observer); // Finds file object by |file_path| and returns its |file_info|. // Returns true if file was found. diff --git a/chrome/browser/chromeos/gdata/gdata_mock.h b/chrome/browser/chromeos/gdata/gdata_mock.h index bd848e0..d967c01 100644 --- a/chrome/browser/chromeos/gdata/gdata_mock.h +++ b/chrome/browser/chromeos/gdata/gdata_mock.h @@ -28,7 +28,6 @@ class MockDocumentsService : public DocumentsServiceInterface { // DocumentServiceInterface overrides. MOCK_METHOD1(Initialize, void(Profile* profile)); - MOCK_CONST_METHOD0(operation_registry, GDataOperationRegistry*()); MOCK_METHOD0(CancelAll, void(void)); MOCK_METHOD1(Authenticate, void(const AuthStatusCallback& callback)); MOCK_METHOD2(GetDocuments, void(const GURL& feed_url, diff --git a/chrome/browser/extensions/extension_event_names.cc b/chrome/browser/extensions/extension_event_names.cc index c127cd5..9f25a7a 100644 --- a/chrome/browser/extensions/extension_event_names.cc +++ b/chrome/browser/extensions/extension_event_names.cc @@ -31,8 +31,6 @@ const char kOnFileBrowserDiskChanged[] = "fileBrowserPrivate.onDiskChanged"; const char kOnFileChanged[] = "fileBrowserPrivate.onFileChanged"; const char kOnFileBrowserMountCompleted[] = "fileBrowserPrivate.onMountCompleted"; -const char kOnFileTransfersUpdated[] = - "fileBrowserPrivate.onFileTransfersUpdated"; const char kOnInputMethodChanged[] = "inputMethodPrivate.onChanged"; diff --git a/chrome/browser/extensions/extension_event_names.h b/chrome/browser/extensions/extension_event_names.h index 200328d..d18c1f11 100644 --- a/chrome/browser/extensions/extension_event_names.h +++ b/chrome/browser/extensions/extension_event_names.h @@ -38,7 +38,6 @@ extern const char kOnExtensionDisabled[]; extern const char kOnFileBrowserDiskChanged[]; extern const char kOnFileChanged[]; extern const char kOnFileBrowserMountCompleted[]; -extern const char kOnFileTransfersUpdated[]; // InputMethod. extern const char kOnInputMethodChanged[]; diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 5b1258b..af61980 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -541,8 +541,9 @@ void ExtensionService::InitEventRouters() { web_navigation_event_router_->Init(); #if defined(OS_CHROMEOS) - FileBrowserEventRouterFactory::GetForProfile( - profile_)->ObserveFileSystemEvents(); + file_browser_event_router_.reset( + new ExtensionFileBrowserEventRouter(profile_)); + file_browser_event_router_->ObserveFileSystemEvents(); input_method_event_router_.reset( new chromeos::ExtensionInputMethodEventRouter); diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h index 7f884ad..4c133d8 100644 --- a/chrome/browser/extensions/extension_service.h +++ b/chrome/browser/extensions/extension_service.h @@ -53,6 +53,7 @@ class ExtensionBrowserEventRouter; class ExtensionContentSettingsStore; class ExtensionCookiesEventRouter; class ExtensionDownloadsEventRouter; +class ExtensionFileBrowserEventRouter; class ExtensionGlobalError; class ExtensionManagementEventRouter; class ExtensionPreferenceEventRouter; @@ -476,6 +477,9 @@ class ExtensionService } #if defined(OS_CHROMEOS) + ExtensionFileBrowserEventRouter* file_browser_event_router() { + return file_browser_event_router_.get(); + } chromeos::ExtensionInputMethodEventRouter* input_method_event_router() { return input_method_event_router_.get(); } @@ -810,6 +814,7 @@ class ExtensionService scoped_ptr<ExtensionWebNavigationEventRouter> web_navigation_event_router_; #if defined(OS_CHROMEOS) + scoped_ptr<ExtensionFileBrowserEventRouter> file_browser_event_router_; scoped_ptr<chromeos::ExtensionInputMethodEventRouter> input_method_event_router_; #endif diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js index f7457ae..eb98100 100644 --- a/chrome/browser/resources/file_manager/js/directory_model.js +++ b/chrome/browser/resources/file_manager/js/directory_model.js @@ -763,15 +763,11 @@ DirectoryModel.prototype = { } function onGData(entry) { - console.log('onGData'); - console.log(entry); groups.gdata = [entry]; done(); } function onGDataError(error) { - console.log('onGDataError'); - console.log(error); groups.gdata = []; done(); } @@ -788,11 +784,8 @@ DirectoryModel.prototype = { }, updateRoots: function(opt_callback) { - console.log('directoryModel_.updateRoots'); var self = this; this.resolveRoots_(function(rootEntries) { - console.log('rootsList_ = '); - console.log(self.rootsList_); var dm = self.rootsList_; var args = [0, dm.length].concat(rootEntries); dm.splice.apply(dm, args); diff --git a/chrome/common/extensions/api/fileBrowserPrivate.json b/chrome/common/extensions/api/fileBrowserPrivate.json index bd8b71a..0993aed 100644 --- a/chrome/common/extensions/api/fileBrowserPrivate.json +++ b/chrome/common/extensions/api/fileBrowserPrivate.json @@ -259,37 +259,6 @@ } }, { - "id": "FileTransferStatus", - "type": "object", - "description": "Payload data for file transfer status updates.", - "properties": { - "fileUrl": { - "type": "string", - "description": "URL of file that is being transfered." - }, - "transferState": { - "type": "string", - "enum": ["started", "in_progress", "completed", "failed"], - "description": "File transfer progress state." - }, - "transferType": { - "type": "string", - "enum": ["upload", "download"], - "description": "Defines file transfer direction." - }, - "processed": { - "type": "integer", - "optional": true, - "description": "Completed portion of the transfer operation." - }, - "total": { - "type": "integer", - "optional": true, - "description": "Total size (cost) of transfer operation." - } - } - }, - { "id": "FileWatchEvent", "type": "object", "description": "Payload data for disk mount / unmount event.", @@ -683,24 +652,6 @@ ] }, { - "name": "getFileTransfers", - "description": "Get the list of ongoing file transfer operations.", - "parameters": [ - { - "name": "callback", - "type": "function", - "parameters": [ - { - "name" : "fileTransfers", - "type": "array", - "items": {"$ref": "FileTransferStatus"}, - "description": "The list of FileTransferStatus representing ongoing file transfers." - } - ] - } - ] - }, - { "name": "getSizeStats", "description": "Retrieves total and remaining size of a mount point.", "parameters": [ @@ -782,19 +733,6 @@ ] }, { - "name": "onFileTransfersUpdated", - "type": "function", - "description": "Fired when file transfers with remote file system are in progress.", - "parameters": [ - { - "type": "array", - "items": {"$ref": "FileTransferStatus"}, - "name": "event", - "description": "List of ongoing file statuses for ongoing transfer operations." - } - ] - }, - { "name": "onFileChanged", "type": "function", "description": "Fired when watched file change event is detected.", |