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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_util.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_util.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // The callback type for GetFileNativeLocalPathFor{Opening,Saving}. It receives 47 // The callback type for GetFileNativeLocalPathFor{Opening,Saving}. It receives
48 // the resolved local path when successful, and receives empty path for failure. 48 // the resolved local path when successful, and receives empty path for failure.
49 typedef base::Callback<void(const base::FilePath&)> LocalPathCallback; 49 typedef base::Callback<void(const base::FilePath&)> LocalPathCallback;
50 50
51 // Converts a callback from Drive file system to LocalPathCallback. 51 // Converts a callback from Drive file system to LocalPathCallback.
52 void OnDriveGetFile(const base::FilePath& path, 52 void OnDriveGetFile(const base::FilePath& path,
53 const LocalPathCallback& callback, 53 const LocalPathCallback& callback,
54 drive::FileError error, 54 drive::FileError error,
55 const base::FilePath& local_file_path, 55 const base::FilePath& local_file_path,
56 scoped_ptr<drive::ResourceEntry> entry) { 56 std::unique_ptr<drive::ResourceEntry> entry) {
57 if (error != drive::FILE_ERROR_OK) 57 if (error != drive::FILE_ERROR_OK)
58 DLOG(ERROR) << "Failed to get " << path.value() << " with: " << error; 58 DLOG(ERROR) << "Failed to get " << path.value() << " with: " << error;
59 callback.Run(local_file_path); 59 callback.Run(local_file_path);
60 } 60 }
61 61
62 // Gets a resolved local file path of a non native |path| for file opening. 62 // Gets a resolved local file path of a non native |path| for file opening.
63 void GetFileNativeLocalPathForOpening(Profile* profile, 63 void GetFileNativeLocalPathForOpening(Profile* profile,
64 const base::FilePath& path, 64 const base::FilePath& path,
65 const LocalPathCallback& callback) { 65 const LocalPathCallback& callback) {
66 if (drive::util::IsUnderDriveMountPoint(path)) { 66 if (drive::util::IsUnderDriveMountPoint(path)) {
(...skipping 29 matching lines...) Expand all
96 base::Bind(&OnDriveGetFile, path, callback)); 96 base::Bind(&OnDriveGetFile, path, callback));
97 return; 97 return;
98 } 98 }
99 99
100 // TODO(kinaba): For now, the only writable non-local volume is Drive. 100 // TODO(kinaba): For now, the only writable non-local volume is Drive.
101 NOTREACHED(); 101 NOTREACHED();
102 callback.Run(base::FilePath()); 102 callback.Run(base::FilePath());
103 } 103 }
104 104
105 // Forward declarations of helper functions for GetSelectedFileInfo(). 105 // Forward declarations of helper functions for GetSelectedFileInfo().
106 void ContinueGetSelectedFileInfo(Profile* profile, 106 void ContinueGetSelectedFileInfo(
107 scoped_ptr<GetSelectedFileInfoParams> params, 107 Profile* profile,
108 const base::FilePath& local_file_path); 108 std::unique_ptr<GetSelectedFileInfoParams> params,
109 const base::FilePath& local_file_path);
109 110
110 // Part of GetSelectedFileInfo(). 111 // Part of GetSelectedFileInfo().
111 void GetSelectedFileInfoInternal(Profile* profile, 112 void GetSelectedFileInfoInternal(
112 scoped_ptr<GetSelectedFileInfoParams> params) { 113 Profile* profile,
114 std::unique_ptr<GetSelectedFileInfoParams> params) {
113 DCHECK(profile); 115 DCHECK(profile);
114 116
115 for (size_t i = params->selected_files.size(); 117 for (size_t i = params->selected_files.size();
116 i < params->file_paths.size(); ++i) { 118 i < params->file_paths.size(); ++i) {
117 const base::FilePath& file_path = params->file_paths[i]; 119 const base::FilePath& file_path = params->file_paths[i];
118 120
119 if (file_manager::util::IsUnderNonNativeLocalPath(profile, file_path)) { 121 if (file_manager::util::IsUnderNonNativeLocalPath(profile, file_path)) {
120 // When the caller of the select file dialog wants local file paths, and 122 // When the caller of the select file dialog wants local file paths, and
121 // the selected path does not point to a native local path (e.g., Drive, 123 // the selected path does not point to a native local path (e.g., Drive,
122 // MTP, or provided file system), we should resolve the path. 124 // MTP, or provided file system), we should resolve the path.
(...skipping 22 matching lines...) Expand all
145 } 147 }
146 } else { 148 } else {
147 params->selected_files.push_back( 149 params->selected_files.push_back(
148 ui::SelectedFileInfo(file_path, file_path)); 150 ui::SelectedFileInfo(file_path, file_path));
149 } 151 }
150 } 152 }
151 params->callback.Run(params->selected_files); 153 params->callback.Run(params->selected_files);
152 } 154 }
153 155
154 // Part of GetSelectedFileInfo(). 156 // Part of GetSelectedFileInfo().
155 void ContinueGetSelectedFileInfo(Profile* profile, 157 void ContinueGetSelectedFileInfo(
156 scoped_ptr<GetSelectedFileInfoParams> params, 158 Profile* profile,
157 const base::FilePath& local_path) { 159 std::unique_ptr<GetSelectedFileInfoParams> params,
160 const base::FilePath& local_path) {
158 if (local_path.empty()) { 161 if (local_path.empty()) {
159 params->callback.Run(std::vector<ui::SelectedFileInfo>()); 162 params->callback.Run(std::vector<ui::SelectedFileInfo>());
160 return; 163 return;
161 } 164 }
162 const int index = params->selected_files.size(); 165 const int index = params->selected_files.size();
163 const base::FilePath& file_path = params->file_paths[index]; 166 const base::FilePath& file_path = params->file_paths[index];
164 params->selected_files.push_back(ui::SelectedFileInfo(file_path, local_path)); 167 params->selected_files.push_back(ui::SelectedFileInfo(file_path, local_path));
165 GetSelectedFileInfoInternal(profile, std::move(params)); 168 GetSelectedFileInfoInternal(profile, std::move(params));
166 } 169 }
167 170
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 326 }
324 327
325 void GetSelectedFileInfo(content::RenderFrameHost* render_frame_host, 328 void GetSelectedFileInfo(content::RenderFrameHost* render_frame_host,
326 Profile* profile, 329 Profile* profile,
327 const std::vector<GURL>& file_urls, 330 const std::vector<GURL>& file_urls,
328 GetSelectedFileInfoLocalPathOption local_path_option, 331 GetSelectedFileInfoLocalPathOption local_path_option,
329 GetSelectedFileInfoCallback callback) { 332 GetSelectedFileInfoCallback callback) {
330 DCHECK(render_frame_host); 333 DCHECK(render_frame_host);
331 DCHECK(profile); 334 DCHECK(profile);
332 335
333 scoped_ptr<GetSelectedFileInfoParams> params(new GetSelectedFileInfoParams); 336 std::unique_ptr<GetSelectedFileInfoParams> params(
337 new GetSelectedFileInfoParams);
334 params->local_path_option = local_path_option; 338 params->local_path_option = local_path_option;
335 params->callback = callback; 339 params->callback = callback;
336 340
337 for (size_t i = 0; i < file_urls.size(); ++i) { 341 for (size_t i = 0; i < file_urls.size(); ++i) {
338 const GURL& file_url = file_urls[i]; 342 const GURL& file_url = file_urls[i];
339 const base::FilePath path = GetLocalPathFromURL( 343 const base::FilePath path = GetLocalPathFromURL(
340 render_frame_host, profile, file_url); 344 render_frame_host, profile, file_url);
341 if (!path.empty()) { 345 if (!path.empty()) {
342 DVLOG(1) << "Selected: file path: " << path.value(); 346 DVLOG(1) << "Selected: file path: " << path.value();
343 params->file_paths.push_back(path); 347 params->file_paths.push_back(path);
(...skipping 18 matching lines...) Expand all
362 } 366 }
363 367
364 drive::EventLogger* GetLogger(Profile* profile) { 368 drive::EventLogger* GetLogger(Profile* profile) {
365 drive::DriveIntegrationService* service = 369 drive::DriveIntegrationService* service =
366 drive::DriveIntegrationServiceFactory::FindForProfile(profile); 370 drive::DriveIntegrationServiceFactory::FindForProfile(profile);
367 return service ? service->event_logger() : NULL; 371 return service ? service->event_logger() : NULL;
368 } 372 }
369 373
370 } // namespace util 374 } // namespace util
371 } // namespace file_manager 375 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698