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

Side by Side Diff: chrome/browser/chromeos/gdata/drive_download_observer.cc

Issue 10905142: Rename GData to Drive in drive_file_system_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gdata/drive_download_observer.h" 5 #include "chrome/browser/chromeos/gdata/drive_download_observer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // Callback for DriveServiceInterface::Authenticate. 168 // Callback for DriveServiceInterface::Authenticate.
169 void OnAuthenticate(Profile* profile, 169 void OnAuthenticate(Profile* profile,
170 const FilePath& drive_path, 170 const FilePath& drive_path,
171 const base::Closure& substitute_callback, 171 const base::Closure& substitute_callback,
172 GDataErrorCode error, 172 GDataErrorCode error,
173 const std::string& token) { 173 const std::string& token) {
174 DVLOG(1) << "OnAuthenticate"; 174 DVLOG(1) << "OnAuthenticate";
175 175
176 if (error == HTTP_SUCCESS) { 176 if (error == HTTP_SUCCESS) {
177 const FilePath drive_dir_path = 177 const FilePath drive_dir_path =
178 util::ExtractGDataPath(drive_path.DirName()); 178 util::ExtractDrivePath(drive_path.DirName());
179 // Ensure the directory exists. This also forces DriveFileSystem to 179 // Ensure the directory exists. This also forces DriveFileSystem to
180 // initialize DriveRootDirectory. 180 // initialize DriveRootDirectory.
181 GetSystemService(profile)->file_system()->GetEntryInfoByPath( 181 GetSystemService(profile)->file_system()->GetEntryInfoByPath(
182 drive_dir_path, 182 drive_dir_path,
183 base::Bind(&OnEntryFound, profile, drive_dir_path, 183 base::Bind(&OnEntryFound, profile, drive_dir_path,
184 substitute_callback)); 184 substitute_callback));
185 } else { 185 } else {
186 // TODO(achuith): Handle this. 186 // TODO(achuith): Handle this.
187 NOTREACHED(); 187 NOTREACHED();
188 } 188 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 // static 222 // static
223 void DriveDownloadObserver::SubstituteDriveDownloadPath(Profile* profile, 223 void DriveDownloadObserver::SubstituteDriveDownloadPath(Profile* profile,
224 const FilePath& drive_path, content::DownloadItem* download, 224 const FilePath& drive_path, content::DownloadItem* download,
225 const SubstituteDriveDownloadPathCallback& callback) { 225 const SubstituteDriveDownloadPathCallback& callback) {
226 DVLOG(1) << "SubstituteDriveDownloadPath " << drive_path.value(); 226 DVLOG(1) << "SubstituteDriveDownloadPath " << drive_path.value();
227 227
228 SetDownloadParams(drive_path, download); 228 SetDownloadParams(drive_path, download);
229 229
230 if (util::IsUnderGDataMountPoint(drive_path)) { 230 if (util::IsUnderDriveMountPoint(drive_path)) {
231 // Can't access drive if we're not authenticated. 231 // Can't access drive if we're not authenticated.
232 // We set off a chain of callbacks as follows: 232 // We set off a chain of callbacks as follows:
233 // DriveServiceInterface::Authenticate 233 // DriveServiceInterface::Authenticate
234 // OnAuthenticate calls DriveFileSystem::GetEntryInfoByPath 234 // OnAuthenticate calls DriveFileSystem::GetEntryInfoByPath
235 // OnEntryFound calls DriveFileSystem::CreateDirectory (if necessary) 235 // OnEntryFound calls DriveFileSystem::CreateDirectory (if necessary)
236 // OnCreateDirectory calls SubstituteDriveDownloadPathInternal 236 // OnCreateDirectory calls SubstituteDriveDownloadPathInternal
237 GetSystemService(profile)->drive_service()->Authenticate( 237 GetSystemService(profile)->drive_service()->Authenticate(
238 base::Bind(&OnAuthenticate, profile, drive_path, 238 base::Bind(&OnAuthenticate, profile, drive_path,
239 base::Bind(&SubstituteDriveDownloadPathInternal, 239 base::Bind(&SubstituteDriveDownloadPathInternal,
240 profile, callback))); 240 profile, callback)));
241 } else { 241 } else {
242 callback.Run(drive_path); 242 callback.Run(drive_path);
243 } 243 }
244 } 244 }
245 245
246 // static 246 // static
247 void DriveDownloadObserver::SetDownloadParams(const FilePath& drive_path, 247 void DriveDownloadObserver::SetDownloadParams(const FilePath& drive_path,
248 DownloadItem* download) { 248 DownloadItem* download) {
249 if (!download) 249 if (!download)
250 return; 250 return;
251 251
252 if (util::IsUnderGDataMountPoint(drive_path)) { 252 if (util::IsUnderDriveMountPoint(drive_path)) {
253 download->SetUserData(&kGDataPathKey, 253 download->SetUserData(&kGDataPathKey,
254 new DriveUserData(drive_path)); 254 new DriveUserData(drive_path));
255 download->SetDisplayName(drive_path.BaseName()); 255 download->SetDisplayName(drive_path.BaseName());
256 download->SetIsTemporary(true); 256 download->SetIsTemporary(true);
257 } else if (IsDriveDownload(download)) { 257 } else if (IsDriveDownload(download)) {
258 // This may have been previously set if the default download folder is 258 // This may have been previously set if the default download folder is
259 // /drive, and the user has now changed the download target to a local 259 // /drive, and the user has now changed the download target to a local
260 // folder. 260 // folder.
261 download->SetUserData(&kGDataPathKey, NULL); 261 download->SetUserData(&kGDataPathKey, NULL);
262 download->SetDisplayName(drive_path); 262 download->SetDisplayName(drive_path);
263 // TODO(achuith): This is not quite right. 263 // TODO(achuith): This is not quite right.
264 download->SetIsTemporary(false); 264 download->SetIsTemporary(false);
265 } 265 }
266 } 266 }
267 267
268 // static 268 // static
269 FilePath DriveDownloadObserver::GetDrivePath(DownloadItem* download) { 269 FilePath DriveDownloadObserver::GetDrivePath(DownloadItem* download) {
270 DriveUserData* data = GetDriveUserData(download); 270 DriveUserData* data = GetDriveUserData(download);
271 // If data is NULL, we've somehow lost the gdata path selected by the file 271 // If data is NULL, we've somehow lost the gdata path selected by the file
272 // picker. 272 // picker.
273 DCHECK(data); 273 DCHECK(data);
274 return data ? util::ExtractGDataPath(data->file_path()) : FilePath(); 274 return data ? util::ExtractDrivePath(data->file_path()) : FilePath();
275 } 275 }
276 276
277 // static 277 // static
278 bool DriveDownloadObserver::IsDriveDownload(DownloadItem* download) { 278 bool DriveDownloadObserver::IsDriveDownload(DownloadItem* download) {
279 // We use the existence of the DriveUserData object in download as a 279 // We use the existence of the DriveUserData object in download as a
280 // signal that this is a DriveDownload. 280 // signal that this is a DriveDownload.
281 return !!GetDriveUserData(download); 281 return !!GetDriveUserData(download);
282 } 282 }
283 283
284 // static 284 // static
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, 665 file_system_->AddUploadedFile(UPLOAD_NEW_FILE,
666 upload_data->virtual_dir_path(), 666 upload_data->virtual_dir_path(),
667 entry.Pass(), 667 entry.Pass(),
668 download->GetTargetFilePath(), 668 download->GetTargetFilePath(),
669 DriveCache::FILE_OPERATION_MOVE, 669 DriveCache::FILE_OPERATION_MOVE,
670 base::Bind(&base::DoNothing)); 670 base::Bind(&base::DoNothing));
671 } 671 }
672 } 672 }
673 673
674 } // namespace gdata 674 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager_util.cc ('k') | chrome/browser/chromeos/gdata/drive_file_system_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698