Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| 31 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "webkit/fileapi/file_system_types.h" | 33 #include "webkit/fileapi/file_system_types.h" |
| 34 #include "webkit/fileapi/file_system_util.h" | 34 #include "webkit/fileapi/file_system_util.h" |
| 35 | 35 |
| 36 using chromeos::disks::DiskMountManager; | 36 using chromeos::disks::DiskMountManager; |
| 37 using chromeos::disks::DiskMountManagerEventType; | 37 using chromeos::disks::DiskMountManagerEventType; |
| 38 using content::BrowserThread; | 38 using content::BrowserThread; |
| 39 using gdata::GDataFileSystemInterface; | 39 using gdata::DriveFileSystemInterface; |
|
kinaba
2012/08/23 10:28:46
Can we remove this using declaration? It looks all
kochi
2012/08/23 10:50:32
Done.
| |
| 40 using gdata::GDataSystemService; | 40 using gdata::GDataSystemService; |
| 41 using gdata::GDataSystemServiceFactory; | 41 using gdata::GDataSystemServiceFactory; |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| 44 const char kDiskAddedEventType[] = "added"; | 44 const char kDiskAddedEventType[] = "added"; |
| 45 const char kDiskRemovedEventType[] = "removed"; | 45 const char kDiskRemovedEventType[] = "removed"; |
| 46 | 46 |
| 47 const char kPathChanged[] = "changed"; | 47 const char kPathChanged[] = "changed"; |
| 48 const char kPathWatchError[] = "error"; | 48 const char kPathWatchError[] = "error"; |
| 49 | 49 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 // Raise mount event. | 264 // Raise mount event. |
| 265 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); | 265 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); |
| 266 | 266 |
| 267 if (!callback.is_null()) | 267 if (!callback.is_null()) |
| 268 callback.Run(); | 268 callback.Run(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(bool start) { | 271 void FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(bool start) { |
| 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 273 | 273 |
| 274 gdata::GDataFileSystemInterface* file_system = GetRemoteFileSystem(); | 274 gdata::DriveFileSystemInterface* file_system = GetRemoteFileSystem(); |
| 275 DCHECK(file_system); | 275 DCHECK(file_system); |
| 276 | 276 |
| 277 if (start) { | 277 if (start) { |
| 278 file_system->CheckForUpdates(); | 278 file_system->CheckForUpdates(); |
| 279 if (num_remote_update_requests_ == 0) | 279 if (num_remote_update_requests_ == 0) |
| 280 file_system->StartUpdates(); | 280 file_system->StartUpdates(); |
| 281 ++num_remote_update_requests_; | 281 ++num_remote_update_requests_; |
| 282 } else { | 282 } else { |
| 283 DCHECK_LE(1, num_remote_update_requests_); | 283 DCHECK_LE(1, num_remote_update_requests_); |
| 284 --num_remote_update_requests_; | 284 --num_remote_update_requests_; |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 unsigned int | 811 unsigned int |
| 812 FileBrowserEventRouter::FileWatcherExtensions::GetRefCount() const { | 812 FileBrowserEventRouter::FileWatcherExtensions::GetRefCount() const { |
| 813 return ref_count_; | 813 return ref_count_; |
| 814 } | 814 } |
| 815 | 815 |
| 816 const FilePath& | 816 const FilePath& |
| 817 FileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { | 817 FileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { |
| 818 return virtual_path_; | 818 return virtual_path_; |
| 819 } | 819 } |
| 820 | 820 |
| 821 gdata::GDataFileSystemInterface* | 821 gdata::DriveFileSystemInterface* |
| 822 FileBrowserEventRouter::GetRemoteFileSystem() const { | 822 FileBrowserEventRouter::GetRemoteFileSystem() const { |
| 823 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 823 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 824 gdata::GDataSystemService* system_service = | 824 gdata::GDataSystemService* system_service = |
| 825 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 825 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 826 return (system_service ? system_service->file_system() : NULL); | 826 return (system_service ? system_service->file_system() : NULL); |
| 827 } | 827 } |
| 828 | 828 |
| 829 bool FileBrowserEventRouter::FileWatcherExtensions::Watch | 829 bool FileBrowserEventRouter::FileWatcherExtensions::Watch |
| 830 (const FilePath& path, FileWatcherDelegate* delegate) { | 830 (const FilePath& path, FileWatcherDelegate* delegate) { |
| 831 if (is_remote_file_system_) | 831 if (is_remote_file_system_) |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 861 return scoped_refptr<RefcountedProfileKeyedService>( | 861 return scoped_refptr<RefcountedProfileKeyedService>( |
| 862 new FileBrowserEventRouter(profile)); | 862 new FileBrowserEventRouter(profile)); |
| 863 } | 863 } |
| 864 | 864 |
| 865 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { | 865 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { |
| 866 // Explicitly and always allow this router in guest login mode. see | 866 // Explicitly and always allow this router in guest login mode. see |
| 867 // chrome/browser/profiles/profile_keyed_base_factory.h comment | 867 // chrome/browser/profiles/profile_keyed_base_factory.h comment |
| 868 // for the details. | 868 // for the details. |
| 869 return true; | 869 return true; |
| 870 } | 870 } |
| OLD | NEW |