| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // download completion in this pref. | 62 // download completion in this pref. |
| 63 std::string extensions_to_open = | 63 std::string extensions_to_open = |
| 64 prefs->GetString(prefs::kDownloadExtensionsToOpen); | 64 prefs->GetString(prefs::kDownloadExtensionsToOpen); |
| 65 std::vector<std::string> extensions; | 65 std::vector<std::string> extensions; |
| 66 base::SplitString(extensions_to_open, ':', &extensions); | 66 base::SplitString(extensions_to_open, ':', &extensions); |
| 67 | 67 |
| 68 for (size_t i = 0; i < extensions.size(); ++i) { | 68 for (size_t i = 0; i < extensions.size(); ++i) { |
| 69 #if defined(OS_POSIX) | 69 #if defined(OS_POSIX) |
| 70 base::FilePath path(extensions[i]); | 70 base::FilePath path(extensions[i]); |
| 71 #elif defined(OS_WIN) | 71 #elif defined(OS_WIN) |
| 72 base::FilePath path(UTF8ToWide(extensions[i])); | 72 base::FilePath path(base::UTF8ToWide(extensions[i])); |
| 73 #endif | 73 #endif |
| 74 if (!extensions[i].empty() && | 74 if (!extensions[i].empty() && |
| 75 download_util::GetFileDangerLevel(path) == download_util::NotDangerous) | 75 download_util::GetFileDangerLevel(path) == download_util::NotDangerous) |
| 76 auto_open_.insert(path.value()); | 76 auto_open_.insert(path.value()); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 DownloadPrefs::~DownloadPrefs() { | 80 DownloadPrefs::~DownloadPrefs() { |
| 81 SaveAutoOpenState(); | 81 SaveAutoOpenState(); |
| 82 } | 82 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 189 } |
| 190 | 190 |
| 191 void DownloadPrefs::SaveAutoOpenState() { | 191 void DownloadPrefs::SaveAutoOpenState() { |
| 192 std::string extensions; | 192 std::string extensions; |
| 193 for (AutoOpenSet::iterator it = auto_open_.begin(); | 193 for (AutoOpenSet::iterator it = auto_open_.begin(); |
| 194 it != auto_open_.end(); ++it) { | 194 it != auto_open_.end(); ++it) { |
| 195 #if defined(OS_POSIX) | 195 #if defined(OS_POSIX) |
| 196 std::string this_extension = *it; | 196 std::string this_extension = *it; |
| 197 #elif defined(OS_WIN) | 197 #elif defined(OS_WIN) |
| 198 // TODO(phajdan.jr): Why we're using Sys conversion here, but not in ctor? | 198 // TODO(phajdan.jr): Why we're using Sys conversion here, but not in ctor? |
| 199 std::string this_extension = base::SysWideToUTF8(*it); | 199 std::string this_extension = base::Sysbase::WideToUTF8(*it); |
| 200 #endif | 200 #endif |
| 201 extensions += this_extension + ":"; | 201 extensions += this_extension + ":"; |
| 202 } | 202 } |
| 203 if (!extensions.empty()) | 203 if (!extensions.empty()) |
| 204 extensions.erase(extensions.size() - 1); | 204 extensions.erase(extensions.size() - 1); |
| 205 | 205 |
| 206 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); | 206 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
| 207 } | 207 } |
| 208 | 208 |
| 209 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( | 209 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |
| 210 const base::FilePath::StringType& a, | 210 const base::FilePath::StringType& a, |
| 211 const base::FilePath::StringType& b) const { | 211 const base::FilePath::StringType& b) const { |
| 212 return base::FilePath::CompareLessIgnoreCase(a, b); | 212 return base::FilePath::CompareLessIgnoreCase(a, b); |
| 213 } | 213 } |
| OLD | NEW |