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

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

Issue 10535026: Move creation and ownership of DownloadManager from the embedder to content. This matches all the o… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros compile Created 8 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) 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 13 matching lines...) Expand all
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/download_manager.h" 27 #include "content/public/browser/download_manager.h"
28 #include "content/public/browser/save_page_type.h" 28 #include "content/public/browser/save_page_type.h"
29 29
30 #if defined(OS_CHROMEOS) 30 #if defined(OS_CHROMEOS)
31 #include "chrome/browser/chromeos/gdata/gdata_util.h" 31 #include "chrome/browser/chromeos/gdata/gdata_util.h"
32 #endif 32 #endif
33 33
34 using content::BrowserContext;
34 using content::BrowserThread; 35 using content::BrowserThread;
35 using content::DownloadManager; 36 using content::DownloadManager;
36 37
37 DownloadPrefs::DownloadPrefs(PrefService* prefs) : prefs_(prefs) { 38 DownloadPrefs::DownloadPrefs(PrefService* prefs) : prefs_(prefs) {
38 prompt_for_download_.Init(prefs::kPromptForDownload, prefs, NULL); 39 prompt_for_download_.Init(prefs::kPromptForDownload, prefs, NULL);
39 download_path_.Init(prefs::kDownloadDefaultDirectory, prefs, NULL); 40 download_path_.Init(prefs::kDownloadDefaultDirectory, prefs, NULL);
40 save_file_type_.Init(prefs::kSaveFileType, prefs, NULL); 41 save_file_type_.Init(prefs::kSaveFileType, prefs, NULL);
41 42
42 // We store any file extension that should be opened automatically at 43 // We store any file extension that should be opened automatically at
43 // download completion in this pref. 44 // download completion in this pref.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // static 110 // static
110 DownloadPrefs* DownloadPrefs::FromDownloadManager( 111 DownloadPrefs* DownloadPrefs::FromDownloadManager(
111 DownloadManager* download_manager) { 112 DownloadManager* download_manager) {
112 ChromeDownloadManagerDelegate* delegate = 113 ChromeDownloadManagerDelegate* delegate =
113 static_cast<ChromeDownloadManagerDelegate*>(download_manager->delegate()); 114 static_cast<ChromeDownloadManagerDelegate*>(download_manager->delegate());
114 return delegate->download_prefs(); 115 return delegate->download_prefs();
115 } 116 }
116 117
117 // static 118 // static
118 DownloadPrefs* DownloadPrefs::FromBrowserContext( 119 DownloadPrefs* DownloadPrefs::FromBrowserContext(
119 content::BrowserContext* browser_context) { 120 content::BrowserContext* context) {
120 Profile* profile = static_cast<Profile*>(browser_context); 121 return FromDownloadManager(BrowserContext::GetDownloadManager(context));
121 DownloadService* download_service =
122 DownloadServiceFactory::GetForProfile(profile);
123 return FromDownloadManager(download_service->GetDownloadManager());
124 } 122 }
125 123
126 bool DownloadPrefs::PromptForDownload() const { 124 bool DownloadPrefs::PromptForDownload() const {
127 // If the DownloadDirectory policy is set, then |prompt_for_download_| should 125 // If the DownloadDirectory policy is set, then |prompt_for_download_| should
128 // always be false. 126 // always be false.
129 DCHECK(!download_path_.IsManaged() || !prompt_for_download_.GetValue()); 127 DCHECK(!download_path_.IsManaged() || !prompt_for_download_.GetValue());
130 return *prompt_for_download_; 128 return *prompt_for_download_;
131 } 129 }
132 130
133 bool DownloadPrefs::IsDownloadPathManaged() const { 131 bool DownloadPrefs::IsDownloadPathManaged() const {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 extensions.erase(extensions.size() - 1); 184 extensions.erase(extensions.size() - 1);
187 185
188 prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions); 186 prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions);
189 } 187 }
190 188
191 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( 189 bool DownloadPrefs::AutoOpenCompareFunctor::operator()(
192 const FilePath::StringType& a, 190 const FilePath::StringType& a,
193 const FilePath::StringType& b) const { 191 const FilePath::StringType& b) const {
194 return FilePath::CompareLessIgnoreCase(a, b); 192 return FilePath::CompareLessIgnoreCase(a, b);
195 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698