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

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

Issue 2765363004: Stop passing raw pointers to DictionaryValue::Set, part 2 (Closed)
Patch Set: Fix comments Created 3 years, 9 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 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 this, 753 this,
754 next_link, 754 next_link,
755 base::Passed(&results))); 755 base::Passed(&results)));
756 } 756 }
757 757
758 void FileManagerPrivateSearchDriveFunction::OnEntryDefinitionList( 758 void FileManagerPrivateSearchDriveFunction::OnEntryDefinitionList(
759 const GURL& next_link, 759 const GURL& next_link,
760 std::unique_ptr<SearchResultInfoList> search_result_info_list, 760 std::unique_ptr<SearchResultInfoList> search_result_info_list,
761 std::unique_ptr<EntryDefinitionList> entry_definition_list) { 761 std::unique_ptr<EntryDefinitionList> entry_definition_list) {
762 DCHECK_EQ(search_result_info_list->size(), entry_definition_list->size()); 762 DCHECK_EQ(search_result_info_list->size(), entry_definition_list->size());
763 base::ListValue* entries = new base::ListValue(); 763 auto entries = base::MakeUnique<base::ListValue>();
764 764
765 // Convert Drive files to something File API stack can understand. 765 // Convert Drive files to something File API stack can understand.
766 for (EntryDefinitionList::const_iterator it = entry_definition_list->begin(); 766 for (EntryDefinitionList::const_iterator it = entry_definition_list->begin();
767 it != entry_definition_list->end(); 767 it != entry_definition_list->end();
768 ++it) { 768 ++it) {
769 auto entry = base::MakeUnique<base::DictionaryValue>(); 769 auto entry = base::MakeUnique<base::DictionaryValue>();
770 entry->SetString("fileSystemName", it->file_system_name); 770 entry->SetString("fileSystemName", it->file_system_name);
771 entry->SetString("fileSystemRoot", it->file_system_root_url); 771 entry->SetString("fileSystemRoot", it->file_system_root_url);
772 entry->SetString("fileFullPath", "/" + it->full_path.AsUTF8Unsafe()); 772 entry->SetString("fileFullPath", "/" + it->full_path.AsUTF8Unsafe());
773 entry->SetBoolean("fileIsDirectory", it->is_directory); 773 entry->SetBoolean("fileIsDirectory", it->is_directory);
774 entries->Append(std::move(entry)); 774 entries->Append(std::move(entry));
775 } 775 }
776 776
777 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 777 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
778 result->Set("entries", entries); 778 result->Set("entries", std::move(entries));
779 result->SetString("nextFeed", next_link.spec()); 779 result->SetString("nextFeed", next_link.spec());
780 780
781 SetResult(std::move(result)); 781 SetResult(std::move(result));
782 SendResponse(true); 782 SendResponse(true);
783 } 783 }
784 784
785 bool FileManagerPrivateSearchDriveMetadataFunction::RunAsync() { 785 bool FileManagerPrivateSearchDriveMetadataFunction::RunAsync() {
786 using api::file_manager_private::SearchDriveMetadata::Params; 786 using api::file_manager_private::SearchDriveMetadata::Params;
787 const std::unique_ptr<Params> params(Params::Create(*args_)); 787 const std::unique_ptr<Params> params(Params::Create(*args_));
788 EXTENSION_FUNCTION_VALIDATE(params); 788 EXTENSION_FUNCTION_VALIDATE(params);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 std::unique_ptr<base::ListValue> results_list(new base::ListValue()); 862 std::unique_ptr<base::ListValue> results_list(new base::ListValue());
863 863
864 // Convert Drive files to something File API stack can understand. See 864 // Convert Drive files to something File API stack can understand. See
865 // file_browser_handler_custom_bindings.cc and 865 // file_browser_handler_custom_bindings.cc and
866 // file_manager_private_custom_bindings.js for how this is magically 866 // file_manager_private_custom_bindings.js for how this is magically
867 // converted to a FileEntry. 867 // converted to a FileEntry.
868 for (size_t i = 0; i < entry_definition_list->size(); ++i) { 868 for (size_t i = 0; i < entry_definition_list->size(); ++i) {
869 auto result_dict = base::MakeUnique<base::DictionaryValue>(); 869 auto result_dict = base::MakeUnique<base::DictionaryValue>();
870 870
871 // FileEntry fields. 871 // FileEntry fields.
872 base::DictionaryValue* entry = new base::DictionaryValue(); 872 auto entry = base::MakeUnique<base::DictionaryValue>();
873 entry->SetString( 873 entry->SetString(
874 "fileSystemName", entry_definition_list->at(i).file_system_name); 874 "fileSystemName", entry_definition_list->at(i).file_system_name);
875 entry->SetString( 875 entry->SetString(
876 "fileSystemRoot", entry_definition_list->at(i).file_system_root_url); 876 "fileSystemRoot", entry_definition_list->at(i).file_system_root_url);
877 entry->SetString( 877 entry->SetString(
878 "fileFullPath", 878 "fileFullPath",
879 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe()); 879 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe());
880 entry->SetBoolean("fileIsDirectory", 880 entry->SetBoolean("fileIsDirectory",
881 entry_definition_list->at(i).is_directory); 881 entry_definition_list->at(i).is_directory);
882 882
883 result_dict->Set("entry", entry); 883 result_dict->Set("entry", std::move(entry));
884 result_dict->SetString( 884 result_dict->SetString(
885 "highlightedBaseName", 885 "highlightedBaseName",
886 search_result_info_list->at(i).highlighted_base_name); 886 search_result_info_list->at(i).highlighted_base_name);
887 results_list->Append(std::move(result_dict)); 887 results_list->Append(std::move(result_dict));
888 } 888 }
889 889
890 SetResult(std::move(results_list)); 890 SetResult(std::move(results_list));
891 SendResponse(true); 891 SendResponse(true);
892 } 892 }
893 893
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 } 1149 }
1150 1150
1151 const std::string url = 1151 const std::string url =
1152 download_url_.Resolve("?alt=media&access_token=" + access_token).spec(); 1152 download_url_.Resolve("?alt=media&access_token=" + access_token).spec();
1153 SetResult(base::MakeUnique<base::Value>(url)); 1153 SetResult(base::MakeUnique<base::Value>(url));
1154 1154
1155 SendResponse(true); 1155 SendResponse(true);
1156 } 1156 }
1157 1157
1158 } // namespace extensions 1158 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/external_cache_unittest.cc ('k') | chrome/browser/chromeos/extensions/info_private_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698