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

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

Issue 10815024: Revert 147594 - NaCl: Remove two uses of '#include "nacl/nacl_log.h"' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/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"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/string_split.h" 14 #include "base/string_split.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/sys_string_conversions.h" 16 #include "base/sys_string_conversions.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/download/chrome_download_manager_delegate.h" 18 #include "chrome/browser/download/chrome_download_manager_delegate.h"
19 #include "chrome/browser/download/download_extensions.h" 19 #include "chrome/browser/download/download_extensions.h"
20 #include "chrome/browser/download/download_service.h" 20 #include "chrome/browser/download/download_service.h"
21 #include "chrome/browser/download/download_service_factory.h" 21 #include "chrome/browser/download/download_service_factory.h"
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/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/download_manager.h" 28 #include "content/public/browser/download_manager.h"
28 #include "content/public/browser/save_page_type.h" 29 #include "content/public/browser/save_page_type.h"
29 30
30 #if defined(OS_CHROMEOS) 31 #if defined(OS_CHROMEOS)
32 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
31 #include "chrome/browser/chromeos/gdata/gdata_util.h" 33 #include "chrome/browser/chromeos/gdata/gdata_util.h"
32 #endif 34 #endif
33 35
34 using content::BrowserContext; 36 using content::BrowserContext;
35 using content::BrowserThread; 37 using content::BrowserThread;
36 using content::DownloadManager; 38 using content::DownloadManager;
37 39
38 DownloadPrefs::DownloadPrefs(PrefService* prefs) : prefs_(prefs) { 40 DownloadPrefs::DownloadPrefs(Profile* profile) : profile_(profile) {
41 PrefService* prefs = profile->GetPrefs();
39 prompt_for_download_.Init(prefs::kPromptForDownload, prefs, NULL); 42 prompt_for_download_.Init(prefs::kPromptForDownload, prefs, NULL);
40 download_path_.Init(prefs::kDownloadDefaultDirectory, prefs, NULL); 43 download_path_.Init(prefs::kDownloadDefaultDirectory, prefs, NULL);
41 save_file_type_.Init(prefs::kSaveFileType, prefs, NULL); 44 save_file_type_.Init(prefs::kSaveFileType, prefs, NULL);
42 45
43 // We store any file extension that should be opened automatically at 46 // We store any file extension that should be opened automatically at
44 // download completion in this pref. 47 // download completion in this pref.
45 std::string extensions_to_open = 48 std::string extensions_to_open =
46 prefs->GetString(prefs::kDownloadExtensionsToOpen); 49 prefs->GetString(prefs::kDownloadExtensionsToOpen);
47 std::vector<std::string> extensions; 50 std::vector<std::string> extensions;
48 base::SplitString(extensions_to_open, ':', &extensions); 51 base::SplitString(extensions_to_open, ':', &extensions);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 download_manager->GetDelegate()); 118 download_manager->GetDelegate());
116 return delegate->download_prefs(); 119 return delegate->download_prefs();
117 } 120 }
118 121
119 // static 122 // static
120 DownloadPrefs* DownloadPrefs::FromBrowserContext( 123 DownloadPrefs* DownloadPrefs::FromBrowserContext(
121 content::BrowserContext* context) { 124 content::BrowserContext* context) {
122 return FromDownloadManager(BrowserContext::GetDownloadManager(context)); 125 return FromDownloadManager(BrowserContext::GetDownloadManager(context));
123 } 126 }
124 127
128 FilePath DownloadPrefs::DownloadPath() const {
129 #if defined(OS_CHROMEOS)
130 // If the download path is under /drive, and GDataSystemService isn't
131 // available (which it isn't for incognito mode, for instance), use the
132 // default download directory (/Downloads).
133 if (gdata::util::IsUnderGDataMountPoint(*download_path_) &&
134 !gdata::GDataSystemServiceFactory::GetForProfile(profile_))
135 return download_util::GetDefaultDownloadDirectory();
136 #endif
137 return *download_path_;
138 }
139
125 bool DownloadPrefs::PromptForDownload() const { 140 bool DownloadPrefs::PromptForDownload() const {
126 // If the DownloadDirectory policy is set, then |prompt_for_download_| should 141 // If the DownloadDirectory policy is set, then |prompt_for_download_| should
127 // always be false. 142 // always be false.
128 DCHECK(!download_path_.IsManaged() || !prompt_for_download_.GetValue()); 143 DCHECK(!download_path_.IsManaged() || !prompt_for_download_.GetValue());
129 return *prompt_for_download_; 144 return *prompt_for_download_;
130 } 145 }
131 146
132 bool DownloadPrefs::IsDownloadPathManaged() const { 147 bool DownloadPrefs::IsDownloadPathManaged() const {
133 return download_path_.IsManaged(); 148 return download_path_.IsManaged();
134 } 149 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 std::string this_extension = *it; 192 std::string this_extension = *it;
178 #elif defined(OS_WIN) 193 #elif defined(OS_WIN)
179 // TODO(phajdan.jr): Why we're using Sys conversion here, but not in ctor? 194 // TODO(phajdan.jr): Why we're using Sys conversion here, but not in ctor?
180 std::string this_extension = base::SysWideToUTF8(*it); 195 std::string this_extension = base::SysWideToUTF8(*it);
181 #endif 196 #endif
182 extensions += this_extension + ":"; 197 extensions += this_extension + ":";
183 } 198 }
184 if (!extensions.empty()) 199 if (!extensions.empty())
185 extensions.erase(extensions.size() - 1); 200 extensions.erase(extensions.size() - 1);
186 201
187 prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions); 202 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions);
188 } 203 }
189 204
190 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( 205 bool DownloadPrefs::AutoOpenCompareFunctor::operator()(
191 const FilePath::StringType& a, 206 const FilePath::StringType& a,
192 const FilePath::StringType& b) const { 207 const FilePath::StringType& b) const {
193 return FilePath::CompareLessIgnoreCase(a, b); 208 return FilePath::CompareLessIgnoreCase(a, b);
194 } 209 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_prefs.h ('k') | chrome/browser/download/save_page_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698