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" | |
19 | 18 |
20 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
21 #include "base/mac/mac_util.h" | 20 #include "base/mac/mac_util.h" |
22 #endif | 21 #endif |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
26 // File name of the internal Flash plugin on different platforms. | 25 // File name of the internal Flash plugin on different platforms. |
27 const FilePath::CharType kInternalFlashPluginFileName[] = | 26 const FilePath::CharType kInternalFlashPluginFileName[] = |
28 #if defined(OS_MACOSX) | 27 #if defined(OS_MACOSX) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 case chrome::FILE_RESOURCE_MODULE: | 136 case chrome::FILE_RESOURCE_MODULE: |
138 return PathService::Get(base::FILE_MODULE, result); | 137 return PathService::Get(base::FILE_MODULE, result); |
139 } | 138 } |
140 | 139 |
141 // Assume that we will not need to create the directory if it does not exist. | 140 // Assume that we will not need to create the directory if it does not exist. |
142 // This flag can be set to true for the cases where we want to create it. | 141 // This flag can be set to true for the cases where we want to create it. |
143 bool create_dir = false; | 142 bool create_dir = false; |
144 | 143 |
145 FilePath cur; | 144 FilePath cur; |
146 switch (key) { | 145 switch (key) { |
147 case chrome::DIR_USER_DATA: { | 146 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 } | |
156 if (!GetDefaultUserDataDirectory(&cur)) { | 147 if (!GetDefaultUserDataDirectory(&cur)) { |
157 NOTREACHED(); | 148 NOTREACHED(); |
158 return false; | 149 return false; |
159 } | 150 } |
160 create_dir = true; | 151 create_dir = true; |
161 break; | 152 break; |
162 } | |
163 case chrome::DIR_USER_DOCUMENTS: | 153 case chrome::DIR_USER_DOCUMENTS: |
164 if (!GetUserDocumentsDirectory(&cur)) | 154 if (!GetUserDocumentsDirectory(&cur)) |
165 return false; | 155 return false; |
166 create_dir = true; | 156 create_dir = true; |
167 break; | 157 break; |
168 case chrome::DIR_DEFAULT_DOWNLOADS_SAFE: | 158 case chrome::DIR_DEFAULT_DOWNLOADS_SAFE: |
169 #if defined(OS_WIN) || defined(OS_LINUX) | 159 #if defined(OS_WIN) || defined(OS_LINUX) |
170 if (!GetUserDownloadsDirectorySafe(&cur)) | 160 if (!GetUserDownloadsDirectorySafe(&cur)) |
171 return false; | 161 return false; |
172 break; | 162 break; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 return true; | 420 return true; |
431 } | 421 } |
432 | 422 |
433 // This cannot be done as a static initializer sadly since Visual Studio will | 423 // This cannot be done as a static initializer sadly since Visual Studio will |
434 // eliminate this object file if there is no direct entry point into it. | 424 // eliminate this object file if there is no direct entry point into it. |
435 void RegisterPathProvider() { | 425 void RegisterPathProvider() { |
436 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 426 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
437 } | 427 } |
438 | 428 |
439 } // namespace chrome | 429 } // namespace chrome |
OLD | NEW |