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 "chrome/browser/chromeos/drive/drive_app_registry.h" | 7 #include "chrome/browser/chromeos/drive/drive_app_registry.h" |
8 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 8 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
9 #include "chrome/browser/chromeos/drive/logging.h" | 9 #include "chrome/browser/chromeos/drive/logging.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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 drive::FileError error, | 388 drive::FileError error, |
389 const GURL& next_link, | 389 const GURL& next_link, |
390 scoped_ptr<std::vector<drive::SearchResultInfo> > results) { | 390 scoped_ptr<std::vector<drive::SearchResultInfo> > results) { |
391 if (error != drive::FILE_ERROR_OK) { | 391 if (error != drive::FILE_ERROR_OK) { |
392 SendResponse(false); | 392 SendResponse(false); |
393 return; | 393 return; |
394 } | 394 } |
395 | 395 |
396 DCHECK(results.get()); | 396 DCHECK(results.get()); |
397 | 397 |
398 base::ListValue* entries = new ListValue(); | 398 base::ListValue* entries = new base::ListValue(); |
399 | 399 |
400 // Convert Drive files to something File API stack can understand. | 400 // Convert Drive files to something File API stack can understand. |
401 fileapi::FileSystemInfo info = | 401 fileapi::FileSystemInfo info = |
402 fileapi::GetFileSystemInfoForChromeOS(source_url_.GetOrigin()); | 402 fileapi::GetFileSystemInfoForChromeOS(source_url_.GetOrigin()); |
403 for (size_t i = 0; i < results->size(); ++i) { | 403 for (size_t i = 0; i < results->size(); ++i) { |
404 DictionaryValue* entry = new DictionaryValue(); | 404 base::DictionaryValue* entry = new base::DictionaryValue(); |
405 entry->SetString("fileSystemName", info.name); | 405 entry->SetString("fileSystemName", info.name); |
406 entry->SetString("fileSystemRoot", info.root_url.spec()); | 406 entry->SetString("fileSystemRoot", info.root_url.spec()); |
407 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); | 407 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); |
408 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); | 408 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); |
409 entries->Append(entry); | 409 entries->Append(entry); |
410 } | 410 } |
411 | 411 |
412 base::DictionaryValue* result = new DictionaryValue(); | 412 base::DictionaryValue* result = new base::DictionaryValue(); |
413 result->Set("entries", entries); | 413 result->Set("entries", entries); |
414 result->SetString("nextFeed", next_link.spec()); | 414 result->SetString("nextFeed", next_link.spec()); |
415 | 415 |
416 SetResult(result); | 416 SetResult(result); |
417 SendResponse(true); | 417 SendResponse(true); |
418 } | 418 } |
419 | 419 |
420 bool FileBrowserPrivateSearchDriveMetadataFunction::RunImpl() { | 420 bool FileBrowserPrivateSearchDriveMetadataFunction::RunImpl() { |
421 using api::file_browser_private::SearchDriveMetadata::Params; | 421 using api::file_browser_private::SearchDriveMetadata::Params; |
422 const scoped_ptr<Params> params(Params::Create(*args_)); | 422 const scoped_ptr<Params> params(Params::Create(*args_)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 void FileBrowserPrivateSearchDriveMetadataFunction::OnSearchMetadata( | 469 void FileBrowserPrivateSearchDriveMetadataFunction::OnSearchMetadata( |
470 drive::FileError error, | 470 drive::FileError error, |
471 scoped_ptr<drive::MetadataSearchResultVector> results) { | 471 scoped_ptr<drive::MetadataSearchResultVector> results) { |
472 if (error != drive::FILE_ERROR_OK) { | 472 if (error != drive::FILE_ERROR_OK) { |
473 SendResponse(false); | 473 SendResponse(false); |
474 return; | 474 return; |
475 } | 475 } |
476 | 476 |
477 DCHECK(results.get()); | 477 DCHECK(results.get()); |
478 | 478 |
479 base::ListValue* results_list = new ListValue(); | 479 base::ListValue* results_list = new base::ListValue(); |
480 | 480 |
481 // Convert Drive files to something File API stack can understand. See | 481 // Convert Drive files to something File API stack can understand. See |
482 // file_browser_handler_custom_bindings.cc and | 482 // file_browser_handler_custom_bindings.cc and |
483 // file_browser_private_custom_bindings.js for how this is magically | 483 // file_browser_private_custom_bindings.js for how this is magically |
484 // converted to a FileEntry. | 484 // converted to a FileEntry. |
485 fileapi::FileSystemInfo info = | 485 fileapi::FileSystemInfo info = |
486 fileapi::GetFileSystemInfoForChromeOS(source_url_.GetOrigin()); | 486 fileapi::GetFileSystemInfoForChromeOS(source_url_.GetOrigin()); |
487 for (size_t i = 0; i < results->size(); ++i) { | 487 for (size_t i = 0; i < results->size(); ++i) { |
488 DictionaryValue* result_dict = new DictionaryValue(); | 488 base::DictionaryValue* result_dict = new base::DictionaryValue(); |
489 | 489 |
490 // FileEntry fields. | 490 // FileEntry fields. |
491 DictionaryValue* entry = new DictionaryValue(); | 491 base::DictionaryValue* entry = new base::DictionaryValue(); |
492 entry->SetString("fileSystemName", info.name); | 492 entry->SetString("fileSystemName", info.name); |
493 entry->SetString("fileSystemRoot", info.root_url.spec()); | 493 entry->SetString("fileSystemRoot", info.root_url.spec()); |
494 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); | 494 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); |
495 entry->SetBoolean("fileIsDirectory", | 495 entry->SetBoolean("fileIsDirectory", |
496 results->at(i).entry.file_info().is_directory()); | 496 results->at(i).entry.file_info().is_directory()); |
497 | 497 |
498 result_dict->Set("entry", entry); | 498 result_dict->Set("entry", entry); |
499 result_dict->SetString("highlightedBaseName", | 499 result_dict->SetString("highlightedBaseName", |
500 results->at(i).highlighted_base_name); | 500 results->at(i).highlighted_base_name); |
501 results_list->Append(result_dict); | 501 results_list->Append(result_dict); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 error_ = "Share Url for this item is not available."; | 602 error_ = "Share Url for this item is not available."; |
603 SendResponse(false); | 603 SendResponse(false); |
604 return; | 604 return; |
605 } | 605 } |
606 | 606 |
607 SetResult(new base::StringValue(share_url.spec())); | 607 SetResult(new base::StringValue(share_url.spec())); |
608 SendResponse(true); | 608 SendResponse(true); |
609 } | 609 } |
610 | 610 |
611 } // namespace extensions | 611 } // namespace extensions |
OLD | NEW |