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; | |
40 using gdata::GDataSystemService; | 39 using gdata::GDataSystemService; |
41 using gdata::GDataSystemServiceFactory; | 40 using gdata::GDataSystemServiceFactory; |
42 | 41 |
43 namespace { | 42 namespace { |
44 const char kDiskAddedEventType[] = "added"; | 43 const char kDiskAddedEventType[] = "added"; |
45 const char kDiskRemovedEventType[] = "removed"; | 44 const char kDiskRemovedEventType[] = "removed"; |
46 | 45 |
47 const char kPathChanged[] = "changed"; | 46 const char kPathChanged[] = "changed"; |
48 const char kPathWatchError[] = "error"; | 47 const char kPathWatchError[] = "error"; |
49 | 48 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // Raise mount event. | 263 // Raise mount event. |
265 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); | 264 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); |
266 | 265 |
267 if (!callback.is_null()) | 266 if (!callback.is_null()) |
268 callback.Run(); | 267 callback.Run(); |
269 } | 268 } |
270 | 269 |
271 void FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(bool start) { | 270 void FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(bool start) { |
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
273 | 272 |
274 gdata::GDataFileSystemInterface* file_system = GetRemoteFileSystem(); | 273 gdata::DriveFileSystemInterface* file_system = GetRemoteFileSystem(); |
275 DCHECK(file_system); | 274 DCHECK(file_system); |
276 | 275 |
277 if (start) { | 276 if (start) { |
278 file_system->CheckForUpdates(); | 277 file_system->CheckForUpdates(); |
279 if (num_remote_update_requests_ == 0) | 278 if (num_remote_update_requests_ == 0) |
280 file_system->StartUpdates(); | 279 file_system->StartUpdates(); |
281 ++num_remote_update_requests_; | 280 ++num_remote_update_requests_; |
282 } else { | 281 } else { |
283 DCHECK_LE(1, num_remote_update_requests_); | 282 DCHECK_LE(1, num_remote_update_requests_); |
284 --num_remote_update_requests_; | 283 --num_remote_update_requests_; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 unsigned int | 810 unsigned int |
812 FileBrowserEventRouter::FileWatcherExtensions::GetRefCount() const { | 811 FileBrowserEventRouter::FileWatcherExtensions::GetRefCount() const { |
813 return ref_count_; | 812 return ref_count_; |
814 } | 813 } |
815 | 814 |
816 const FilePath& | 815 const FilePath& |
817 FileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { | 816 FileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { |
818 return virtual_path_; | 817 return virtual_path_; |
819 } | 818 } |
820 | 819 |
821 gdata::GDataFileSystemInterface* | 820 gdata::DriveFileSystemInterface* |
822 FileBrowserEventRouter::GetRemoteFileSystem() const { | 821 FileBrowserEventRouter::GetRemoteFileSystem() const { |
823 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 822 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
824 gdata::GDataSystemService* system_service = | 823 gdata::GDataSystemService* system_service = |
825 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 824 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
826 return (system_service ? system_service->file_system() : NULL); | 825 return (system_service ? system_service->file_system() : NULL); |
827 } | 826 } |
828 | 827 |
829 bool FileBrowserEventRouter::FileWatcherExtensions::Watch | 828 bool FileBrowserEventRouter::FileWatcherExtensions::Watch |
830 (const FilePath& path, FileWatcherDelegate* delegate) { | 829 (const FilePath& path, FileWatcherDelegate* delegate) { |
831 if (is_remote_file_system_) | 830 if (is_remote_file_system_) |
(...skipping 29 matching lines...) Expand all Loading... |
861 return scoped_refptr<RefcountedProfileKeyedService>( | 860 return scoped_refptr<RefcountedProfileKeyedService>( |
862 new FileBrowserEventRouter(profile)); | 861 new FileBrowserEventRouter(profile)); |
863 } | 862 } |
864 | 863 |
865 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { | 864 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { |
866 // Explicitly and always allow this router in guest login mode. see | 865 // Explicitly and always allow this router in guest login mode. see |
867 // chrome/browser/profiles/profile_keyed_base_factory.h comment | 866 // chrome/browser/profiles/profile_keyed_base_factory.h comment |
868 // for the details. | 867 // for the details. |
869 return true; | 868 return true; |
870 } | 869 } |
OLD | NEW |