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_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
6 | 6 |
7 #include <sys/statvfs.h> | 7 #include <sys/statvfs.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
16 #include "base/string_split.h" | 16 #include "base/string_split.h" |
17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/chromeos/cros/cros_library.h" | 20 #include "chrome/browser/chromeos/cros/cros_library.h" |
21 #include "chrome/browser/chromeos/cros/network_library.h" | 21 #include "chrome/browser/chromeos/cros/network_library.h" |
22 #include "chrome/browser/chromeos/extensions/file_handler_util.h" | 22 #include "chrome/browser/chromeos/extensions/file_handler_util.h" |
23 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 23 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
24 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 24 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
25 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" | 25 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" |
| 26 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
26 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 27 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
27 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | |
28 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 28 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
29 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" | 29 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
30 #include "chrome/browser/chromeos/gdata/operation_registry.h" | 30 #include "chrome/browser/chromeos/gdata/operation_registry.h" |
31 #include "chrome/browser/chromeos/system/statistics_provider.h" | 31 #include "chrome/browser/chromeos/system/statistics_provider.h" |
32 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 32 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
33 #include "chrome/browser/extensions/extension_process_manager.h" | 33 #include "chrome/browser/extensions/extension_process_manager.h" |
34 #include "chrome/browser/extensions/extension_service.h" | 34 #include "chrome/browser/extensions/extension_service.h" |
35 #include "chrome/browser/extensions/extension_tab_util.h" | 35 #include "chrome/browser/extensions/extension_tab_util.h" |
36 #include "chrome/browser/extensions/process_map.h" | 36 #include "chrome/browser/extensions/process_map.h" |
37 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (!render_view_host || !render_view_host->GetProcess()) | 193 if (!render_view_host || !render_view_host->GetProcess()) |
194 return; | 194 return; |
195 | 195 |
196 // Grant R/W permissions to gdata 'folder'. File API layer still | 196 // Grant R/W permissions to gdata 'folder'. File API layer still |
197 // expects this to be satisfied. | 197 // expects this to be satisfied. |
198 GrantFilePermissionsToHost(render_view_host, | 198 GrantFilePermissionsToHost(render_view_host, |
199 mount_point, | 199 mount_point, |
200 file_handler_util::GetReadWritePermissions()); | 200 file_handler_util::GetReadWritePermissions()); |
201 | 201 |
202 // Grant R/W permission for tmp and pinned cache folder. | 202 // Grant R/W permission for tmp and pinned cache folder. |
203 gdata::GDataSystemService* system_service = | 203 gdata::DriveSystemService* system_service = |
204 gdata::GDataSystemServiceFactory::GetForProfile(profile); | 204 gdata::DriveSystemServiceFactory::GetForProfile(profile); |
205 // |system_service| is NULL if incognito window / guest login. | 205 // |system_service| is NULL if incognito window / guest login. |
206 if (!system_service || !system_service->file_system()) | 206 if (!system_service || !system_service->file_system()) |
207 return; | 207 return; |
208 gdata::DriveCache* cache = system_service->cache(); | 208 gdata::DriveCache* cache = system_service->cache(); |
209 | 209 |
210 // We check permissions for raw cache file paths only for read-only | 210 // We check permissions for raw cache file paths only for read-only |
211 // operations (when fileEntry.file() is called), so read only permissions | 211 // operations (when fileEntry.file() is called), so read only permissions |
212 // should be sufficient for all cache paths. For the rest of supported | 212 // should be sufficient for all cache paths. For the rest of supported |
213 // operations the file access check is done for drive/ paths. | 213 // operations the file access check is done for drive/ paths. |
214 GrantFilePermissionsToHost(render_view_host, | 214 GrantFilePermissionsToHost(render_view_host, |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 // apps and add them, with generated task ids. Extension ids will be the app_ids | 606 // apps and add them, with generated task ids. Extension ids will be the app_ids |
607 // from drive. We'll know that they are drive apps because the extension id will | 607 // from drive. We'll know that they are drive apps because the extension id will |
608 // begin with kDriveTaskExtensionPrefix. | 608 // begin with kDriveTaskExtensionPrefix. |
609 bool GetFileTasksFileBrowserFunction::FindDriveAppTasks( | 609 bool GetFileTasksFileBrowserFunction::FindDriveAppTasks( |
610 const FileInfoList& file_info_list, | 610 const FileInfoList& file_info_list, |
611 ListValue* result_list) { | 611 ListValue* result_list) { |
612 | 612 |
613 if (file_info_list.empty()) | 613 if (file_info_list.empty()) |
614 return true; | 614 return true; |
615 | 615 |
616 gdata::GDataSystemService* system_service = | 616 gdata::DriveSystemService* system_service = |
617 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 617 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
618 // |system_service| is NULL if incognito window / guest login. We return true | 618 // |system_service| is NULL if incognito window / guest login. We return true |
619 // in this case because there might be other extension tasks, even if we don't | 619 // in this case because there might be other extension tasks, even if we don't |
620 // have any to add. | 620 // have any to add. |
621 if (!system_service || !system_service->webapps_registry()) | 621 if (!system_service || !system_service->webapps_registry()) |
622 return true; | 622 return true; |
623 | 623 |
624 | 624 |
625 gdata::DriveWebAppsRegistry* registry = system_service->webapps_registry(); | 625 gdata::DriveWebAppsRegistry* registry = system_service->webapps_registry(); |
626 | 626 |
627 // Map of app_id to DriveWebAppInfo so we can look up the apps we've found | 627 // Map of app_id to DriveWebAppInfo so we can look up the apps we've found |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1111 | 1111 |
1112 if (!files.size()) { | 1112 if (!files.size()) { |
1113 SendResponse(false); | 1113 SendResponse(false); |
1114 return; | 1114 return; |
1115 } | 1115 } |
1116 | 1116 |
1117 const FilePath& source_path = files[0].local_path; | 1117 const FilePath& source_path = files[0].local_path; |
1118 const FilePath::StringType& display_name = files[0].display_name; | 1118 const FilePath::StringType& display_name = files[0].display_name; |
1119 // Check if the source path is under GData cache directory. | 1119 // Check if the source path is under GData cache directory. |
1120 gdata::GDataSystemService* system_service = | 1120 gdata::DriveSystemService* system_service = |
1121 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1121 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
1122 gdata::DriveCache* cache = system_service ? system_service->cache() : NULL; | 1122 gdata::DriveCache* cache = system_service ? system_service->cache() : NULL; |
1123 if (cache && cache->IsUnderDriveCacheDirectory(source_path)) { | 1123 if (cache && cache->IsUnderDriveCacheDirectory(source_path)) { |
1124 cache->SetMountedStateOnUIThread( | 1124 cache->SetMountedStateOnUIThread( |
1125 source_path, | 1125 source_path, |
1126 true, | 1126 true, |
1127 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, | 1127 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, |
1128 display_name)); | 1128 display_name)); |
1129 } else { | 1129 } else { |
1130 OnMountedStateSet(mount_type_str, display_name, | 1130 OnMountedStateSet(mount_type_str, display_name, |
1131 gdata::DRIVE_FILE_OK, source_path); | 1131 gdata::DRIVE_FILE_OK, source_path); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( | 1240 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( |
1241 const SelectedFileInfoList& files) { | 1241 const SelectedFileInfoList& files) { |
1242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1243 | 1243 |
1244 if (files.size() != 1) { | 1244 if (files.size() != 1) { |
1245 SendResponse(false); | 1245 SendResponse(false); |
1246 return; | 1246 return; |
1247 } | 1247 } |
1248 | 1248 |
1249 if (files[0].file_path == gdata::util::GetGDataMountPointPath()) { | 1249 if (files[0].file_path == gdata::util::GetGDataMountPointPath()) { |
1250 gdata::GDataSystemService* system_service = | 1250 gdata::DriveSystemService* system_service = |
1251 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1251 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
1252 | 1252 |
1253 gdata::DriveFileSystemInterface* file_system = | 1253 gdata::DriveFileSystemInterface* file_system = |
1254 system_service->file_system(); | 1254 system_service->file_system(); |
1255 | 1255 |
1256 file_system->GetAvailableSpace( | 1256 file_system->GetAvailableSpace( |
1257 base::Bind(&GetSizeStatsFunction::GetGDataAvailableSpaceCallback, | 1257 base::Bind(&GetSizeStatsFunction::GetGDataAvailableSpaceCallback, |
1258 this)); | 1258 this)); |
1259 | 1259 |
1260 } else { | 1260 } else { |
1261 BrowserThread::PostTask( | 1261 BrowserThread::PostTask( |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 std::string file_str; | 1781 std::string file_str; |
1782 path_list_->GetString(current_index_, &file_str); | 1782 path_list_->GetString(current_index_, &file_str); |
1783 GURL file_url = GURL(file_str); | 1783 GURL file_url = GURL(file_str); |
1784 FilePath file_path = GetVirtualPathFromURL(file_url); | 1784 FilePath file_path = GetVirtualPathFromURL(file_url); |
1785 | 1785 |
1786 base::DictionaryValue* property_dict = new base::DictionaryValue; | 1786 base::DictionaryValue* property_dict = new base::DictionaryValue; |
1787 property_dict->SetString("fileUrl", file_url.spec()); | 1787 property_dict->SetString("fileUrl", file_url.spec()); |
1788 file_properties_->Append(property_dict); | 1788 file_properties_->Append(property_dict); |
1789 | 1789 |
1790 // Start getting the file info. | 1790 // Start getting the file info. |
1791 gdata::GDataSystemService* system_service = | 1791 gdata::DriveSystemService* system_service = |
1792 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1792 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
1793 system_service->file_system()->GetEntryInfoByPath( | 1793 system_service->file_system()->GetEntryInfoByPath( |
1794 file_path, | 1794 file_path, |
1795 base::Bind(&GetGDataFilePropertiesFunction::OnGetFileInfo, | 1795 base::Bind(&GetGDataFilePropertiesFunction::OnGetFileInfo, |
1796 this, | 1796 this, |
1797 file_path, | 1797 file_path, |
1798 property_dict)); | 1798 property_dict)); |
1799 } | 1799 } |
1800 | 1800 |
1801 void GetGDataFilePropertiesFunction::CompleteGetFileProperties() { | 1801 void GetGDataFilePropertiesFunction::CompleteGetFileProperties() { |
1802 current_index_++; | 1802 current_index_++; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1846 if (!entry_proto->content_url().empty()) { | 1846 if (!entry_proto->content_url().empty()) { |
1847 property_dict->SetString("contentUrl", entry_proto->content_url()); | 1847 property_dict->SetString("contentUrl", entry_proto->content_url()); |
1848 } | 1848 } |
1849 | 1849 |
1850 property_dict->SetBoolean("isHosted", | 1850 property_dict->SetBoolean("isHosted", |
1851 file_specific_info.is_hosted_document()); | 1851 file_specific_info.is_hosted_document()); |
1852 | 1852 |
1853 property_dict->SetString("contentMimeType", | 1853 property_dict->SetString("contentMimeType", |
1854 file_specific_info.content_mime_type()); | 1854 file_specific_info.content_mime_type()); |
1855 | 1855 |
1856 gdata::GDataSystemService* system_service = | 1856 gdata::DriveSystemService* system_service = |
1857 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1857 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
1858 | 1858 |
1859 // Get drive WebApps that can accept this file. | 1859 // Get drive WebApps that can accept this file. |
1860 ScopedVector<gdata::DriveWebAppInfo> web_apps; | 1860 ScopedVector<gdata::DriveWebAppInfo> web_apps; |
1861 system_service->webapps_registry()->GetWebAppsForFile( | 1861 system_service->webapps_registry()->GetWebAppsForFile( |
1862 file_path, file_specific_info.content_mime_type(), &web_apps); | 1862 file_path, file_specific_info.content_mime_type(), &web_apps); |
1863 if (!web_apps.empty()) { | 1863 if (!web_apps.empty()) { |
1864 ListValue* apps = new ListValue(); | 1864 ListValue* apps = new ListValue(); |
1865 property_dict->Set("driveApps", apps); | 1865 property_dict->Set("driveApps", apps); |
1866 for (ScopedVector<gdata::DriveWebAppInfo>::const_iterator it = | 1866 for (ScopedVector<gdata::DriveWebAppInfo>::const_iterator it = |
1867 web_apps.begin(); | 1867 web_apps.begin(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1930 | 1930 |
1931 return true; | 1931 return true; |
1932 } | 1932 } |
1933 | 1933 |
1934 void PinGDataFileFunction::DoOperation( | 1934 void PinGDataFileFunction::DoOperation( |
1935 const FilePath& file_path, | 1935 const FilePath& file_path, |
1936 base::DictionaryValue* properties, | 1936 base::DictionaryValue* properties, |
1937 scoped_ptr<gdata::DriveEntryProto> entry_proto) { | 1937 scoped_ptr<gdata::DriveEntryProto> entry_proto) { |
1938 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1938 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1939 | 1939 |
1940 gdata::GDataSystemService* system_service = | 1940 gdata::DriveSystemService* system_service = |
1941 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1941 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
1942 // This is subtle but we should take references of resource_id and md5 | 1942 // This is subtle but we should take references of resource_id and md5 |
1943 // before |file_info| is passed to |callback| by base::Passed(). Otherwise, | 1943 // before |file_info| is passed to |callback| by base::Passed(). Otherwise, |
1944 // file_info->whatever() crashes. | 1944 // file_info->whatever() crashes. |
1945 const std::string& resource_id = entry_proto->resource_id(); | 1945 const std::string& resource_id = entry_proto->resource_id(); |
1946 const std::string& md5 = entry_proto->file_specific_info().file_md5(); | 1946 const std::string& md5 = entry_proto->file_specific_info().file_md5(); |
1947 const gdata::CacheOperationCallback callback = | 1947 const gdata::CacheOperationCallback callback = |
1948 base::Bind(&PinGDataFileFunction::OnPinStateSet, | 1948 base::Bind(&PinGDataFileFunction::OnPinStateSet, |
1949 this, | 1949 this, |
1950 file_path, | 1950 file_path, |
1951 properties, | 1951 properties, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2056 } | 2056 } |
2057 | 2057 |
2058 void GetGDataFilesFunction::GetFileOrSendResponse() { | 2058 void GetGDataFilesFunction::GetFileOrSendResponse() { |
2059 // Send the response if all files are obtained. | 2059 // Send the response if all files are obtained. |
2060 if (remaining_gdata_paths_.empty()) { | 2060 if (remaining_gdata_paths_.empty()) { |
2061 SetResult(local_paths_); | 2061 SetResult(local_paths_); |
2062 SendResponse(true); | 2062 SendResponse(true); |
2063 return; | 2063 return; |
2064 } | 2064 } |
2065 | 2065 |
2066 gdata::GDataSystemService* system_service = | 2066 gdata::DriveSystemService* system_service = |
2067 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2067 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2068 DCHECK(system_service); | 2068 DCHECK(system_service); |
2069 | 2069 |
2070 // Get the file on the top of the queue. | 2070 // Get the file on the top of the queue. |
2071 FilePath gdata_path = remaining_gdata_paths_.front(); | 2071 FilePath gdata_path = remaining_gdata_paths_.front(); |
2072 system_service->file_system()->GetFileByPath( | 2072 system_service->file_system()->GetFileByPath( |
2073 gdata_path, | 2073 gdata_path, |
2074 base::Bind(&GetGDataFilesFunction::OnFileReady, this), | 2074 base::Bind(&GetGDataFilesFunction::OnFileReady, this), |
2075 gdata::GetContentCallback()); | 2075 gdata::GetContentCallback()); |
2076 } | 2076 } |
2077 | 2077 |
(...skipping 24 matching lines...) Expand all Loading... |
2102 | 2102 |
2103 // Start getting the next file. | 2103 // Start getting the next file. |
2104 GetFileOrSendResponse(); | 2104 GetFileOrSendResponse(); |
2105 } | 2105 } |
2106 | 2106 |
2107 GetFileTransfersFunction::GetFileTransfersFunction() {} | 2107 GetFileTransfersFunction::GetFileTransfersFunction() {} |
2108 | 2108 |
2109 GetFileTransfersFunction::~GetFileTransfersFunction() {} | 2109 GetFileTransfersFunction::~GetFileTransfersFunction() {} |
2110 | 2110 |
2111 ListValue* GetFileTransfersFunction::GetFileTransfersList() { | 2111 ListValue* GetFileTransfersFunction::GetFileTransfersList() { |
2112 gdata::GDataSystemService* system_service = | 2112 gdata::DriveSystemService* system_service = |
2113 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2113 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2114 if (!system_service) | 2114 if (!system_service) |
2115 return NULL; | 2115 return NULL; |
2116 | 2116 |
2117 std::vector<gdata::OperationRegistry::ProgressStatus> | 2117 std::vector<gdata::OperationRegistry::ProgressStatus> |
2118 list = system_service->drive_service()->operation_registry()-> | 2118 list = system_service->drive_service()->operation_registry()-> |
2119 GetProgressStatusList(); | 2119 GetProgressStatusList(); |
2120 return file_manager_util::ProgressStatusVectorToListValue( | 2120 return file_manager_util::ProgressStatusVectorToListValue( |
2121 profile_, source_url_.GetOrigin(), list); | 2121 profile_, source_url_.GetOrigin(), list); |
2122 } | 2122 } |
2123 | 2123 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2157 GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( | 2157 GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( |
2158 file_urls, | 2158 file_urls, |
2159 base::Bind(&CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread, | 2159 base::Bind(&CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread, |
2160 this)); | 2160 this)); |
2161 return true; | 2161 return true; |
2162 } | 2162 } |
2163 | 2163 |
2164 void CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread( | 2164 void CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread( |
2165 const SelectedFileInfoList& files) { | 2165 const SelectedFileInfoList& files) { |
2166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2167 gdata::GDataSystemService* system_service = | 2167 gdata::DriveSystemService* system_service = |
2168 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2168 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2169 if (!system_service) { | 2169 if (!system_service) { |
2170 SendResponse(false); | 2170 SendResponse(false); |
2171 return; | 2171 return; |
2172 } | 2172 } |
2173 | 2173 |
2174 gdata::OperationRegistry* operation_registry = | 2174 gdata::OperationRegistry* operation_registry = |
2175 system_service->drive_service()->operation_registry(); | 2175 system_service->drive_service()->operation_registry(); |
2176 | 2176 |
2177 scoped_ptr<ListValue> responses(new ListValue()); | 2177 scoped_ptr<ListValue> responses(new ListValue()); |
2178 for (size_t i = 0; i < files.size(); ++i) { | 2178 for (size_t i = 0; i < files.size(); ++i) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2220 } | 2220 } |
2221 | 2221 |
2222 void TransferFileFunction::GetLocalPathsResponseOnUIThread( | 2222 void TransferFileFunction::GetLocalPathsResponseOnUIThread( |
2223 const SelectedFileInfoList& files) { | 2223 const SelectedFileInfoList& files) { |
2224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2225 if (files.size() != 2U) { | 2225 if (files.size() != 2U) { |
2226 SendResponse(false); | 2226 SendResponse(false); |
2227 return; | 2227 return; |
2228 } | 2228 } |
2229 | 2229 |
2230 gdata::GDataSystemService* system_service = | 2230 gdata::DriveSystemService* system_service = |
2231 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2231 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2232 if (!system_service) { | 2232 if (!system_service) { |
2233 SendResponse(false); | 2233 SendResponse(false); |
2234 return; | 2234 return; |
2235 } | 2235 } |
2236 | 2236 |
2237 FilePath source_file = files[0].file_path; | 2237 FilePath source_file = files[0].file_path; |
2238 FilePath destination_file = files[1].file_path; | 2238 FilePath destination_file = files[1].file_path; |
2239 | 2239 |
2240 bool source_file_under_gdata = | 2240 bool source_file_under_gdata = |
2241 gdata::util::IsUnderGDataMountPoint(source_file); | 2241 gdata::util::IsUnderGDataMountPoint(source_file); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2342 const std::string& file_system_name, | 2342 const std::string& file_system_name, |
2343 const GURL& file_system_url) { | 2343 const GURL& file_system_url) { |
2344 if (result != base::PLATFORM_FILE_OK) { | 2344 if (result != base::PLATFORM_FILE_OK) { |
2345 SendResponse(false); | 2345 SendResponse(false); |
2346 return; | 2346 return; |
2347 } | 2347 } |
2348 | 2348 |
2349 file_system_name_ = file_system_name; | 2349 file_system_name_ = file_system_name; |
2350 file_system_url_ = file_system_url; | 2350 file_system_url_ = file_system_url; |
2351 | 2351 |
2352 gdata::GDataSystemService* system_service = | 2352 gdata::DriveSystemService* system_service = |
2353 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2353 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2354 if (!system_service || !system_service->file_system()) { | 2354 if (!system_service || !system_service->file_system()) { |
2355 SendResponse(false); | 2355 SendResponse(false); |
2356 return; | 2356 return; |
2357 } | 2357 } |
2358 | 2358 |
2359 system_service->file_system()->Search( | 2359 system_service->file_system()->Search( |
2360 query_, GURL(next_feed_), | 2360 query_, GURL(next_feed_), |
2361 base::Bind(&SearchDriveFunction::OnSearch, this)); | 2361 base::Bind(&SearchDriveFunction::OnSearch, this)); |
2362 } | 2362 } |
2363 | 2363 |
(...skipping 22 matching lines...) Expand all Loading... |
2386 | 2386 |
2387 base::DictionaryValue* result = new DictionaryValue(); | 2387 base::DictionaryValue* result = new DictionaryValue(); |
2388 result->Set("entries", entries); | 2388 result->Set("entries", entries); |
2389 result->SetString("nextFeed", next_feed.spec()); | 2389 result->SetString("nextFeed", next_feed.spec()); |
2390 | 2390 |
2391 SetResult(result); | 2391 SetResult(result); |
2392 SendResponse(true); | 2392 SendResponse(true); |
2393 } | 2393 } |
2394 | 2394 |
2395 bool ClearDriveCacheFunction::RunImpl() { | 2395 bool ClearDriveCacheFunction::RunImpl() { |
2396 gdata::GDataSystemService* system_service = | 2396 gdata::DriveSystemService* system_service = |
2397 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2397 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2398 // |system_service| is NULL if incognito window / guest login. | 2398 // |system_service| is NULL if incognito window / guest login. |
2399 if (!system_service || !system_service->file_system()) | 2399 if (!system_service || !system_service->file_system()) |
2400 return false; | 2400 return false; |
2401 | 2401 |
2402 // TODO(yoshiki): Receive a callback from JS-side and pass it to | 2402 // TODO(yoshiki): Receive a callback from JS-side and pass it to |
2403 // ClearCacheAndRemountFileSystem(). http://crbug.com/140511 | 2403 // ClearCacheAndRemountFileSystem(). http://crbug.com/140511 |
2404 system_service->ClearCacheAndRemountFileSystem(base::Callback<void(bool)>()); | 2404 system_service->ClearCacheAndRemountFileSystem(base::Callback<void(bool)>()); |
2405 | 2405 |
2406 SendResponse(true); | 2406 SendResponse(true); |
2407 return true; | 2407 return true; |
(...skipping 22 matching lines...) Expand all Loading... |
2430 SetResult(value.release()); | 2430 SetResult(value.release()); |
2431 | 2431 |
2432 return true; | 2432 return true; |
2433 } | 2433 } |
2434 | 2434 |
2435 bool RequestDirectoryRefreshFunction::RunImpl() { | 2435 bool RequestDirectoryRefreshFunction::RunImpl() { |
2436 std::string file_url_as_string; | 2436 std::string file_url_as_string; |
2437 if (!args_->GetString(0, &file_url_as_string)) | 2437 if (!args_->GetString(0, &file_url_as_string)) |
2438 return false; | 2438 return false; |
2439 | 2439 |
2440 gdata::GDataSystemService* system_service = | 2440 gdata::DriveSystemService* system_service = |
2441 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2441 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2442 if (!system_service || !system_service->file_system()) | 2442 if (!system_service || !system_service->file_system()) |
2443 return false; | 2443 return false; |
2444 | 2444 |
2445 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2445 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
2446 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2446 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
2447 | 2447 |
2448 return true; | 2448 return true; |
2449 } | 2449 } |
OLD | NEW |