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 <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 const GURL& next_link, | 756 const GURL& next_link, |
757 std::unique_ptr<SearchResultInfoList> search_result_info_list, | 757 std::unique_ptr<SearchResultInfoList> search_result_info_list, |
758 std::unique_ptr<EntryDefinitionList> entry_definition_list) { | 758 std::unique_ptr<EntryDefinitionList> entry_definition_list) { |
759 DCHECK_EQ(search_result_info_list->size(), entry_definition_list->size()); | 759 DCHECK_EQ(search_result_info_list->size(), entry_definition_list->size()); |
760 base::ListValue* entries = new base::ListValue(); | 760 base::ListValue* entries = new base::ListValue(); |
761 | 761 |
762 // Convert Drive files to something File API stack can understand. | 762 // Convert Drive files to something File API stack can understand. |
763 for (EntryDefinitionList::const_iterator it = entry_definition_list->begin(); | 763 for (EntryDefinitionList::const_iterator it = entry_definition_list->begin(); |
764 it != entry_definition_list->end(); | 764 it != entry_definition_list->end(); |
765 ++it) { | 765 ++it) { |
766 base::DictionaryValue* entry = new base::DictionaryValue(); | 766 auto entry = base::MakeUnique<base::DictionaryValue>(); |
767 entry->SetString("fileSystemName", it->file_system_name); | 767 entry->SetString("fileSystemName", it->file_system_name); |
768 entry->SetString("fileSystemRoot", it->file_system_root_url); | 768 entry->SetString("fileSystemRoot", it->file_system_root_url); |
769 entry->SetString("fileFullPath", "/" + it->full_path.AsUTF8Unsafe()); | 769 entry->SetString("fileFullPath", "/" + it->full_path.AsUTF8Unsafe()); |
770 entry->SetBoolean("fileIsDirectory", it->is_directory); | 770 entry->SetBoolean("fileIsDirectory", it->is_directory); |
771 entries->Append(entry); | 771 entries->Append(std::move(entry)); |
772 } | 772 } |
773 | 773 |
774 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 774 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
775 result->Set("entries", entries); | 775 result->Set("entries", entries); |
776 result->SetString("nextFeed", next_link.spec()); | 776 result->SetString("nextFeed", next_link.spec()); |
777 | 777 |
778 SetResult(std::move(result)); | 778 SetResult(std::move(result)); |
779 SendResponse(true); | 779 SendResponse(true); |
780 } | 780 } |
781 | 781 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 std::unique_ptr<drive::MetadataSearchResultVector> search_result_info_list, | 856 std::unique_ptr<drive::MetadataSearchResultVector> search_result_info_list, |
857 std::unique_ptr<EntryDefinitionList> entry_definition_list) { | 857 std::unique_ptr<EntryDefinitionList> entry_definition_list) { |
858 DCHECK_EQ(search_result_info_list->size(), entry_definition_list->size()); | 858 DCHECK_EQ(search_result_info_list->size(), entry_definition_list->size()); |
859 std::unique_ptr<base::ListValue> results_list(new base::ListValue()); | 859 std::unique_ptr<base::ListValue> results_list(new base::ListValue()); |
860 | 860 |
861 // Convert Drive files to something File API stack can understand. See | 861 // Convert Drive files to something File API stack can understand. See |
862 // file_browser_handler_custom_bindings.cc and | 862 // file_browser_handler_custom_bindings.cc and |
863 // file_manager_private_custom_bindings.js for how this is magically | 863 // file_manager_private_custom_bindings.js for how this is magically |
864 // converted to a FileEntry. | 864 // converted to a FileEntry. |
865 for (size_t i = 0; i < entry_definition_list->size(); ++i) { | 865 for (size_t i = 0; i < entry_definition_list->size(); ++i) { |
866 base::DictionaryValue* result_dict = new base::DictionaryValue(); | 866 auto result_dict = base::MakeUnique<base::DictionaryValue>(); |
867 | 867 |
868 // FileEntry fields. | 868 // FileEntry fields. |
869 base::DictionaryValue* entry = new base::DictionaryValue(); | 869 base::DictionaryValue* entry = new base::DictionaryValue(); |
870 entry->SetString( | 870 entry->SetString( |
871 "fileSystemName", entry_definition_list->at(i).file_system_name); | 871 "fileSystemName", entry_definition_list->at(i).file_system_name); |
872 entry->SetString( | 872 entry->SetString( |
873 "fileSystemRoot", entry_definition_list->at(i).file_system_root_url); | 873 "fileSystemRoot", entry_definition_list->at(i).file_system_root_url); |
874 entry->SetString( | 874 entry->SetString( |
875 "fileFullPath", | 875 "fileFullPath", |
876 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe()); | 876 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe()); |
877 entry->SetBoolean("fileIsDirectory", | 877 entry->SetBoolean("fileIsDirectory", |
878 entry_definition_list->at(i).is_directory); | 878 entry_definition_list->at(i).is_directory); |
879 | 879 |
880 result_dict->Set("entry", entry); | 880 result_dict->Set("entry", entry); |
881 result_dict->SetString( | 881 result_dict->SetString( |
882 "highlightedBaseName", | 882 "highlightedBaseName", |
883 search_result_info_list->at(i).highlighted_base_name); | 883 search_result_info_list->at(i).highlighted_base_name); |
884 results_list->Append(result_dict); | 884 results_list->Append(std::move(result_dict)); |
885 } | 885 } |
886 | 886 |
887 SetResult(std::move(results_list)); | 887 SetResult(std::move(results_list)); |
888 SendResponse(true); | 888 SendResponse(true); |
889 } | 889 } |
890 | 890 |
891 ExtensionFunction::ResponseAction | 891 ExtensionFunction::ResponseAction |
892 FileManagerPrivateGetDriveConnectionStateFunction::Run() { | 892 FileManagerPrivateGetDriveConnectionStateFunction::Run() { |
893 api::file_manager_private::DriveConnectionState result; | 893 api::file_manager_private::DriveConnectionState result; |
894 | 894 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 } | 1144 } |
1145 | 1145 |
1146 const std::string url = | 1146 const std::string url = |
1147 download_url_.Resolve("?alt=media&access_token=" + access_token).spec(); | 1147 download_url_.Resolve("?alt=media&access_token=" + access_token).spec(); |
1148 SetResult(base::MakeUnique<base::StringValue>(url)); | 1148 SetResult(base::MakeUnique<base::StringValue>(url)); |
1149 | 1149 |
1150 SendResponse(true); | 1150 SendResponse(true); |
1151 } | 1151 } |
1152 | 1152 |
1153 } // namespace extensions | 1153 } // namespace extensions |
OLD | NEW |