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

Unified 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: Add comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_prefs.cc
diff --git a/chrome/browser/download/download_prefs.cc b/chrome/browser/download/download_prefs.cc
index 2bfb7928e96259b62a0dbf21fd573489b576979a..aec63ee19a6c13c08e878e4634adbff35de98b9e 100644
--- a/chrome/browser/download/download_prefs.cc
+++ b/chrome/browser/download/download_prefs.cc
@@ -153,8 +153,13 @@ bool DownloadPrefs::IsAutoOpenUsed() const {
return !auto_open_.empty();
}
-bool DownloadPrefs::IsAutoOpenEnabledForExtension(
- const base::FilePath::StringType& extension) const {
+bool DownloadPrefs::IsAutoOpenEnabledBasedOnExtension(
+ const base::FilePath& path) const {
+ base::FilePath::StringType extension = path.Extension();
+ if (extension.empty())
+ return false;
+ DCHECK(extension[0] == base::FilePath::kExtensionSeparator);
+ extension.erase(0, 1);
return auto_open_.find(extension) != auto_open_.end();
}
@@ -202,6 +207,8 @@ void DownloadPrefs::SaveAutoOpenState() {
if (!extensions.empty())
extensions.erase(extensions.size() - 1);
+ DCHECK(profile_);
+ DCHECK(profile_->GetPrefs());
profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions);
}

Powered by Google App Engine
This is Rietveld 408576698