OLD | NEW |
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/common/chrome_paths.h" | 5 #include "chrome/common/chrome_paths.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
14 #include "base/version.h" | 14 #include "base/version.h" |
15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
16 #include "chrome/common/chrome_paths_internal.h" | 16 #include "chrome/common/chrome_paths_internal.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "content/public/common/content_switches.h" |
18 | 19 |
19 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
20 #include "base/mac/mac_util.h" | 21 #include "base/mac/mac_util.h" |
21 #endif | 22 #endif |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // File name of the internal Flash plugin on different platforms. | 26 // File name of the internal Flash plugin on different platforms. |
26 const FilePath::CharType kInternalFlashPluginFileName[] = | 27 const FilePath::CharType kInternalFlashPluginFileName[] = |
27 #if defined(OS_MACOSX) | 28 #if defined(OS_MACOSX) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 case chrome::FILE_RESOURCE_MODULE: | 137 case chrome::FILE_RESOURCE_MODULE: |
137 return PathService::Get(base::FILE_MODULE, result); | 138 return PathService::Get(base::FILE_MODULE, result); |
138 } | 139 } |
139 | 140 |
140 // Assume that we will not need to create the directory if it does not exist. | 141 // Assume that we will not need to create the directory if it does not exist. |
141 // This flag can be set to true for the cases where we want to create it. | 142 // This flag can be set to true for the cases where we want to create it. |
142 bool create_dir = false; | 143 bool create_dir = false; |
143 | 144 |
144 FilePath cur; | 145 FilePath cur; |
145 switch (key) { | 146 switch (key) { |
146 case chrome::DIR_USER_DATA: | 147 case chrome::DIR_USER_DATA: { |
| 148 CommandLine *cmd_line = CommandLine::ForCurrentProcess(); |
| 149 if (cmd_line) { |
| 150 // In some tests this check might be happening after the CommandLine |
| 151 // object has been destroyed. This is DCHECKED but in release builds |
| 152 // it might lead to a crash here. |
| 153 CHECK(ProcessNeedsProfileDir(cmd_line->GetSwitchValueASCII( |
| 154 switches::kProcessType))); |
| 155 } |
147 if (!GetDefaultUserDataDirectory(&cur)) { | 156 if (!GetDefaultUserDataDirectory(&cur)) { |
148 NOTREACHED(); | 157 NOTREACHED(); |
149 return false; | 158 return false; |
150 } | 159 } |
151 create_dir = true; | 160 create_dir = true; |
152 break; | 161 break; |
| 162 } |
153 case chrome::DIR_USER_DOCUMENTS: | 163 case chrome::DIR_USER_DOCUMENTS: |
154 if (!GetUserDocumentsDirectory(&cur)) | 164 if (!GetUserDocumentsDirectory(&cur)) |
155 return false; | 165 return false; |
156 create_dir = true; | 166 create_dir = true; |
157 break; | 167 break; |
158 case chrome::DIR_DEFAULT_DOWNLOADS_SAFE: | 168 case chrome::DIR_DEFAULT_DOWNLOADS_SAFE: |
159 #if defined(OS_WIN) || defined(OS_LINUX) | 169 #if defined(OS_WIN) || defined(OS_LINUX) |
160 if (!GetUserDownloadsDirectorySafe(&cur)) | 170 if (!GetUserDownloadsDirectorySafe(&cur)) |
161 return false; | 171 return false; |
162 break; | 172 break; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 return true; | 430 return true; |
421 } | 431 } |
422 | 432 |
423 // This cannot be done as a static initializer sadly since Visual Studio will | 433 // This cannot be done as a static initializer sadly since Visual Studio will |
424 // eliminate this object file if there is no direct entry point into it. | 434 // eliminate this object file if there is no direct entry point into it. |
425 void RegisterPathProvider() { | 435 void RegisterPathProvider() { |
426 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 436 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
427 } | 437 } |
428 | 438 |
429 } // namespace chrome | 439 } // namespace chrome |
OLD | NEW |