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

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

Issue 1240183002: Update SplitString calls in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 prompt_for_download_.Init(prefs::kPromptForDownload, prefs); 153 prompt_for_download_.Init(prefs::kPromptForDownload, prefs);
154 download_path_.Init(prefs::kDownloadDefaultDirectory, prefs); 154 download_path_.Init(prefs::kDownloadDefaultDirectory, prefs);
155 save_file_path_.Init(prefs::kSaveFileDefaultDirectory, prefs); 155 save_file_path_.Init(prefs::kSaveFileDefaultDirectory, prefs);
156 save_file_type_.Init(prefs::kSaveFileType, prefs); 156 save_file_type_.Init(prefs::kSaveFileType, prefs);
157 157
158 // We store any file extension that should be opened automatically at 158 // We store any file extension that should be opened automatically at
159 // download completion in this pref. 159 // download completion in this pref.
160 std::string extensions_to_open = 160 std::string extensions_to_open =
161 prefs->GetString(prefs::kDownloadExtensionsToOpen); 161 prefs->GetString(prefs::kDownloadExtensionsToOpen);
162 std::vector<std::string> extensions;
163 base::SplitString(extensions_to_open, ':', &extensions);
164 162
165 for (const auto& extension_string : extensions) { 163 for (const auto& extension_string : base::SplitString(
164 extensions_to_open, ":",
165 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
166 #if defined(OS_POSIX) 166 #if defined(OS_POSIX)
167 base::FilePath::StringType extension = extension_string; 167 base::FilePath::StringType extension = extension_string;
168 #elif defined(OS_WIN) 168 #elif defined(OS_WIN)
169 base::FilePath::StringType extension = base::UTF8ToWide(extension_string); 169 base::FilePath::StringType extension = base::UTF8ToWide(extension_string);
170 #endif 170 #endif
171 // If it's empty or malformed or not allowed to open automatically, then 171 // If it's empty or malformed or not allowed to open automatically, then
172 // skip the entry. Any such entries will be dropped from preferences the 172 // skip the entry. Any such entries will be dropped from preferences the
173 // next time SaveAutoOpenState() is called. 173 // next time SaveAutoOpenState() is called.
174 if (extension.empty() || 174 if (extension.empty() ||
175 *extension.begin() == base::FilePath::kExtensionSeparator) 175 *extension.begin() == base::FilePath::kExtensionSeparator)
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 extensions.erase(extensions.size() - 1); 381 extensions.erase(extensions.size() - 1);
382 382
383 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); 383 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions);
384 } 384 }
385 385
386 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( 386 bool DownloadPrefs::AutoOpenCompareFunctor::operator()(
387 const base::FilePath::StringType& a, 387 const base::FilePath::StringType& a,
388 const base::FilePath::StringType& b) const { 388 const base::FilePath::StringType& b) const {
389 return base::FilePath::CompareLessIgnoreCase(a, b); 389 return base::FilePath::CompareLessIgnoreCase(a, b);
390 } 390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698