Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc

Issue 2392693002: Rewrite simple uses of base::ListValue::Append(base::Value*) on CrOS. (Closed)
Patch Set: headers Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
sky 2016/10/03 21:48:18 MakeUnique
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
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 std::unique_ptr<base::DictionaryValue> result_dict(
sky 2016/10/03 21:48:18 MakeUnique (I'm not going to mention it anymore).
867 new base::DictionaryValue());
867 868
868 // FileEntry fields. 869 // FileEntry fields.
869 base::DictionaryValue* entry = new base::DictionaryValue(); 870 base::DictionaryValue* entry = new base::DictionaryValue();
870 entry->SetString( 871 entry->SetString(
871 "fileSystemName", entry_definition_list->at(i).file_system_name); 872 "fileSystemName", entry_definition_list->at(i).file_system_name);
872 entry->SetString( 873 entry->SetString(
873 "fileSystemRoot", entry_definition_list->at(i).file_system_root_url); 874 "fileSystemRoot", entry_definition_list->at(i).file_system_root_url);
874 entry->SetString( 875 entry->SetString(
875 "fileFullPath", 876 "fileFullPath",
876 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe()); 877 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe());
877 entry->SetBoolean("fileIsDirectory", 878 entry->SetBoolean("fileIsDirectory",
878 entry_definition_list->at(i).is_directory); 879 entry_definition_list->at(i).is_directory);
879 880
880 result_dict->Set("entry", entry); 881 result_dict->Set("entry", entry);
881 result_dict->SetString( 882 result_dict->SetString(
882 "highlightedBaseName", 883 "highlightedBaseName",
883 search_result_info_list->at(i).highlighted_base_name); 884 search_result_info_list->at(i).highlighted_base_name);
884 results_list->Append(result_dict); 885 results_list->Append(std::move(result_dict));
885 } 886 }
886 887
887 SetResult(std::move(results_list)); 888 SetResult(std::move(results_list));
888 SendResponse(true); 889 SendResponse(true);
889 } 890 }
890 891
891 ExtensionFunction::ResponseAction 892 ExtensionFunction::ResponseAction
892 FileManagerPrivateGetDriveConnectionStateFunction::Run() { 893 FileManagerPrivateGetDriveConnectionStateFunction::Run() {
893 api::file_manager_private::DriveConnectionState result; 894 api::file_manager_private::DriveConnectionState result;
894 895
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 } 1145 }
1145 1146
1146 const std::string url = 1147 const std::string url =
1147 download_url_.Resolve("?alt=media&access_token=" + access_token).spec(); 1148 download_url_.Resolve("?alt=media&access_token=" + access_token).spec();
1148 SetResult(base::MakeUnique<base::StringValue>(url)); 1149 SetResult(base::MakeUnique<base::StringValue>(url));
1149 1150
1150 SendResponse(true); 1151 SendResponse(true);
1151 } 1152 }
1152 1153
1153 } // namespace extensions 1154 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698