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

Side by Side Diff: base/path_service.cc

Issue 6973052: When the download folder does not exist, change the download folder to a user's "Downloads" (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add SavePageTest.SavedFolder4 and DownloadTest.DownloadedFolder2 Created 9 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/path_service.h" 5 #include "base/path_service.h"
6 6
7 #ifdef OS_WIN 7 #ifdef OS_WIN
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 if (path.empty()) 199 if (path.empty())
200 return false; 200 return false;
201 201
202 AddToCache(key, path); 202 AddToCache(key, path);
203 203
204 *result = path; 204 *result = path;
205 return true; 205 return true;
206 } 206 }
207 207
208 void PathService::Set(int key, const FilePath& path) {
209 AddToCache(key, path);
210 }
211
208 bool PathService::Override(int key, const FilePath& path) { 212 bool PathService::Override(int key, const FilePath& path) {
209 PathData* path_data = GetPathData(); 213 PathData* path_data = GetPathData();
210 DCHECK(path_data); 214 DCHECK(path_data);
211 DCHECK_GT(key, base::DIR_CURRENT) << "invalid path key"; 215 DCHECK_GT(key, base::DIR_CURRENT) << "invalid path key";
212 216
213 FilePath file_path = path; 217 FilePath file_path = path;
214 218
215 // Make sure the directory exists. We need to do this before we translate 219 // Make sure the directory exists. We need to do this before we translate
216 // this to the absolute path because on POSIX, AbsolutePath fails if called 220 // this to the absolute path because on POSIX, AbsolutePath fails if called
217 // on a non-existant path. 221 // on a non-existant path.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 p = new Provider; 263 p = new Provider;
260 p->is_static = false; 264 p->is_static = false;
261 p->func = func; 265 p->func = func;
262 p->next = path_data->providers; 266 p->next = path_data->providers;
263 #ifndef NDEBUG 267 #ifndef NDEBUG
264 p->key_start = key_start; 268 p->key_start = key_start;
265 p->key_end = key_end; 269 p->key_end = key_end;
266 #endif 270 #endif
267 path_data->providers = p; 271 path_data->providers = p;
268 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698