OLD | NEW |
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/download/download_prefs.h" | 5 #include "chrome/browser/download/download_prefs.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/download/download_util.h" | 22 #include "chrome/browser/download/download_util.h" |
23 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/download_manager.h" | 28 #include "content/public/browser/download_manager.h" |
29 #include "content/public/browser/save_page_type.h" | 29 #include "content/public/browser/save_page_type.h" |
30 | 30 |
31 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
32 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 32 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
33 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 33 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
34 #endif | 34 #endif |
35 | 35 |
36 using content::BrowserContext; | 36 using content::BrowserContext; |
37 using content::BrowserThread; | 37 using content::BrowserThread; |
38 using content::DownloadManager; | 38 using content::DownloadManager; |
39 | 39 |
40 DownloadPrefs::DownloadPrefs(Profile* profile) : profile_(profile) { | 40 DownloadPrefs::DownloadPrefs(Profile* profile) : profile_(profile) { |
41 PrefService* prefs = profile->GetPrefs(); | 41 PrefService* prefs = profile->GetPrefs(); |
42 prompt_for_download_.Init(prefs::kPromptForDownload, prefs, NULL); | 42 prompt_for_download_.Init(prefs::kPromptForDownload, prefs, NULL); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 | 121 |
122 // static | 122 // static |
123 DownloadPrefs* DownloadPrefs::FromBrowserContext( | 123 DownloadPrefs* DownloadPrefs::FromBrowserContext( |
124 content::BrowserContext* context) { | 124 content::BrowserContext* context) { |
125 return FromDownloadManager(BrowserContext::GetDownloadManager(context)); | 125 return FromDownloadManager(BrowserContext::GetDownloadManager(context)); |
126 } | 126 } |
127 | 127 |
128 FilePath DownloadPrefs::DownloadPath() const { | 128 FilePath DownloadPrefs::DownloadPath() const { |
129 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
130 // If the download path is under /drive, and GDataSystemService isn't | 130 // If the download path is under /drive, and DriveSystemService isn't |
131 // available (which it isn't for incognito mode, for instance), use the | 131 // available (which it isn't for incognito mode, for instance), use the |
132 // default download directory (/Downloads). | 132 // default download directory (/Downloads). |
133 if (gdata::util::IsUnderGDataMountPoint(*download_path_) && | 133 if (gdata::util::IsUnderGDataMountPoint(*download_path_) && |
134 !gdata::GDataSystemServiceFactory::GetForProfile(profile_)) | 134 !gdata::DriveSystemServiceFactory::GetForProfile(profile_)) |
135 return download_util::GetDefaultDownloadDirectory(); | 135 return download_util::GetDefaultDownloadDirectory(); |
136 #endif | 136 #endif |
137 return *download_path_; | 137 return *download_path_; |
138 } | 138 } |
139 | 139 |
140 bool DownloadPrefs::PromptForDownload() const { | 140 bool DownloadPrefs::PromptForDownload() const { |
141 // If the DownloadDirectory policy is set, then |prompt_for_download_| should | 141 // If the DownloadDirectory policy is set, then |prompt_for_download_| should |
142 // always be false. | 142 // always be false. |
143 DCHECK(!download_path_.IsManaged() || !prompt_for_download_.GetValue()); | 143 DCHECK(!download_path_.IsManaged() || !prompt_for_download_.GetValue()); |
144 return *prompt_for_download_; | 144 return *prompt_for_download_; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 extensions.erase(extensions.size() - 1); | 200 extensions.erase(extensions.size() - 1); |
201 | 201 |
202 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); | 202 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
203 } | 203 } |
204 | 204 |
205 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( | 205 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |
206 const FilePath::StringType& a, | 206 const FilePath::StringType& a, |
207 const FilePath::StringType& b) const { | 207 const FilePath::StringType& b) const { |
208 return FilePath::CompareLessIgnoreCase(a, b); | 208 return FilePath::CompareLessIgnoreCase(a, b); |
209 } | 209 } |
OLD | NEW |