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

Side by Side Diff: chrome/browser/download/download_manager.cc

Issue 6973052: When the download folder does not exist, change the download folder to a user's "Downloads" (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Correct typo Created 9 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/download/download_manager.h" 5 #include "chrome/browser/download/download_manager.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 download->id(), 361 download->id(),
362 state, 362 state,
363 download_prefs()->download_path())); 363 download_prefs()->download_path()));
364 } 364 }
365 365
366 void DownloadManager::CheckIfSuggestedPathExists(int32 download_id, 366 void DownloadManager::CheckIfSuggestedPathExists(int32 download_id,
367 DownloadStateInfo state, 367 DownloadStateInfo state,
368 const FilePath& default_path) { 368 const FilePath& default_path) {
369 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 369 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
370 370
371 // Make sure the default download directory exists.
372 // TODO(phajdan.jr): only create the directory when we're sure the user
373 // is going to save there and not to another directory of his choice.
374 file_util::CreateDirectory(default_path);
Paweł Hajdan Jr. 2011/05/30 14:15:49 Please also add a test for a case where we're down
haraken1 2011/05/31 12:41:31 I added DownloadTest.DownloadedDirectory.
375
376 // Check writability of the suggested path. If we can't write to it, default 371 // Check writability of the suggested path. If we can't write to it, default
377 // to the user's "My Documents" directory. We'll prompt them in this case. 372 // to the user's "My Documents" directory. We'll prompt them in this case.
378 FilePath dir = state.suggested_path.DirName(); 373 FilePath dir = state.suggested_path.DirName();
379 FilePath filename = state.suggested_path.BaseName(); 374 FilePath filename = state.suggested_path.BaseName();
380 if (!file_util::PathIsWritable(dir)) { 375 if (!file_util::PathIsWritable(dir)) {
381 VLOG(1) << "Unable to write to directory \"" << dir.value() << "\""; 376 VLOG(1) << "Unable to write to directory \"" << dir.value() << "\"";
382 state.prompt_user_for_save_location = true; 377 state.prompt_user_for_save_location = true;
383 PathService::Get(chrome::DIR_USER_DOCUMENTS, &state.suggested_path); 378 PathService::Get(chrome::DIR_USER_DOCUMENTS, &state.suggested_path);
384 state.suggested_path = state.suggested_path.Append(filename); 379 state.suggested_path = state.suggested_path.Append(filename);
385 } 380 }
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 observed_download_manager_->RemoveObserver(this); 1272 observed_download_manager_->RemoveObserver(this);
1278 } 1273 }
1279 1274
1280 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { 1275 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() {
1281 observing_download_manager_->NotifyModelChanged(); 1276 observing_download_manager_->NotifyModelChanged();
1282 } 1277 }
1283 1278
1284 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { 1279 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() {
1285 observed_download_manager_ = NULL; 1280 observed_download_manager_ = NULL;
1286 } 1281 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/save_package.h » ('j') | chrome/browser/download/save_package.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698