Index: chrome/browser/download/download_prefs.cc |
=================================================================== |
--- chrome/browser/download/download_prefs.cc (revision 147600) |
+++ chrome/browser/download/download_prefs.cc (working copy) |
@@ -22,12 +22,14 @@ |
#include "chrome/browser/download/download_util.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/common/pref_names.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/download_manager.h" |
#include "content/public/browser/save_page_type.h" |
#if defined(OS_CHROMEOS) |
+#include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
#include "chrome/browser/chromeos/gdata/gdata_util.h" |
#endif |
@@ -35,7 +37,8 @@ |
using content::BrowserThread; |
using content::DownloadManager; |
-DownloadPrefs::DownloadPrefs(PrefService* prefs) : prefs_(prefs) { |
+DownloadPrefs::DownloadPrefs(Profile* profile) : profile_(profile) { |
+ PrefService* prefs = profile->GetPrefs(); |
prompt_for_download_.Init(prefs::kPromptForDownload, prefs, NULL); |
download_path_.Init(prefs::kDownloadDefaultDirectory, prefs, NULL); |
save_file_type_.Init(prefs::kSaveFileType, prefs, NULL); |
@@ -122,6 +125,18 @@ |
return FromDownloadManager(BrowserContext::GetDownloadManager(context)); |
} |
+FilePath DownloadPrefs::DownloadPath() const { |
+#if defined(OS_CHROMEOS) |
+ // If the download path is under /drive, and GDataSystemService isn't |
+ // available (which it isn't for incognito mode, for instance), use the |
+ // default download directory (/Downloads). |
+ if (gdata::util::IsUnderGDataMountPoint(*download_path_) && |
+ !gdata::GDataSystemServiceFactory::GetForProfile(profile_)) |
+ return download_util::GetDefaultDownloadDirectory(); |
+#endif |
+ return *download_path_; |
+} |
+ |
bool DownloadPrefs::PromptForDownload() const { |
// If the DownloadDirectory policy is set, then |prompt_for_download_| should |
// always be false. |
@@ -184,7 +199,7 @@ |
if (!extensions.empty()) |
extensions.erase(extensions.size() - 1); |
- prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
+ profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
} |
bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |