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

Side by Side Diff: base/path_service.cc

Issue 8463020: Make sure only the right processes can access the profile path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added user notification for network profiles. Created 8 years, 11 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
« no previous file with comments | « base/path_service.h ('k') | chrome/app/chrome_main_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 if (path.empty()) 215 if (path.empty())
216 return false; 216 return false;
217 217
218 AddToCache(key, path); 218 AddToCache(key, path);
219 219
220 *result = path; 220 *result = path;
221 return true; 221 return true;
222 } 222 }
223 223
224 bool PathService::Override(int key, const FilePath& path) { 224 bool PathService::Override(int key, const FilePath& path) {
225 // Just call the full function with true for the value of |create|.
226 return Override(key, path, true);
227 }
228
229 bool PathService::Override(int key, const FilePath& path, bool create) {
225 PathData* path_data = GetPathData(); 230 PathData* path_data = GetPathData();
226 DCHECK(path_data); 231 DCHECK(path_data);
227 DCHECK_GT(key, base::DIR_CURRENT) << "invalid path key"; 232 DCHECK_GT(key, base::DIR_CURRENT) << "invalid path key";
228 233
229 FilePath file_path = path; 234 FilePath file_path = path;
230 235
231 // Make sure the directory exists. We need to do this before we translate 236 // For some locations this will fail if called from inside the sandbox there-
232 // this to the absolute path because on POSIX, AbsolutePath fails if called 237 // fore we protect this call with a flag.
233 // on a non-existent path. 238 if (create) {
234 if (!file_util::PathExists(file_path) && 239 // Make sure the directory exists. We need to do this before we translate
235 !file_util::CreateDirectory(file_path)) 240 // this to the absolute path because on POSIX, AbsolutePath fails if called
236 return false; 241 // on a non-existent path.
242 if (!file_util::PathExists(file_path) &&
243 !file_util::CreateDirectory(file_path))
244 return false;
245 }
237 246
238 // We need to have an absolute path, as extensions and plugins don't like 247 // We need to have an absolute path, as extensions and plugins don't like
239 // relative paths, and will gladly crash the browser in CHECK()s if they get a 248 // relative paths, and will gladly crash the browser in CHECK()s if they get a
240 // relative path. 249 // relative path.
241 if (!file_util::AbsolutePath(&file_path)) 250 if (!file_util::AbsolutePath(&file_path))
242 return false; 251 return false;
243 252
244 base::AutoLock scoped_lock(path_data->lock); 253 base::AutoLock scoped_lock(path_data->lock);
245 254
246 // Clear the cache now. Some of its entries could have depended 255 // Clear the cache now. Some of its entries could have depended
(...skipping 28 matching lines...) Expand all
275 p = new Provider; 284 p = new Provider;
276 p->is_static = false; 285 p->is_static = false;
277 p->func = func; 286 p->func = func;
278 p->next = path_data->providers; 287 p->next = path_data->providers;
279 #ifndef NDEBUG 288 #ifndef NDEBUG
280 p->key_start = key_start; 289 p->key_start = key_start;
281 p->key_end = key_end; 290 p->key_end = key_end;
282 #endif 291 #endif
283 path_data->providers = p; 292 path_data->providers = p;
284 } 293 }
OLDNEW
« no previous file with comments | « base/path_service.h ('k') | chrome/app/chrome_main_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698