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

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

Issue 12850002: Move download filename determintion into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 146 }
147 147
148 bool DownloadPrefs::IsDownloadPathManaged() const { 148 bool DownloadPrefs::IsDownloadPathManaged() const {
149 return download_path_.IsManaged(); 149 return download_path_.IsManaged();
150 } 150 }
151 151
152 bool DownloadPrefs::IsAutoOpenUsed() const { 152 bool DownloadPrefs::IsAutoOpenUsed() const {
153 return !auto_open_.empty(); 153 return !auto_open_.empty();
154 } 154 }
155 155
156 bool DownloadPrefs::IsAutoOpenEnabledForExtension( 156 bool DownloadPrefs::IsAutoOpenEnabledBasedOnExtension(
157 const base::FilePath::StringType& extension) const { 157 const base::FilePath& path) const {
158 base::FilePath::StringType extension = path.Extension();
159 if (extension.empty())
160 return false;
161 DCHECK(extension[0] == base::FilePath::kExtensionSeparator);
162 extension.erase(0, 1);
158 return auto_open_.find(extension) != auto_open_.end(); 163 return auto_open_.find(extension) != auto_open_.end();
159 } 164 }
160 165
161 bool DownloadPrefs::EnableAutoOpenBasedOnExtension( 166 bool DownloadPrefs::EnableAutoOpenBasedOnExtension(
162 const base::FilePath& file_name) { 167 const base::FilePath& file_name) {
163 base::FilePath::StringType extension = file_name.Extension(); 168 base::FilePath::StringType extension = file_name.Extension();
164 if (extension.empty()) 169 if (extension.empty())
165 return false; 170 return false;
166 DCHECK(extension[0] == base::FilePath::kExtensionSeparator); 171 DCHECK(extension[0] == base::FilePath::kExtensionSeparator);
167 extension.erase(0, 1); 172 extension.erase(0, 1);
(...skipping 27 matching lines...) Expand all
195 std::string this_extension = *it; 200 std::string this_extension = *it;
196 #elif defined(OS_WIN) 201 #elif defined(OS_WIN)
197 // TODO(phajdan.jr): Why we're using Sys conversion here, but not in ctor? 202 // TODO(phajdan.jr): Why we're using Sys conversion here, but not in ctor?
198 std::string this_extension = base::SysWideToUTF8(*it); 203 std::string this_extension = base::SysWideToUTF8(*it);
199 #endif 204 #endif
200 extensions += this_extension + ":"; 205 extensions += this_extension + ":";
201 } 206 }
202 if (!extensions.empty()) 207 if (!extensions.empty())
203 extensions.erase(extensions.size() - 1); 208 extensions.erase(extensions.size() - 1);
204 209
210 DCHECK(profile_);
benjhayden 2013/04/09 15:46:32 I thought it was unnecessary to dcheck pointers th
asanka 2013/04/16 20:34:01 Done.
211 DCHECK(profile_->GetPrefs());
205 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); 212 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions);
206 } 213 }
207 214
208 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( 215 bool DownloadPrefs::AutoOpenCompareFunctor::operator()(
209 const base::FilePath::StringType& a, 216 const base::FilePath::StringType& a,
210 const base::FilePath::StringType& b) const { 217 const base::FilePath::StringType& b) const {
211 return base::FilePath::CompareLessIgnoreCase(a, b); 218 return base::FilePath::CompareLessIgnoreCase(a, b);
212 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698