| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 extensions.erase(extensions.size() - 1); | 208 extensions.erase(extensions.size() - 1); |
| 204 | 209 |
| 205 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); | 210 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
| 206 } | 211 } |
| 207 | 212 |
| 208 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( | 213 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |
| 209 const base::FilePath::StringType& a, | 214 const base::FilePath::StringType& a, |
| 210 const base::FilePath::StringType& b) const { | 215 const base::FilePath::StringType& b) const { |
| 211 return base::FilePath::CompareLessIgnoreCase(a, b); | 216 return base::FilePath::CompareLessIgnoreCase(a, b); |
| 212 } | 217 } |
| OLD | NEW |