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

Side by Side Diff: chrome/browser/download/download_prefs.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: Remove PathServiceWrapper and add DefaultDownloadDirectory 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_prefs.h" 5 #include "chrome/browser/download/download_prefs.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 "", 54 "",
55 PrefService::UNSYNCABLE_PREF); 55 PrefService::UNSYNCABLE_PREF);
56 prefs->RegisterBooleanPref(prefs::kDownloadDirUpgraded, 56 prefs->RegisterBooleanPref(prefs::kDownloadDirUpgraded,
57 false, 57 false,
58 PrefService::UNSYNCABLE_PREF); 58 PrefService::UNSYNCABLE_PREF);
59 prefs->RegisterIntegerPref(prefs::kSaveFileType, 59 prefs->RegisterIntegerPref(prefs::kSaveFileType,
60 SavePackage::SAVE_AS_COMPLETE_HTML, 60 SavePackage::SAVE_AS_COMPLETE_HTML,
61 PrefService::UNSYNCABLE_PREF); 61 PrefService::UNSYNCABLE_PREF);
62 62
63 // The default download path is userprofile\download. 63 // The default download path is userprofile\download.
64 const FilePath& default_download_path = 64 FilePath default_download_path;
65 download_util::GetDefaultDownloadDirectory(); 65 if (!download_util::DefaultDownloadDirectory::Get(&default_download_path))
66 VLOG(1) << "Cannot find the user's \"Downloads\" folder.";
66 prefs->RegisterFilePathPref(prefs::kDownloadDefaultDirectory, 67 prefs->RegisterFilePathPref(prefs::kDownloadDefaultDirectory,
67 default_download_path, 68 default_download_path,
68 PrefService::UNSYNCABLE_PREF); 69 PrefService::UNSYNCABLE_PREF);
69 70
70 #if defined(OS_CHROMEOS) 71 #if defined(OS_CHROMEOS)
71 // Ensure that the download directory specified in the preferences exists. 72 // Ensure that the download directory specified in the preferences exists.
72 BrowserThread::PostTask( 73 BrowserThread::PostTask(
73 BrowserThread::FILE, FROM_HERE, 74 BrowserThread::FILE, FROM_HERE,
74 NewRunnableFunction(&file_util::CreateDirectory, default_download_path)); 75 NewRunnableFunction(&file_util::CreateDirectory, default_download_path));
75 #endif // defined(OS_CHROMEOS) 76 #endif // defined(OS_CHROMEOS)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 extensions.erase(extensions.size() - 1); 152 extensions.erase(extensions.size() - 1);
152 153
153 prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions); 154 prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions);
154 } 155 }
155 156
156 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( 157 bool DownloadPrefs::AutoOpenCompareFunctor::operator()(
157 const FilePath::StringType& a, 158 const FilePath::StringType& a,
158 const FilePath::StringType& b) const { 159 const FilePath::StringType& b) const {
159 return FilePath::CompareLessIgnoreCase(a, b); 160 return FilePath::CompareLessIgnoreCase(a, b);
160 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698