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

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

Issue 27354: Add FilePath setter/getter to pref service.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/save_package.h" 5 #include "chrome/browser/download/save_package.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 // static 959 // static
960 FilePath SavePackage::GetSuggestNameForSaveAs(PrefService* prefs, 960 FilePath SavePackage::GetSuggestNameForSaveAs(PrefService* prefs,
961 const FilePath& name) { 961 const FilePath& name) {
962 // Check whether the preference has the preferred directory for saving file. 962 // Check whether the preference has the preferred directory for saving file.
963 // If not, initialize it with default directory. 963 // If not, initialize it with default directory.
964 if (!prefs->IsPrefRegistered(prefs::kSaveFileDefaultDirectory)) { 964 if (!prefs->IsPrefRegistered(prefs::kSaveFileDefaultDirectory)) {
965 FilePath default_save_path; 965 FilePath default_save_path;
966 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, 966 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS,
967 &default_save_path)) 967 &default_save_path))
968 NOTREACHED(); 968 NOTREACHED();
969 prefs->RegisterStringPref(prefs::kSaveFileDefaultDirectory, 969 prefs->RegisterFilePathPref(prefs::kSaveFileDefaultDirectory,
970 default_save_path.ToWStringHack()); 970 default_save_path);
971 } 971 }
972 972
973 // Get the directory from preference. 973 // Get the directory from preference.
974 StringPrefMember save_file_path; 974 StringPrefMember save_file_path;
975 save_file_path.Init(prefs::kSaveFileDefaultDirectory, prefs, NULL); 975 save_file_path.Init(prefs::kSaveFileDefaultDirectory, prefs, NULL);
976 DCHECK(!(*save_file_path).empty()); 976 DCHECK(!(*save_file_path).empty());
977 977
978 // Ask user for getting final saving name. 978 // Ask user for getting final saving name.
979 std::wstring file_name = name.ToWStringHack(); 979 std::wstring file_name = name.ToWStringHack();
980 // TODO(port): we need a version of ReplaceIllegalCharacters() that takes 980 // TODO(port): we need a version of ReplaceIllegalCharacters() that takes
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 *pure_file_name = 1104 *pure_file_name =
1105 pure_file_name->substr(0, available_length); 1105 pure_file_name->substr(0, available_length);
1106 return true; 1106 return true;
1107 } 1107 }
1108 1108
1109 // Not enough room to even use a shortened |pure_file_name|. 1109 // Not enough room to even use a shortened |pure_file_name|.
1110 pure_file_name->clear(); 1110 pure_file_name->clear();
1111 return false; 1111 return false;
1112 } 1112 }
1113 1113
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/metrics/metrics_service_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698