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

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

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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_tasks.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_tasks.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 return mime_types; 63 return mime_types;
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 bool FileManagerPrivateInternalExecuteTaskFunction::RunAsync() { 68 bool FileManagerPrivateInternalExecuteTaskFunction::RunAsync() {
69 using extensions::api::file_manager_private_internal::ExecuteTask::Params; 69 using extensions::api::file_manager_private_internal::ExecuteTask::Params;
70 using extensions::api::file_manager_private_internal::ExecuteTask::Results:: 70 using extensions::api::file_manager_private_internal::ExecuteTask::Results::
71 Create; 71 Create;
72 const scoped_ptr<Params> params(Params::Create(*args_)); 72 const std::unique_ptr<Params> params(Params::Create(*args_));
73 EXTENSION_FUNCTION_VALIDATE(params); 73 EXTENSION_FUNCTION_VALIDATE(params);
74 74
75 file_manager::file_tasks::TaskDescriptor task; 75 file_manager::file_tasks::TaskDescriptor task;
76 if (!file_manager::file_tasks::ParseTaskID(params->task_id, &task)) { 76 if (!file_manager::file_tasks::ParseTaskID(params->task_id, &task)) {
77 SetError(kInvalidTask + params->task_id); 77 SetError(kInvalidTask + params->task_id);
78 results_ = 78 results_ =
79 Create(extensions::api::file_manager_private::TASK_RESULT_FAILED); 79 Create(extensions::api::file_manager_private::TASK_RESULT_FAILED);
80 return false; 80 return false;
81 } 81 }
82 82
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 124
125 FileManagerPrivateInternalGetFileTasksFunction:: 125 FileManagerPrivateInternalGetFileTasksFunction::
126 FileManagerPrivateInternalGetFileTasksFunction() {} 126 FileManagerPrivateInternalGetFileTasksFunction() {}
127 127
128 FileManagerPrivateInternalGetFileTasksFunction:: 128 FileManagerPrivateInternalGetFileTasksFunction::
129 ~FileManagerPrivateInternalGetFileTasksFunction() {} 129 ~FileManagerPrivateInternalGetFileTasksFunction() {}
130 130
131 bool FileManagerPrivateInternalGetFileTasksFunction::RunAsync() { 131 bool FileManagerPrivateInternalGetFileTasksFunction::RunAsync() {
132 using extensions::api::file_manager_private_internal::GetFileTasks::Params; 132 using extensions::api::file_manager_private_internal::GetFileTasks::Params;
133 const scoped_ptr<Params> params(Params::Create(*args_)); 133 const std::unique_ptr<Params> params(Params::Create(*args_));
134 EXTENSION_FUNCTION_VALIDATE(params); 134 EXTENSION_FUNCTION_VALIDATE(params);
135 135
136 if (params->urls.empty()) 136 if (params->urls.empty())
137 return false; 137 return false;
138 138
139 const scoped_refptr<storage::FileSystemContext> file_system_context = 139 const scoped_refptr<storage::FileSystemContext> file_system_context =
140 file_manager::util::GetFileSystemContextForRenderFrameHost( 140 file_manager::util::GetFileSystemContextForRenderFrameHost(
141 GetProfile(), render_frame_host()); 141 GetProfile(), render_frame_host());
142 142
143 // Collect all the URLs, convert them to GURLs, and crack all the urls into 143 // Collect all the URLs, convert them to GURLs, and crack all the urls into
(...skipping 12 matching lines...) Expand all
156 mime_type_collector_->CollectForLocalPaths( 156 mime_type_collector_->CollectForLocalPaths(
157 local_paths_, 157 local_paths_,
158 base::Bind( 158 base::Bind(
159 &FileManagerPrivateInternalGetFileTasksFunction::OnMimeTypesCollected, 159 &FileManagerPrivateInternalGetFileTasksFunction::OnMimeTypesCollected,
160 this)); 160 this));
161 161
162 return true; 162 return true;
163 } 163 }
164 164
165 void FileManagerPrivateInternalGetFileTasksFunction::OnMimeTypesCollected( 165 void FileManagerPrivateInternalGetFileTasksFunction::OnMimeTypesCollected(
166 scoped_ptr<std::vector<std::string>> mime_types) { 166 std::unique_ptr<std::vector<std::string>> mime_types) {
167 is_directory_collector_.reset( 167 is_directory_collector_.reset(
168 new app_file_handler_util::IsDirectoryCollector(GetProfile())); 168 new app_file_handler_util::IsDirectoryCollector(GetProfile()));
169 is_directory_collector_->CollectForEntriesPaths( 169 is_directory_collector_->CollectForEntriesPaths(
170 local_paths_, base::Bind(&FileManagerPrivateInternalGetFileTasksFunction:: 170 local_paths_, base::Bind(&FileManagerPrivateInternalGetFileTasksFunction::
171 OnAreDirectoriesAndMimeTypesCollected, 171 OnAreDirectoriesAndMimeTypesCollected,
172 this, base::Passed(std::move(mime_types)))); 172 this, base::Passed(std::move(mime_types))));
173 } 173 }
174 174
175 void FileManagerPrivateInternalGetFileTasksFunction:: 175 void FileManagerPrivateInternalGetFileTasksFunction::
176 OnAreDirectoriesAndMimeTypesCollected( 176 OnAreDirectoriesAndMimeTypesCollected(
177 scoped_ptr<std::vector<std::string>> mime_types, 177 std::unique_ptr<std::vector<std::string>> mime_types,
178 scoped_ptr<std::set<base::FilePath>> directory_paths) { 178 std::unique_ptr<std::set<base::FilePath>> directory_paths) {
179 std::vector<EntryInfo> entries; 179 std::vector<EntryInfo> entries;
180 for (size_t i = 0; i < local_paths_.size(); ++i) { 180 for (size_t i = 0; i < local_paths_.size(); ++i) {
181 entries.push_back(EntryInfo( 181 entries.push_back(EntryInfo(
182 local_paths_[i], (*mime_types)[i], 182 local_paths_[i], (*mime_types)[i],
183 directory_paths->find(local_paths_[i]) != directory_paths->end())); 183 directory_paths->find(local_paths_[i]) != directory_paths->end()));
184 } 184 }
185 185
186 std::vector<file_manager::file_tasks::FullTaskDescriptor> tasks; 186 std::vector<file_manager::file_tasks::FullTaskDescriptor> tasks;
187 file_manager::file_tasks::FindAllTypesOfTasks( 187 file_manager::file_tasks::FindAllTypesOfTasks(
188 GetProfile(), drive::util::GetDriveAppRegistryByProfile(GetProfile()), 188 GetProfile(), drive::util::GetDriveAppRegistryByProfile(GetProfile()),
(...skipping 14 matching lines...) Expand all
203 results.push_back(std::move(converted)); 203 results.push_back(std::move(converted));
204 } 204 }
205 205
206 results_ = extensions::api::file_manager_private_internal::GetFileTasks:: 206 results_ = extensions::api::file_manager_private_internal::GetFileTasks::
207 Results::Create(results); 207 Results::Create(results);
208 SendResponse(true); 208 SendResponse(true);
209 } 209 }
210 210
211 bool FileManagerPrivateInternalSetDefaultTaskFunction::RunSync() { 211 bool FileManagerPrivateInternalSetDefaultTaskFunction::RunSync() {
212 using extensions::api::file_manager_private_internal::SetDefaultTask::Params; 212 using extensions::api::file_manager_private_internal::SetDefaultTask::Params;
213 const scoped_ptr<Params> params(Params::Create(*args_)); 213 const std::unique_ptr<Params> params(Params::Create(*args_));
214 EXTENSION_FUNCTION_VALIDATE(params); 214 EXTENSION_FUNCTION_VALIDATE(params);
215 215
216 const scoped_refptr<storage::FileSystemContext> file_system_context = 216 const scoped_refptr<storage::FileSystemContext> file_system_context =
217 file_manager::util::GetFileSystemContextForRenderFrameHost( 217 file_manager::util::GetFileSystemContextForRenderFrameHost(
218 GetProfile(), render_frame_host()); 218 GetProfile(), render_frame_host());
219 219
220 const std::set<std::string> suffixes = 220 const std::set<std::string> suffixes =
221 GetUniqueSuffixes(params->urls, file_system_context.get()); 221 GetUniqueSuffixes(params->urls, file_system_context.get());
222 const std::set<std::string> mime_types = 222 const std::set<std::string> mime_types =
223 GetUniqueMimeTypes(params->mime_types); 223 GetUniqueMimeTypes(params->mime_types);
224 224
225 // If there weren't any mime_types, and all the suffixes were blank, 225 // If there weren't any mime_types, and all the suffixes were blank,
226 // then we "succeed", but don't actually associate with anything. 226 // then we "succeed", but don't actually associate with anything.
227 // Otherwise, any time we set the default on a file with no extension 227 // Otherwise, any time we set the default on a file with no extension
228 // on the local drive, we'd fail. 228 // on the local drive, we'd fail.
229 // TODO(gspencer): Fix file manager so that it never tries to set default in 229 // TODO(gspencer): Fix file manager so that it never tries to set default in
230 // cases where extensionless local files are part of the selection. 230 // cases where extensionless local files are part of the selection.
231 if (suffixes.empty() && mime_types.empty()) { 231 if (suffixes.empty() && mime_types.empty()) {
232 SetResult(new base::FundamentalValue(true)); 232 SetResult(new base::FundamentalValue(true));
233 return true; 233 return true;
234 } 234 }
235 235
236 file_manager::file_tasks::UpdateDefaultTask( 236 file_manager::file_tasks::UpdateDefaultTask(
237 GetProfile()->GetPrefs(), params->task_id, suffixes, mime_types); 237 GetProfile()->GetPrefs(), params->task_id, suffixes, mime_types);
238 return true; 238 return true;
239 } 239 }
240 240
241 } // namespace extensions 241 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698