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

Unified Diff: base/path_service.cc

Issue 10306009: Make sure only the main browser process and service proceses are allowed to create the profile dire… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add gpu to the list of allowed processes. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/path_service.h ('k') | chrome/app/chrome_main_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/path_service.cc
diff --git a/base/path_service.cc b/base/path_service.cc
index 46f394c1d79eb2a8e5b9a06ba4447e5f2791364c..a3b882c2a9e8f76f668ed71b8549706059aecf51 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -222,18 +222,29 @@ bool PathService::Get(int key, FilePath* result) {
}
bool PathService::Override(int key, const FilePath& path) {
+ // Just call the full function with true for the value of |create|.
+ return OverrideAndCreateIfNeeded(key, path, true);
+}
+
+bool PathService::OverrideAndCreateIfNeeded(int key,
+ const FilePath& path,
+ bool create) {
PathData* path_data = GetPathData();
DCHECK(path_data);
DCHECK_GT(key, base::DIR_CURRENT) << "invalid path key";
FilePath file_path = path;
- // Make sure the directory exists. We need to do this before we translate
- // this to the absolute path because on POSIX, AbsolutePath fails if called
- // on a non-existent path.
- if (!file_util::PathExists(file_path) &&
- !file_util::CreateDirectory(file_path))
- return false;
+ // For some locations this will fail if called from inside the sandbox there-
+ // fore we protect this call with a flag.
+ if (create) {
+ // Make sure the directory exists. We need to do this before we translate
+ // this to the absolute path because on POSIX, AbsolutePath fails if called
+ // on a non-existent path.
+ if (!file_util::PathExists(file_path) &&
+ !file_util::CreateDirectory(file_path))
+ return false;
+ }
// We need to have an absolute path, as extensions and plugins don't like
// relative paths, and will gladly crash the browser in CHECK()s if they get a
« 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