| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/string_split.h" | 15 #include "base/string_split.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 20 #include "chrome/browser/chromeos/cros/network_library.h" | 20 #include "chrome/browser/chromeos/cros/network_library.h" |
| 21 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" | 21 #include "chrome/browser/chromeos/disks/disk_mount_manager.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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 if (!render_view_host || !render_view_host->GetProcess()) | 192 if (!render_view_host || !render_view_host->GetProcess()) |
| 193 return; | 193 return; |
| 194 | 194 |
| 195 // Grant R/W permissions to gdata 'folder'. File API layer still | 195 // Grant R/W permissions to gdata 'folder'. File API layer still |
| 196 // expects this to be satisfied. | 196 // expects this to be satisfied. |
| 197 GrantFilePermissionsToHost(render_view_host, | 197 GrantFilePermissionsToHost(render_view_host, |
| 198 mount_point, | 198 mount_point, |
| 199 file_handler_util::GetReadWritePermissions()); | 199 file_handler_util::GetReadWritePermissions()); |
| 200 | 200 |
| 201 // Grant R/W permission for tmp and pinned cache folder. | 201 // Grant R/W permission for tmp and pinned cache folder. |
| 202 gdata::GDataSystemService* system_service = | 202 gdata::DriveSystemService* system_service = |
| 203 gdata::GDataSystemServiceFactory::GetForProfile(profile); | 203 gdata::DriveSystemServiceFactory::GetForProfile(profile); |
| 204 // |system_service| is NULL if incognito window / guest login. | 204 // |system_service| is NULL if incognito window / guest login. |
| 205 if (!system_service || !system_service->file_system()) | 205 if (!system_service || !system_service->file_system()) |
| 206 return; | 206 return; |
| 207 gdata::DriveCache* cache = system_service->cache(); | 207 gdata::DriveCache* cache = system_service->cache(); |
| 208 | 208 |
| 209 // We check permissions for raw cache file paths only for read-only | 209 // We check permissions for raw cache file paths only for read-only |
| 210 // operations (when fileEntry.file() is called), so read only permissions | 210 // operations (when fileEntry.file() is called), so read only permissions |
| 211 // should be sufficient for all cache paths. For the rest of supported | 211 // should be sufficient for all cache paths. For the rest of supported |
| 212 // operations the file access check is done for drive/ paths. | 212 // operations the file access check is done for drive/ paths. |
| 213 GrantFilePermissionsToHost(render_view_host, | 213 GrantFilePermissionsToHost(render_view_host, |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 // apps and add them, with generated task ids. Extension ids will be the app_ids | 585 // apps and add them, with generated task ids. Extension ids will be the app_ids |
| 586 // from drive. We'll know that they are drive apps because the extension id will | 586 // from drive. We'll know that they are drive apps because the extension id will |
| 587 // begin with kDriveTaskExtensionPrefix. | 587 // begin with kDriveTaskExtensionPrefix. |
| 588 bool GetFileTasksFileBrowserFunction::FindDriveAppTasks( | 588 bool GetFileTasksFileBrowserFunction::FindDriveAppTasks( |
| 589 const FileInfoList& file_info_list, | 589 const FileInfoList& file_info_list, |
| 590 ListValue* result_list) { | 590 ListValue* result_list) { |
| 591 | 591 |
| 592 if (file_info_list.empty()) | 592 if (file_info_list.empty()) |
| 593 return true; | 593 return true; |
| 594 | 594 |
| 595 gdata::GDataSystemService* system_service = | 595 gdata::DriveSystemService* system_service = |
| 596 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 596 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 597 // |system_service| is NULL if incognito window / guest login. We return true | 597 // |system_service| is NULL if incognito window / guest login. We return true |
| 598 // in this case because there might be other extension tasks, even if we don't | 598 // in this case because there might be other extension tasks, even if we don't |
| 599 // have any to add. | 599 // have any to add. |
| 600 if (!system_service || !system_service->webapps_registry()) | 600 if (!system_service || !system_service->webapps_registry()) |
| 601 return true; | 601 return true; |
| 602 | 602 |
| 603 | 603 |
| 604 gdata::DriveWebAppsRegistry* registry = system_service->webapps_registry(); | 604 gdata::DriveWebAppsRegistry* registry = system_service->webapps_registry(); |
| 605 | 605 |
| 606 // Map of app_id to DriveWebAppInfo so we can look up the apps we've found | 606 // 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... |
| 1089 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1089 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1090 | 1090 |
| 1091 if (!files.size()) { | 1091 if (!files.size()) { |
| 1092 SendResponse(false); | 1092 SendResponse(false); |
| 1093 return; | 1093 return; |
| 1094 } | 1094 } |
| 1095 | 1095 |
| 1096 const FilePath& source_path = files[0].local_path; | 1096 const FilePath& source_path = files[0].local_path; |
| 1097 const FilePath::StringType& display_name = files[0].display_name; | 1097 const FilePath::StringType& display_name = files[0].display_name; |
| 1098 // Check if the source path is under GData cache directory. | 1098 // Check if the source path is under GData cache directory. |
| 1099 gdata::GDataSystemService* system_service = | 1099 gdata::DriveSystemService* system_service = |
| 1100 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1100 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 1101 gdata::DriveCache* cache = system_service ? system_service->cache() : NULL; | 1101 gdata::DriveCache* cache = system_service ? system_service->cache() : NULL; |
| 1102 if (cache && cache->IsUnderDriveCacheDirectory(source_path)) { | 1102 if (cache && cache->IsUnderDriveCacheDirectory(source_path)) { |
| 1103 cache->SetMountedStateOnUIThread( | 1103 cache->SetMountedStateOnUIThread( |
| 1104 source_path, | 1104 source_path, |
| 1105 true, | 1105 true, |
| 1106 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, | 1106 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, |
| 1107 display_name)); | 1107 display_name)); |
| 1108 } else { | 1108 } else { |
| 1109 OnMountedStateSet(mount_type_str, display_name, | 1109 OnMountedStateSet(mount_type_str, display_name, |
| 1110 gdata::DRIVE_FILE_OK, source_path); | 1110 gdata::DRIVE_FILE_OK, source_path); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( | 1219 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( |
| 1220 const SelectedFileInfoList& files) { | 1220 const SelectedFileInfoList& files) { |
| 1221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1222 | 1222 |
| 1223 if (files.size() != 1) { | 1223 if (files.size() != 1) { |
| 1224 SendResponse(false); | 1224 SendResponse(false); |
| 1225 return; | 1225 return; |
| 1226 } | 1226 } |
| 1227 | 1227 |
| 1228 if (files[0].file_path == gdata::util::GetGDataMountPointPath()) { | 1228 if (files[0].file_path == gdata::util::GetGDataMountPointPath()) { |
| 1229 gdata::GDataSystemService* system_service = | 1229 gdata::DriveSystemService* system_service = |
| 1230 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1230 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 1231 | 1231 |
| 1232 gdata::DriveFileSystemInterface* file_system = | 1232 gdata::DriveFileSystemInterface* file_system = |
| 1233 system_service->file_system(); | 1233 system_service->file_system(); |
| 1234 | 1234 |
| 1235 file_system->GetAvailableSpace( | 1235 file_system->GetAvailableSpace( |
| 1236 base::Bind(&GetSizeStatsFunction::GetGDataAvailableSpaceCallback, | 1236 base::Bind(&GetSizeStatsFunction::GetGDataAvailableSpaceCallback, |
| 1237 this)); | 1237 this)); |
| 1238 | 1238 |
| 1239 } else { | 1239 } else { |
| 1240 BrowserThread::PostTask( | 1240 BrowserThread::PostTask( |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 std::string file_str; | 1761 std::string file_str; |
| 1762 path_list_->GetString(current_index_, &file_str); | 1762 path_list_->GetString(current_index_, &file_str); |
| 1763 GURL file_url = GURL(file_str); | 1763 GURL file_url = GURL(file_str); |
| 1764 FilePath file_path = GetVirtualPathFromURL(file_url); | 1764 FilePath file_path = GetVirtualPathFromURL(file_url); |
| 1765 | 1765 |
| 1766 base::DictionaryValue* property_dict = new base::DictionaryValue; | 1766 base::DictionaryValue* property_dict = new base::DictionaryValue; |
| 1767 property_dict->SetString("fileUrl", file_url.spec()); | 1767 property_dict->SetString("fileUrl", file_url.spec()); |
| 1768 file_properties_->Append(property_dict); | 1768 file_properties_->Append(property_dict); |
| 1769 | 1769 |
| 1770 // Start getting the file info. | 1770 // Start getting the file info. |
| 1771 gdata::GDataSystemService* system_service = | 1771 gdata::DriveSystemService* system_service = |
| 1772 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1772 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 1773 system_service->file_system()->GetEntryInfoByPath( | 1773 system_service->file_system()->GetEntryInfoByPath( |
| 1774 file_path, | 1774 file_path, |
| 1775 base::Bind(&GetGDataFilePropertiesFunction::OnGetFileInfo, | 1775 base::Bind(&GetGDataFilePropertiesFunction::OnGetFileInfo, |
| 1776 this, | 1776 this, |
| 1777 file_path, | 1777 file_path, |
| 1778 property_dict)); | 1778 property_dict)); |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 void GetGDataFilePropertiesFunction::CompleteGetFileProperties() { | 1781 void GetGDataFilePropertiesFunction::CompleteGetFileProperties() { |
| 1782 current_index_++; | 1782 current_index_++; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 if (!entry_proto->content_url().empty()) { | 1826 if (!entry_proto->content_url().empty()) { |
| 1827 property_dict->SetString("contentUrl", entry_proto->content_url()); | 1827 property_dict->SetString("contentUrl", entry_proto->content_url()); |
| 1828 } | 1828 } |
| 1829 | 1829 |
| 1830 property_dict->SetBoolean("isHosted", | 1830 property_dict->SetBoolean("isHosted", |
| 1831 file_specific_info.is_hosted_document()); | 1831 file_specific_info.is_hosted_document()); |
| 1832 | 1832 |
| 1833 property_dict->SetString("contentMimeType", | 1833 property_dict->SetString("contentMimeType", |
| 1834 file_specific_info.content_mime_type()); | 1834 file_specific_info.content_mime_type()); |
| 1835 | 1835 |
| 1836 gdata::GDataSystemService* system_service = | 1836 gdata::DriveSystemService* system_service = |
| 1837 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1837 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 1838 | 1838 |
| 1839 // Get drive WebApps that can accept this file. | 1839 // Get drive WebApps that can accept this file. |
| 1840 ScopedVector<gdata::DriveWebAppInfo> web_apps; | 1840 ScopedVector<gdata::DriveWebAppInfo> web_apps; |
| 1841 system_service->webapps_registry()->GetWebAppsForFile( | 1841 system_service->webapps_registry()->GetWebAppsForFile( |
| 1842 file_path, file_specific_info.content_mime_type(), &web_apps); | 1842 file_path, file_specific_info.content_mime_type(), &web_apps); |
| 1843 if (!web_apps.empty()) { | 1843 if (!web_apps.empty()) { |
| 1844 ListValue* apps = new ListValue(); | 1844 ListValue* apps = new ListValue(); |
| 1845 property_dict->Set("driveApps", apps); | 1845 property_dict->Set("driveApps", apps); |
| 1846 for (ScopedVector<gdata::DriveWebAppInfo>::const_iterator it = | 1846 for (ScopedVector<gdata::DriveWebAppInfo>::const_iterator it = |
| 1847 web_apps.begin(); | 1847 web_apps.begin(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 | 1910 |
| 1911 return true; | 1911 return true; |
| 1912 } | 1912 } |
| 1913 | 1913 |
| 1914 void PinGDataFileFunction::DoOperation( | 1914 void PinGDataFileFunction::DoOperation( |
| 1915 const FilePath& file_path, | 1915 const FilePath& file_path, |
| 1916 base::DictionaryValue* properties, | 1916 base::DictionaryValue* properties, |
| 1917 scoped_ptr<gdata::DriveEntryProto> entry_proto) { | 1917 scoped_ptr<gdata::DriveEntryProto> entry_proto) { |
| 1918 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1918 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1919 | 1919 |
| 1920 gdata::GDataSystemService* system_service = | 1920 gdata::DriveSystemService* system_service = |
| 1921 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1921 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 1922 // This is subtle but we should take references of resource_id and md5 | 1922 // This is subtle but we should take references of resource_id and md5 |
| 1923 // before |file_info| is passed to |callback| by base::Passed(). Otherwise, | 1923 // before |file_info| is passed to |callback| by base::Passed(). Otherwise, |
| 1924 // file_info->whatever() crashes. | 1924 // file_info->whatever() crashes. |
| 1925 const std::string& resource_id = entry_proto->resource_id(); | 1925 const std::string& resource_id = entry_proto->resource_id(); |
| 1926 const std::string& md5 = entry_proto->file_specific_info().file_md5(); | 1926 const std::string& md5 = entry_proto->file_specific_info().file_md5(); |
| 1927 const gdata::CacheOperationCallback callback = | 1927 const gdata::CacheOperationCallback callback = |
| 1928 base::Bind(&PinGDataFileFunction::OnPinStateSet, | 1928 base::Bind(&PinGDataFileFunction::OnPinStateSet, |
| 1929 this, | 1929 this, |
| 1930 file_path, | 1930 file_path, |
| 1931 properties, | 1931 properties, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 } | 2036 } |
| 2037 | 2037 |
| 2038 void GetGDataFilesFunction::GetFileOrSendResponse() { | 2038 void GetGDataFilesFunction::GetFileOrSendResponse() { |
| 2039 // Send the response if all files are obtained. | 2039 // Send the response if all files are obtained. |
| 2040 if (remaining_gdata_paths_.empty()) { | 2040 if (remaining_gdata_paths_.empty()) { |
| 2041 SetResult(local_paths_); | 2041 SetResult(local_paths_); |
| 2042 SendResponse(true); | 2042 SendResponse(true); |
| 2043 return; | 2043 return; |
| 2044 } | 2044 } |
| 2045 | 2045 |
| 2046 gdata::GDataSystemService* system_service = | 2046 gdata::DriveSystemService* system_service = |
| 2047 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2047 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 2048 DCHECK(system_service); | 2048 DCHECK(system_service); |
| 2049 | 2049 |
| 2050 // Get the file on the top of the queue. | 2050 // Get the file on the top of the queue. |
| 2051 FilePath gdata_path = remaining_gdata_paths_.front(); | 2051 FilePath gdata_path = remaining_gdata_paths_.front(); |
| 2052 system_service->file_system()->GetFileByPath( | 2052 system_service->file_system()->GetFileByPath( |
| 2053 gdata_path, | 2053 gdata_path, |
| 2054 base::Bind(&GetGDataFilesFunction::OnFileReady, this), | 2054 base::Bind(&GetGDataFilesFunction::OnFileReady, this), |
| 2055 gdata::GetContentCallback()); | 2055 gdata::GetContentCallback()); |
| 2056 } | 2056 } |
| 2057 | 2057 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2082 | 2082 |
| 2083 // Start getting the next file. | 2083 // Start getting the next file. |
| 2084 GetFileOrSendResponse(); | 2084 GetFileOrSendResponse(); |
| 2085 } | 2085 } |
| 2086 | 2086 |
| 2087 GetFileTransfersFunction::GetFileTransfersFunction() {} | 2087 GetFileTransfersFunction::GetFileTransfersFunction() {} |
| 2088 | 2088 |
| 2089 GetFileTransfersFunction::~GetFileTransfersFunction() {} | 2089 GetFileTransfersFunction::~GetFileTransfersFunction() {} |
| 2090 | 2090 |
| 2091 ListValue* GetFileTransfersFunction::GetFileTransfersList() { | 2091 ListValue* GetFileTransfersFunction::GetFileTransfersList() { |
| 2092 gdata::GDataSystemService* system_service = | 2092 gdata::DriveSystemService* system_service = |
| 2093 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2093 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 2094 if (!system_service) | 2094 if (!system_service) |
| 2095 return NULL; | 2095 return NULL; |
| 2096 | 2096 |
| 2097 std::vector<gdata::OperationRegistry::ProgressStatus> | 2097 std::vector<gdata::OperationRegistry::ProgressStatus> |
| 2098 list = system_service->drive_service()->operation_registry()-> | 2098 list = system_service->drive_service()->operation_registry()-> |
| 2099 GetProgressStatusList(); | 2099 GetProgressStatusList(); |
| 2100 return file_manager_util::ProgressStatusVectorToListValue( | 2100 return file_manager_util::ProgressStatusVectorToListValue( |
| 2101 profile_, source_url_.GetOrigin(), list); | 2101 profile_, source_url_.GetOrigin(), list); |
| 2102 } | 2102 } |
| 2103 | 2103 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2137 GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( | 2137 GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( |
| 2138 file_urls, | 2138 file_urls, |
| 2139 base::Bind(&CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread, | 2139 base::Bind(&CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread, |
| 2140 this)); | 2140 this)); |
| 2141 return true; | 2141 return true; |
| 2142 } | 2142 } |
| 2143 | 2143 |
| 2144 void CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread( | 2144 void CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread( |
| 2145 const SelectedFileInfoList& files) { | 2145 const SelectedFileInfoList& files) { |
| 2146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2147 gdata::GDataSystemService* system_service = | 2147 gdata::DriveSystemService* system_service = |
| 2148 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2148 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 2149 if (!system_service) { | 2149 if (!system_service) { |
| 2150 SendResponse(false); | 2150 SendResponse(false); |
| 2151 return; | 2151 return; |
| 2152 } | 2152 } |
| 2153 | 2153 |
| 2154 gdata::OperationRegistry* operation_registry = | 2154 gdata::OperationRegistry* operation_registry = |
| 2155 system_service->drive_service()->operation_registry(); | 2155 system_service->drive_service()->operation_registry(); |
| 2156 | 2156 |
| 2157 scoped_ptr<ListValue> responses(new ListValue()); | 2157 scoped_ptr<ListValue> responses(new ListValue()); |
| 2158 for (size_t i = 0; i < files.size(); ++i) { | 2158 for (size_t i = 0; i < files.size(); ++i) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 } | 2200 } |
| 2201 | 2201 |
| 2202 void TransferFileFunction::GetLocalPathsResponseOnUIThread( | 2202 void TransferFileFunction::GetLocalPathsResponseOnUIThread( |
| 2203 const SelectedFileInfoList& files) { | 2203 const SelectedFileInfoList& files) { |
| 2204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2205 if (files.size() != 2U) { | 2205 if (files.size() != 2U) { |
| 2206 SendResponse(false); | 2206 SendResponse(false); |
| 2207 return; | 2207 return; |
| 2208 } | 2208 } |
| 2209 | 2209 |
| 2210 gdata::GDataSystemService* system_service = | 2210 gdata::DriveSystemService* system_service = |
| 2211 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2211 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 2212 if (!system_service) { | 2212 if (!system_service) { |
| 2213 SendResponse(false); | 2213 SendResponse(false); |
| 2214 return; | 2214 return; |
| 2215 } | 2215 } |
| 2216 | 2216 |
| 2217 FilePath source_file = files[0].file_path; | 2217 FilePath source_file = files[0].file_path; |
| 2218 FilePath destination_file = files[1].file_path; | 2218 FilePath destination_file = files[1].file_path; |
| 2219 | 2219 |
| 2220 bool source_file_under_gdata = | 2220 bool source_file_under_gdata = |
| 2221 gdata::util::IsUnderGDataMountPoint(source_file); | 2221 gdata::util::IsUnderGDataMountPoint(source_file); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2322 const std::string& file_system_name, | 2322 const std::string& file_system_name, |
| 2323 const GURL& file_system_url) { | 2323 const GURL& file_system_url) { |
| 2324 if (result != base::PLATFORM_FILE_OK) { | 2324 if (result != base::PLATFORM_FILE_OK) { |
| 2325 SendResponse(false); | 2325 SendResponse(false); |
| 2326 return; | 2326 return; |
| 2327 } | 2327 } |
| 2328 | 2328 |
| 2329 file_system_name_ = file_system_name; | 2329 file_system_name_ = file_system_name; |
| 2330 file_system_url_ = file_system_url; | 2330 file_system_url_ = file_system_url; |
| 2331 | 2331 |
| 2332 gdata::GDataSystemService* system_service = | 2332 gdata::DriveSystemService* system_service = |
| 2333 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2333 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 2334 if (!system_service || !system_service->file_system()) { | 2334 if (!system_service || !system_service->file_system()) { |
| 2335 SendResponse(false); | 2335 SendResponse(false); |
| 2336 return; | 2336 return; |
| 2337 } | 2337 } |
| 2338 | 2338 |
| 2339 system_service->file_system()->Search( | 2339 system_service->file_system()->Search( |
| 2340 query_, GURL(next_feed_), | 2340 query_, GURL(next_feed_), |
| 2341 base::Bind(&SearchDriveFunction::OnSearch, this)); | 2341 base::Bind(&SearchDriveFunction::OnSearch, this)); |
| 2342 } | 2342 } |
| 2343 | 2343 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2366 | 2366 |
| 2367 base::DictionaryValue* result = new DictionaryValue(); | 2367 base::DictionaryValue* result = new DictionaryValue(); |
| 2368 result->Set("entries", entries); | 2368 result->Set("entries", entries); |
| 2369 result->SetString("nextFeed", next_feed.spec()); | 2369 result->SetString("nextFeed", next_feed.spec()); |
| 2370 | 2370 |
| 2371 SetResult(result); | 2371 SetResult(result); |
| 2372 SendResponse(true); | 2372 SendResponse(true); |
| 2373 } | 2373 } |
| 2374 | 2374 |
| 2375 bool ClearDriveCacheFunction::RunImpl() { | 2375 bool ClearDriveCacheFunction::RunImpl() { |
| 2376 gdata::GDataSystemService* system_service = | 2376 gdata::DriveSystemService* system_service = |
| 2377 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2377 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 2378 // |system_service| is NULL if incognito window / guest login. | 2378 // |system_service| is NULL if incognito window / guest login. |
| 2379 if (!system_service || !system_service->file_system()) | 2379 if (!system_service || !system_service->file_system()) |
| 2380 return false; | 2380 return false; |
| 2381 | 2381 |
| 2382 // TODO(yoshiki): Receive a callback from JS-side and pass it to | 2382 // TODO(yoshiki): Receive a callback from JS-side and pass it to |
| 2383 // ClearCacheAndRemountFileSystem(). http://crbug.com/140511 | 2383 // ClearCacheAndRemountFileSystem(). http://crbug.com/140511 |
| 2384 system_service->ClearCacheAndRemountFileSystem(base::Callback<void(bool)>()); | 2384 system_service->ClearCacheAndRemountFileSystem(base::Callback<void(bool)>()); |
| 2385 | 2385 |
| 2386 SendResponse(true); | 2386 SendResponse(true); |
| 2387 return true; | 2387 return true; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2410 SetResult(value.release()); | 2410 SetResult(value.release()); |
| 2411 | 2411 |
| 2412 return true; | 2412 return true; |
| 2413 } | 2413 } |
| 2414 | 2414 |
| 2415 bool RequestDirectoryRefreshFunction::RunImpl() { | 2415 bool RequestDirectoryRefreshFunction::RunImpl() { |
| 2416 std::string file_url_as_string; | 2416 std::string file_url_as_string; |
| 2417 if (!args_->GetString(0, &file_url_as_string)) | 2417 if (!args_->GetString(0, &file_url_as_string)) |
| 2418 return false; | 2418 return false; |
| 2419 | 2419 |
| 2420 gdata::GDataSystemService* system_service = | 2420 gdata::DriveSystemService* system_service = |
| 2421 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2421 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
| 2422 if (!system_service || !system_service->file_system()) | 2422 if (!system_service || !system_service->file_system()) |
| 2423 return false; | 2423 return false; |
| 2424 | 2424 |
| 2425 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2425 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
| 2426 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2426 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
| 2427 | 2427 |
| 2428 return true; | 2428 return true; |
| 2429 } | 2429 } |
| OLD | NEW |