Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_manager/private_api_drive.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_drive.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 9 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "webkit/common/fileapi/file_system_util.h" | 28 #include "webkit/common/fileapi/file_system_util.h" |
| 29 | 29 |
| 30 using content::BrowserThread; | 30 using content::BrowserThread; |
| 31 | 31 |
| 32 using file_manager::util::EntryDefinition; | 32 using file_manager::util::EntryDefinition; |
| 33 using file_manager::util::EntryDefinitionCallback; | 33 using file_manager::util::EntryDefinitionCallback; |
| 34 using file_manager::util::EntryDefinitionList; | 34 using file_manager::util::EntryDefinitionList; |
| 35 using file_manager::util::EntryDefinitionListCallback; | 35 using file_manager::util::EntryDefinitionListCallback; |
| 36 using file_manager::util::FileDefinition; | 36 using file_manager::util::FileDefinition; |
| 37 using file_manager::util::FileDefinitionList; | 37 using file_manager::util::FileDefinitionList; |
| 38 using extensions::api::file_browser_private::DriveEntryProperties; | 38 using extensions::api::file_browser_private::EntryProperties; |
| 39 | 39 |
| 40 namespace extensions { | 40 namespace extensions { |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 // List of connection types of drive. | 43 // List of connection types of drive. |
| 44 // Keep this in sync with the DriveConnectionType in common/js/util.js. | 44 // Keep this in sync with the DriveConnectionType in common/js/util.js. |
| 45 const char kDriveConnectionTypeOffline[] = "offline"; | 45 const char kDriveConnectionTypeOffline[] = "offline"; |
| 46 const char kDriveConnectionTypeMetered[] = "metered"; | 46 const char kDriveConnectionTypeMetered[] = "metered"; |
| 47 const char kDriveConnectionTypeOnline[] = "online"; | 47 const char kDriveConnectionTypeOnline[] = "online"; |
| 48 | 48 |
| 49 // List of reasons of kDriveConnectionType*. | 49 // List of reasons of kDriveConnectionType*. |
| 50 // Keep this in sync with the DriveConnectionReason in common/js/util.js. | 50 // Keep this in sync with the DriveConnectionReason in common/js/util.js. |
| 51 const char kDriveConnectionReasonNotReady[] = "not_ready"; | 51 const char kDriveConnectionReasonNotReady[] = "not_ready"; |
| 52 const char kDriveConnectionReasonNoNetwork[] = "no_network"; | 52 const char kDriveConnectionReasonNoNetwork[] = "no_network"; |
| 53 const char kDriveConnectionReasonNoService[] = "no_service"; | 53 const char kDriveConnectionReasonNoService[] = "no_service"; |
| 54 | 54 |
| 55 // Copies properties from |entry_proto| to |properties|. |shared_with_me| is | 55 // Copies properties from |entry_proto| to |properties|. |shared_with_me| is |
| 56 // given from the running profile. | 56 // given from the running profile. |
| 57 void FillDriveEntryPropertiesValue(const drive::ResourceEntry& entry_proto, | 57 void FillEntryPropertiesValue(const drive::ResourceEntry& entry_proto, |
| 58 bool shared_with_me, | 58 bool shared_with_me, |
| 59 DriveEntryProperties* properties) { | 59 EntryProperties* properties) { |
| 60 properties->shared_with_me.reset(new bool(shared_with_me)); | 60 properties->shared_with_me.reset(new bool(shared_with_me)); |
| 61 properties->shared.reset(new bool(entry_proto.shared())); | 61 properties->shared.reset(new bool(entry_proto.shared())); |
| 62 | 62 |
| 63 const drive::PlatformFileInfoProto& file_info = entry_proto.file_info(); | 63 const drive::PlatformFileInfoProto& file_info = entry_proto.file_info(); |
| 64 properties->file_size.reset(new double(file_info.size())); | 64 properties->file_size.reset(new double(file_info.size())); |
| 65 properties->last_modified_time.reset(new double( | 65 properties->last_modified_time.reset(new double( |
| 66 base::Time::FromInternalValue(file_info.last_modified()).ToJsTime())); | 66 base::Time::FromInternalValue(file_info.last_modified()).ToJsTime())); |
| 67 | 67 |
| 68 if (!entry_proto.has_file_specific_info()) | 68 if (!entry_proto.has_file_specific_info()) |
| 69 return; | 69 return; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 file_definition_list.push_back(file_definition); | 117 file_definition_list.push_back(file_definition); |
| 118 } | 118 } |
| 119 | 119 |
| 120 file_manager::util::ConvertFileDefinitionListToEntryDefinitionList( | 120 file_manager::util::ConvertFileDefinitionListToEntryDefinitionList( |
| 121 profile, | 121 profile, |
| 122 extension_id, | 122 extension_id, |
| 123 file_definition_list, // Safe, since copied internally. | 123 file_definition_list, // Safe, since copied internally. |
| 124 callback); | 124 callback); |
| 125 } | 125 } |
| 126 | 126 |
| 127 class SingleDriveEntryPropertiesGetter { | 127 class SingleEntryPropertiesGetterForDrive { |
| 128 public: | 128 public: |
| 129 typedef base::Callback<void(drive::FileError error)> ResultCallback; | 129 typedef base::Callback<void(scoped_ptr<EntryProperties> properties, |
| 130 base::File::Error error)> ResultCallback; | |
| 130 | 131 |
| 131 // Creates an instance and starts the process. | 132 // Creates an instance and starts the process. |
| 132 static void Start(const base::FilePath local_path, | 133 static void Start(const base::FilePath local_path, |
| 133 linked_ptr<DriveEntryProperties> properties, | |
| 134 Profile* const profile, | 134 Profile* const profile, |
| 135 const ResultCallback& callback) { | 135 const ResultCallback& callback) { |
| 136 | 136 SingleEntryPropertiesGetterForDrive* instance = |
| 137 SingleDriveEntryPropertiesGetter* instance = | 137 new SingleEntryPropertiesGetterForDrive(local_path, profile, callback); |
| 138 new SingleDriveEntryPropertiesGetter( | |
| 139 local_path, properties, profile, callback); | |
| 140 instance->StartProcess(); | 138 instance->StartProcess(); |
| 141 | 139 |
| 142 // The instance will be destroyed by itself. | 140 // The instance will be destroyed by itself. |
| 143 } | 141 } |
| 144 | 142 |
| 145 virtual ~SingleDriveEntryPropertiesGetter() {} | 143 virtual ~SingleEntryPropertiesGetterForDrive() {} |
| 146 | 144 |
| 147 private: | 145 private: |
| 148 // Given parameters. | 146 // Given parameters. |
| 149 const ResultCallback callback_; | 147 const ResultCallback callback_; |
| 150 const base::FilePath local_path_; | 148 const base::FilePath local_path_; |
| 151 const linked_ptr<DriveEntryProperties> properties_; | |
| 152 Profile* const running_profile_; | 149 Profile* const running_profile_; |
| 153 | 150 |
| 154 // Values used in the process. | 151 // Values used in the process. |
| 152 scoped_ptr<EntryProperties> properties_; | |
| 155 Profile* file_owner_profile_; | 153 Profile* file_owner_profile_; |
| 156 base::FilePath file_path_; | 154 base::FilePath file_path_; |
| 157 scoped_ptr<drive::ResourceEntry> owner_resource_entry_; | 155 scoped_ptr<drive::ResourceEntry> owner_resource_entry_; |
| 158 | 156 |
| 159 base::WeakPtrFactory<SingleDriveEntryPropertiesGetter> weak_ptr_factory_; | 157 base::WeakPtrFactory<SingleEntryPropertiesGetterForDrive> weak_ptr_factory_; |
| 160 | 158 |
| 161 SingleDriveEntryPropertiesGetter(const base::FilePath local_path, | 159 SingleEntryPropertiesGetterForDrive(const base::FilePath local_path, |
| 162 linked_ptr<DriveEntryProperties> properties, | 160 Profile* const profile, |
| 163 Profile* const profile, | 161 const ResultCallback& callback) |
| 164 const ResultCallback& callback) | |
| 165 : callback_(callback), | 162 : callback_(callback), |
| 166 local_path_(local_path), | 163 local_path_(local_path), |
| 167 properties_(properties), | |
| 168 running_profile_(profile), | 164 running_profile_(profile), |
| 165 properties_(new EntryProperties), | |
| 169 file_owner_profile_(NULL), | 166 file_owner_profile_(NULL), |
| 170 weak_ptr_factory_(this) { | 167 weak_ptr_factory_(this) { |
| 171 DCHECK(!callback_.is_null()); | 168 DCHECK(!callback_.is_null()); |
| 172 DCHECK(profile); | 169 DCHECK(profile); |
| 173 } | 170 } |
| 174 | 171 |
| 175 base::WeakPtr<SingleDriveEntryPropertiesGetter> GetWeakPtr() { | 172 base::WeakPtr<SingleEntryPropertiesGetterForDrive> GetWeakPtr() { |
| 176 return weak_ptr_factory_.GetWeakPtr(); | 173 return weak_ptr_factory_.GetWeakPtr(); |
| 177 } | 174 } |
| 178 | 175 |
| 179 void StartProcess() { | 176 void StartProcess() { |
| 180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 181 | 178 |
| 182 file_path_ = drive::util::ExtractDrivePath(local_path_); | 179 file_path_ = drive::util::ExtractDrivePath(local_path_); |
| 183 file_owner_profile_ = drive::util::ExtractProfileFromPath(local_path_); | 180 file_owner_profile_ = drive::util::ExtractProfileFromPath(local_path_); |
| 184 | 181 |
| 185 if (!file_owner_profile_ || | 182 if (!file_owner_profile_ || |
| 186 !g_browser_process->profile_manager()->IsValidProfile( | 183 !g_browser_process->profile_manager()->IsValidProfile( |
| 187 file_owner_profile_)) { | 184 file_owner_profile_)) { |
| 188 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); | 185 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); |
| 189 return; | 186 return; |
| 190 } | 187 } |
| 191 | 188 |
| 192 // Start getting the file info. | 189 // Start getting the file info. |
| 193 drive::FileSystemInterface* const file_system = | 190 drive::FileSystemInterface* const file_system = |
| 194 drive::util::GetFileSystemByProfile(file_owner_profile_); | 191 drive::util::GetFileSystemByProfile(file_owner_profile_); |
| 195 if (!file_system) { | 192 if (!file_system) { |
| 196 // |file_system| is NULL if Drive is disabled or not mounted. | 193 // |file_system| is NULL if Drive is disabled or not mounted. |
| 197 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); | 194 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); |
| 198 return; | 195 return; |
| 199 } | 196 } |
| 200 | 197 |
| 201 file_system->GetResourceEntry( | 198 file_system->GetResourceEntry( |
| 202 file_path_, | 199 file_path_, |
| 203 base::Bind(&SingleDriveEntryPropertiesGetter::OnGetFileInfo, | 200 base::Bind(&SingleEntryPropertiesGetterForDrive::OnGetFileInfo, |
| 204 GetWeakPtr())); | 201 GetWeakPtr())); |
| 205 } | 202 } |
| 206 | 203 |
| 207 void OnGetFileInfo(drive::FileError error, | 204 void OnGetFileInfo(drive::FileError error, |
| 208 scoped_ptr<drive::ResourceEntry> entry) { | 205 scoped_ptr<drive::ResourceEntry> entry) { |
| 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 210 | 207 |
| 211 if (error != drive::FILE_ERROR_OK) { | 208 if (error != drive::FILE_ERROR_OK) { |
| 212 CompleteGetFileProperties(error); | 209 CompleteGetFileProperties(error); |
| 213 return; | 210 return; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 224 // If the running profile does not own the file, obtain the shared_with_me | 221 // If the running profile does not own the file, obtain the shared_with_me |
| 225 // flag from the running profile's value. | 222 // flag from the running profile's value. |
| 226 drive::FileSystemInterface* const file_system = | 223 drive::FileSystemInterface* const file_system = |
| 227 drive::util::GetFileSystemByProfile(running_profile_); | 224 drive::util::GetFileSystemByProfile(running_profile_); |
| 228 if (!file_system) { | 225 if (!file_system) { |
| 229 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); | 226 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); |
| 230 return; | 227 return; |
| 231 } | 228 } |
| 232 file_system->GetPathFromResourceId( | 229 file_system->GetPathFromResourceId( |
| 233 owner_resource_entry_->resource_id(), | 230 owner_resource_entry_->resource_id(), |
| 234 base::Bind(&SingleDriveEntryPropertiesGetter::OnGetRunningPath, | 231 base::Bind(&SingleEntryPropertiesGetterForDrive::OnGetRunningPath, |
| 235 GetWeakPtr())); | 232 GetWeakPtr())); |
| 236 } | 233 } |
| 237 | 234 |
| 238 void OnGetRunningPath(drive::FileError error, | 235 void OnGetRunningPath(drive::FileError error, |
| 239 const base::FilePath& file_path) { | 236 const base::FilePath& file_path) { |
| 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 241 | 238 |
| 242 if (error != drive::FILE_ERROR_OK) { | 239 if (error != drive::FILE_ERROR_OK) { |
| 243 // The running profile does not know the file. | 240 // The running profile does not know the file. |
| 244 StartParseFileInfo(false); | 241 StartParseFileInfo(false); |
| 245 return; | 242 return; |
| 246 } | 243 } |
| 247 | 244 |
| 248 drive::FileSystemInterface* const file_system = | 245 drive::FileSystemInterface* const file_system = |
| 249 drive::util::GetFileSystemByProfile(running_profile_); | 246 drive::util::GetFileSystemByProfile(running_profile_); |
| 250 if (!file_system) { | 247 if (!file_system) { |
| 251 // The drive is disable for the running profile. | 248 // The drive is disable for the running profile. |
| 252 StartParseFileInfo(false); | 249 StartParseFileInfo(false); |
| 253 return; | 250 return; |
| 254 } | 251 } |
| 255 | 252 |
| 256 file_system->GetResourceEntry( | 253 file_system->GetResourceEntry( |
| 257 file_path, | 254 file_path, |
| 258 base::Bind(&SingleDriveEntryPropertiesGetter::OnGetShareInfo, | 255 base::Bind(&SingleEntryPropertiesGetterForDrive::OnGetShareInfo, |
| 259 GetWeakPtr())); | 256 GetWeakPtr())); |
| 260 } | 257 } |
| 261 | 258 |
| 262 void OnGetShareInfo(drive::FileError error, | 259 void OnGetShareInfo(drive::FileError error, |
| 263 scoped_ptr<drive::ResourceEntry> entry) { | 260 scoped_ptr<drive::ResourceEntry> entry) { |
| 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 265 | 262 |
| 266 if (error != drive::FILE_ERROR_OK) { | 263 if (error != drive::FILE_ERROR_OK) { |
| 267 CompleteGetFileProperties(error); | 264 CompleteGetFileProperties(error); |
| 268 return; | 265 return; |
| 269 } | 266 } |
| 270 | 267 |
| 271 DCHECK(entry); | 268 DCHECK(entry); |
| 272 StartParseFileInfo(entry->shared_with_me()); | 269 StartParseFileInfo(entry->shared_with_me()); |
| 273 } | 270 } |
| 274 | 271 |
| 275 void StartParseFileInfo(bool shared_with_me) { | 272 void StartParseFileInfo(bool shared_with_me) { |
| 276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 277 | 274 |
| 278 FillDriveEntryPropertiesValue( | 275 FillEntryPropertiesValue( |
| 279 *owner_resource_entry_, shared_with_me, properties_.get()); | 276 *owner_resource_entry_, shared_with_me, properties_.get()); |
| 280 | 277 |
| 281 drive::FileSystemInterface* const file_system = | 278 drive::FileSystemInterface* const file_system = |
| 282 drive::util::GetFileSystemByProfile(file_owner_profile_); | 279 drive::util::GetFileSystemByProfile(file_owner_profile_); |
| 283 drive::DriveAppRegistry* const app_registry = | 280 drive::DriveAppRegistry* const app_registry = |
| 284 drive::util::GetDriveAppRegistryByProfile(file_owner_profile_); | 281 drive::util::GetDriveAppRegistryByProfile(file_owner_profile_); |
| 285 if (!file_system || !app_registry) { | 282 if (!file_system || !app_registry) { |
| 286 // |file_system| or |app_registry| is NULL if Drive is disabled. | 283 // |file_system| or |app_registry| is NULL if Drive is disabled. |
| 287 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); | 284 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); |
| 288 return; | 285 return; |
| 289 } | 286 } |
| 290 | 287 |
| 291 // The properties meaningful for directories are already filled in | 288 // The properties meaningful for directories are already filled in |
| 292 // FillDriveEntryPropertiesValue(). | 289 // FillEntryPropertiesValue(). |
| 293 if (!owner_resource_entry_->has_file_specific_info()) { | 290 if (!owner_resource_entry_->has_file_specific_info()) { |
| 294 CompleteGetFileProperties(drive::FILE_ERROR_OK); | 291 CompleteGetFileProperties(drive::FILE_ERROR_OK); |
| 295 return; | 292 return; |
| 296 } | 293 } |
| 297 | 294 |
| 298 const drive::FileSpecificInfo& file_specific_info = | 295 const drive::FileSpecificInfo& file_specific_info = |
| 299 owner_resource_entry_->file_specific_info(); | 296 owner_resource_entry_->file_specific_info(); |
| 300 | 297 |
| 301 // Get drive WebApps that can accept this file. We just need to extract the | 298 // Get drive WebApps that can accept this file. We just need to extract the |
| 302 // doc icon for the drive app, which is set as default. | 299 // doc icon for the drive app, which is set as default. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 320 const GURL doc_icon = drive::util::FindPreferredIcon( | 317 const GURL doc_icon = drive::util::FindPreferredIcon( |
| 321 app_info.document_icons, drive::util::kPreferredIconSize); | 318 app_info.document_icons, drive::util::kPreferredIconSize); |
| 322 properties_->custom_icon_url.reset(new std::string(doc_icon.spec())); | 319 properties_->custom_icon_url.reset(new std::string(doc_icon.spec())); |
| 323 } | 320 } |
| 324 } | 321 } |
| 325 } | 322 } |
| 326 | 323 |
| 327 CompleteGetFileProperties(drive::FILE_ERROR_OK); | 324 CompleteGetFileProperties(drive::FILE_ERROR_OK); |
| 328 } | 325 } |
| 329 | 326 |
| 330 void CompleteGetFileProperties(drive::FileError error) { | 327 void CompleteGetFileProperties(drive::FileError error) { |
|
yoshiki
2014/08/28 03:12:39
Didn't you s/FileProperties/EntryProperties/?
mtomasz
2014/08/28 05:18:51
Done.
| |
| 331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 332 DCHECK(!callback_.is_null()); | 329 DCHECK(!callback_.is_null()); |
| 333 callback_.Run(error); | 330 |
| 331 callback_.Run(properties_.Pass(), drive::FileErrorToBaseFileError(error)); | |
| 334 | 332 |
| 335 delete this; | 333 delete this; |
| 336 } | 334 } |
| 337 }; // class SingleDriveEntryPropertiesGetter | 335 }; // class SingleEntryPropertiesGetterForDrive |
| 338 | 336 |
| 339 } // namespace | 337 } // namespace |
| 340 | 338 |
| 341 FileBrowserPrivateGetDriveEntryPropertiesFunction:: | 339 FileBrowserPrivateGetEntryPropertiesFunction:: |
| 342 FileBrowserPrivateGetDriveEntryPropertiesFunction() | 340 FileBrowserPrivateGetEntryPropertiesFunction() |
| 343 : processed_count_(0) {} | 341 : processed_count_(0) { |
| 342 } | |
| 344 | 343 |
| 345 FileBrowserPrivateGetDriveEntryPropertiesFunction:: | 344 FileBrowserPrivateGetEntryPropertiesFunction:: |
| 346 ~FileBrowserPrivateGetDriveEntryPropertiesFunction() {} | 345 ~FileBrowserPrivateGetEntryPropertiesFunction() { |
| 346 } | |
| 347 | 347 |
| 348 bool FileBrowserPrivateGetDriveEntryPropertiesFunction::RunAsync() { | 348 bool FileBrowserPrivateGetEntryPropertiesFunction::RunAsync() { |
| 349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 350 | 350 |
| 351 using api::file_browser_private::GetDriveEntryProperties::Params; | 351 using api::file_browser_private::GetEntryProperties::Params; |
| 352 const scoped_ptr<Params> params(Params::Create(*args_)); | 352 const scoped_ptr<Params> params(Params::Create(*args_)); |
| 353 EXTENSION_FUNCTION_VALIDATE(params); | 353 EXTENSION_FUNCTION_VALIDATE(params); |
| 354 | 354 |
| 355 scoped_refptr<storage::FileSystemContext> file_system_context = | |
| 356 file_manager::util::GetFileSystemContextForRenderViewHost( | |
| 357 GetProfile(), render_view_host()); | |
| 358 | |
| 355 properties_list_.resize(params->file_urls.size()); | 359 properties_list_.resize(params->file_urls.size()); |
| 356 | |
| 357 for (size_t i = 0; i < params->file_urls.size(); i++) { | 360 for (size_t i = 0; i < params->file_urls.size(); i++) { |
| 358 const GURL url = GURL(params->file_urls[i]); | 361 const GURL url = GURL(params->file_urls[i]); |
| 359 const base::FilePath local_path = file_manager::util::GetLocalPathFromURL( | 362 const storage::FileSystemURL file_system_url = |
| 360 render_view_host(), GetProfile(), url); | 363 file_system_context->CrackURL(url); |
| 361 properties_list_[i] = make_linked_ptr(new DriveEntryProperties); | 364 switch (file_system_url.type()) { |
| 362 | 365 case storage::kFileSystemTypeDrive: |
| 363 SingleDriveEntryPropertiesGetter::Start( | 366 SingleEntryPropertiesGetterForDrive::Start( |
| 364 local_path, | 367 file_system_url.path(), |
| 365 properties_list_[i], | 368 GetProfile(), |
| 366 GetProfile(), | 369 base::Bind(&FileBrowserPrivateGetEntryPropertiesFunction:: |
| 367 base::Bind(&FileBrowserPrivateGetDriveEntryPropertiesFunction:: | 370 CompleteGetFileProperties, |
| 368 CompleteGetFileProperties, | 371 this, |
| 369 this)); | 372 i)); |
| 373 break; | |
| 374 case storage::kFileSystemTypeProvided: | |
| 375 // TODO(mtomasz): Add support for provided file systems. | |
| 376 NOTIMPLEMENTED(); | |
| 377 break; | |
| 378 default: | |
| 379 LOG(ERROR) << "Not supported file system type."; | |
| 380 CompleteGetFileProperties(i, | |
| 381 make_scoped_ptr(new EntryProperties), | |
| 382 base::File::FILE_ERROR_INVALID_OPERATION); | |
| 383 } | |
| 370 } | 384 } |
| 371 | 385 |
| 372 return true; | 386 return true; |
| 373 } | 387 } |
| 374 | 388 |
| 375 void FileBrowserPrivateGetDriveEntryPropertiesFunction:: | 389 void FileBrowserPrivateGetEntryPropertiesFunction::CompleteGetFileProperties( |
| 376 CompleteGetFileProperties(drive::FileError error) { | 390 size_t index, |
| 391 scoped_ptr<EntryProperties> properties, | |
| 392 base::File::Error error) { | |
| 377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 378 DCHECK(0 <= processed_count_ && processed_count_ < properties_list_.size()); | 394 DCHECK(0 <= processed_count_ && processed_count_ < properties_list_.size()); |
| 379 | 395 |
| 396 properties_list_[index] = make_linked_ptr(properties.release()); | |
| 397 | |
| 380 processed_count_++; | 398 processed_count_++; |
| 381 if (processed_count_ < properties_list_.size()) | 399 if (processed_count_ < properties_list_.size()) |
| 382 return; | 400 return; |
| 383 | 401 |
| 384 results_ = extensions::api::file_browser_private::GetDriveEntryProperties:: | 402 results_ = extensions::api::file_browser_private::GetEntryProperties:: |
| 385 Results::Create(properties_list_); | 403 Results::Create(properties_list_); |
| 386 SendResponse(true); | 404 SendResponse(true); |
| 387 } | 405 } |
| 388 | 406 |
| 389 bool FileBrowserPrivatePinDriveFileFunction::RunAsync() { | 407 bool FileBrowserPrivatePinDriveFileFunction::RunAsync() { |
| 390 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 391 | 409 |
| 392 using extensions::api::file_browser_private::PinDriveFile::Params; | 410 using extensions::api::file_browser_private::PinDriveFile::Params; |
| 393 const scoped_ptr<Params> params(Params::Create(*args_)); | 411 const scoped_ptr<Params> params(Params::Create(*args_)); |
| 394 EXTENSION_FUNCTION_VALIDATE(params); | 412 EXTENSION_FUNCTION_VALIDATE(params); |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 return; | 993 return; |
| 976 } | 994 } |
| 977 | 995 |
| 978 const std::string url = download_url_ + "?access_token=" + access_token; | 996 const std::string url = download_url_ + "?access_token=" + access_token; |
| 979 SetResult(new base::StringValue(url)); | 997 SetResult(new base::StringValue(url)); |
| 980 | 998 |
| 981 SendResponse(true); | 999 SendResponse(true); |
| 982 } | 1000 } |
| 983 | 1001 |
| 984 } // namespace extensions | 1002 } // namespace extensions |
| OLD | NEW |