One-time migration of NPAPI Flash to PPAPI Flash.
[chromium-blink-merge.git] / chrome / common / chrome_paths.cc
blobed7cdfb759656f6197103a108f4d7019f5d0f90b
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
3 // found in the LICENSE file.
5 #include "chrome/common/chrome_paths.h"
7 #include "base/files/file_util.h"
8 #include "base/lazy_instance.h"
9 #include "base/logging.h"
10 #include "base/mac/bundle_locations.h"
11 #include "base/path_service.h"
12 #include "base/strings/string_util.h"
13 #include "base/sys_info.h"
14 #include "base/threading/thread_restrictions.h"
15 #include "base/version.h"
16 #include "chrome/common/chrome_constants.h"
17 #include "chrome/common/chrome_paths_internal.h"
18 #include "chrome/common/widevine_cdm_constants.h"
19 #include "ui/base/ui_base_paths.h"
21 #if defined(OS_ANDROID)
22 #include "base/android/path_utils.h"
23 #include "base/base_paths_android.h"
24 #endif
26 #if defined(OS_MACOSX)
27 #include "base/mac/foundation_util.h"
28 #endif
30 #if defined(OS_WIN)
31 #include "base/win/registry.h"
32 #endif
34 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
36 namespace {
38 // The Pepper Flash plugins are in a directory with this name.
39 const base::FilePath::CharType kPepperFlashBaseDirectory[] =
40 FILE_PATH_LITERAL("PepperFlash");
42 #if defined(OS_MACOSX) && !defined(OS_IOS)
43 const base::FilePath::CharType kPepperFlashSystemBaseDirectory[] =
44 FILE_PATH_LITERAL("Internet Plug-Ins/PepperFlashPlayer");
45 const base::FilePath::CharType kFlashSystemBaseDirectory[] =
46 FILE_PATH_LITERAL("Internet Plug-Ins");
47 const base::FilePath::CharType kFlashSystemPluginName[] =
48 FILE_PATH_LITERAL("Flash Player.plugin");
49 #endif
51 const base::FilePath::CharType kInternalNaClPluginFileName[] =
52 FILE_PATH_LITERAL("internal-nacl-plugin");
54 #if defined(OS_LINUX)
55 // The path to the external extension <id>.json files.
56 // /usr/share seems like a good choice, see: http://www.pathname.com/fhs/
57 const base::FilePath::CharType kFilepathSinglePrefExtensions[] =
58 #if defined(GOOGLE_CHROME_BUILD)
59 FILE_PATH_LITERAL("/usr/share/google-chrome/extensions");
60 #else
61 FILE_PATH_LITERAL("/usr/share/chromium/extensions");
62 #endif // defined(GOOGLE_CHROME_BUILD)
63 #endif // defined(OS_LINUX)
65 static base::LazyInstance<base::FilePath>
66 g_invalid_specified_user_data_dir = LAZY_INSTANCE_INITIALIZER;
68 // Gets the path for internal plugins.
69 bool GetInternalPluginsDirectory(base::FilePath* result) {
70 #if defined(OS_MACOSX) && !defined(OS_IOS)
71 // If called from Chrome, get internal plugins from a subdirectory of the
72 // framework.
73 if (base::mac::AmIBundled()) {
74 *result = chrome::GetFrameworkBundlePath();
75 DCHECK(!result->empty());
76 *result = result->Append("Internet Plug-Ins");
77 return true;
79 // In tests, just look in the module directory (below).
80 #endif
82 // The rest of the world expects plugins in the module directory.
83 return PathService::Get(base::DIR_MODULE, result);
86 #if defined(OS_WIN)
87 // Gets the Flash path if installed on the system. |is_npapi| determines whether
88 // to return the NPAPI of the PPAPI version of the system plugin.
89 bool GetSystemFlashFilename(base::FilePath* out_path, bool is_npapi) {
90 const wchar_t kNpapiFlashRegistryRoot[] =
91 L"SOFTWARE\\Macromedia\\FlashPlayerPlugin";
92 const wchar_t kPepperFlashRegistryRoot[] =
93 L"SOFTWARE\\Macromedia\\FlashPlayerPepper";
94 const wchar_t kFlashPlayerPathValueName[] = L"PlayerPath";
96 base::win::RegKey path_key(
97 HKEY_LOCAL_MACHINE,
98 is_npapi ? kNpapiFlashRegistryRoot : kPepperFlashRegistryRoot, KEY_READ);
99 base::string16 path_str;
100 if (FAILED(path_key.ReadValue(kFlashPlayerPathValueName, &path_str)))
101 return false;
103 *out_path = base::FilePath(path_str);
104 return true;
106 #endif
108 } // namespace
110 namespace chrome {
112 bool PathProvider(int key, base::FilePath* result) {
113 // Some keys are just aliases...
114 switch (key) {
115 case chrome::DIR_APP:
116 return PathService::Get(base::DIR_MODULE, result);
117 case chrome::DIR_LOGS:
118 #ifdef NDEBUG
119 // Release builds write to the data dir
120 return PathService::Get(chrome::DIR_USER_DATA, result);
121 #else
122 // Debug builds write next to the binary (in the build tree)
123 #if defined(OS_MACOSX)
124 if (!PathService::Get(base::DIR_EXE, result))
125 return false;
126 if (base::mac::AmIBundled()) {
127 // If we're called from chrome, dump it beside the app (outside the
128 // app bundle), if we're called from a unittest, we'll already
129 // outside the bundle so use the exe dir.
130 // exe_dir gave us .../Chromium.app/Contents/MacOS/Chromium.
131 *result = result->DirName();
132 *result = result->DirName();
133 *result = result->DirName();
135 return true;
136 #else
137 return PathService::Get(base::DIR_EXE, result);
138 #endif // defined(OS_MACOSX)
139 #endif // NDEBUG
140 case chrome::FILE_RESOURCE_MODULE:
141 return PathService::Get(base::FILE_MODULE, result);
144 // Assume that we will not need to create the directory if it does not exist.
145 // This flag can be set to true for the cases where we want to create it.
146 bool create_dir = false;
148 base::FilePath cur;
149 switch (key) {
150 case chrome::DIR_USER_DATA:
151 if (!GetDefaultUserDataDirectory(&cur)) {
152 NOTREACHED();
153 return false;
155 create_dir = true;
156 break;
157 case chrome::DIR_USER_DOCUMENTS:
158 if (!GetUserDocumentsDirectory(&cur))
159 return false;
160 create_dir = true;
161 break;
162 case chrome::DIR_USER_MUSIC:
163 if (!GetUserMusicDirectory(&cur))
164 return false;
165 break;
166 case chrome::DIR_USER_PICTURES:
167 if (!GetUserPicturesDirectory(&cur))
168 return false;
169 break;
170 case chrome::DIR_USER_VIDEOS:
171 if (!GetUserVideosDirectory(&cur))
172 return false;
173 break;
174 case chrome::DIR_DEFAULT_DOWNLOADS_SAFE:
175 #if defined(OS_WIN) || defined(OS_LINUX)
176 if (!GetUserDownloadsDirectorySafe(&cur))
177 return false;
178 break;
179 #else
180 // Fall through for all other platforms.
181 #endif
182 case chrome::DIR_DEFAULT_DOWNLOADS:
183 #if defined(OS_ANDROID)
184 if (!base::android::GetDownloadsDirectory(&cur))
185 return false;
186 #else
187 if (!GetUserDownloadsDirectory(&cur))
188 return false;
189 // Do not create the download directory here, we have done it twice now
190 // and annoyed a lot of users.
191 #endif
192 break;
193 case chrome::DIR_CRASH_DUMPS:
194 #if defined(OS_CHROMEOS)
195 // ChromeOS uses a separate directory. See http://crosbug.com/25089
196 cur = base::FilePath("/var/log/chrome");
197 #elif defined(OS_ANDROID)
198 if (!base::android::GetCacheDirectory(&cur))
199 return false;
200 #else
201 // The crash reports are always stored relative to the default user data
202 // directory. This avoids the problem of having to re-initialize the
203 // exception handler after parsing command line options, which may
204 // override the location of the app's profile directory.
205 if (!GetDefaultUserDataDirectory(&cur))
206 return false;
207 #endif
208 #if defined(OS_MACOSX)
209 cur = cur.Append(FILE_PATH_LITERAL("Crashpad"));
210 #else
211 cur = cur.Append(FILE_PATH_LITERAL("Crash Reports"));
212 #endif
213 create_dir = true;
214 break;
215 #if defined(OS_WIN)
216 case chrome::DIR_WATCHER_DATA:
217 // The watcher data is always stored relative to the default user data
218 // directory. This allows the watcher to be initialized before
219 // command-line options have been parsed.
220 if (!GetDefaultUserDataDirectory(&cur))
221 return false;
222 cur = cur.Append(FILE_PATH_LITERAL("Diagnostics"));
223 break;
224 #endif
225 case chrome::DIR_RESOURCES:
226 #if defined(OS_MACOSX)
227 cur = base::mac::FrameworkBundlePath();
228 cur = cur.Append(FILE_PATH_LITERAL("Resources"));
229 #else
230 if (!PathService::Get(chrome::DIR_APP, &cur))
231 return false;
232 cur = cur.Append(FILE_PATH_LITERAL("resources"));
233 #endif
234 break;
235 case chrome::DIR_INSPECTOR:
236 if (!PathService::Get(chrome::DIR_RESOURCES, &cur))
237 return false;
238 cur = cur.Append(FILE_PATH_LITERAL("inspector"));
239 break;
240 case chrome::DIR_APP_DICTIONARIES:
241 #if defined(OS_POSIX)
242 // We can't write into the EXE dir on Linux, so keep dictionaries
243 // alongside the safe browsing database in the user data dir.
244 // And we don't want to write into the bundle on the Mac, so push
245 // it to the user data dir there also.
246 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
247 return false;
248 #else
249 if (!PathService::Get(base::DIR_EXE, &cur))
250 return false;
251 #endif
252 cur = cur.Append(FILE_PATH_LITERAL("Dictionaries"));
253 create_dir = true;
254 break;
255 case chrome::DIR_INTERNAL_PLUGINS:
256 if (!GetInternalPluginsDirectory(&cur))
257 return false;
258 break;
259 case chrome::DIR_PEPPER_FLASH_PLUGIN:
260 if (!GetInternalPluginsDirectory(&cur))
261 return false;
262 cur = cur.Append(kPepperFlashBaseDirectory);
263 break;
264 case chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN:
265 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
266 return false;
267 cur = cur.Append(kPepperFlashBaseDirectory);
268 break;
269 case chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN:
270 #if defined(OS_WIN)
271 if (!GetSystemFlashFilename(&cur, false))
272 return false;
273 #elif defined(OS_MACOSX) && !defined(OS_IOS)
274 if (!GetLocalLibraryDirectory(&cur))
275 return false;
276 cur = cur.Append(kPepperFlashSystemBaseDirectory);
277 cur = cur.Append(chrome::kPepperFlashPluginFilename);
278 #else
279 // Chrome on iOS does not supports PPAPI binaries, return false.
280 // TODO(wfh): If Adobe release PPAPI binaries for Linux, add support here.
281 return false;
282 #endif
283 break;
284 case chrome::FILE_FLASH_SYSTEM_PLUGIN:
285 #if defined(OS_WIN)
286 if (!GetSystemFlashFilename(&cur, true))
287 return false;
288 #elif defined(OS_MACOSX) && !defined(OS_IOS)
289 if (!GetLocalLibraryDirectory(&cur))
290 return false;
291 cur = cur.Append(kFlashSystemBaseDirectory);
292 cur = cur.Append(kFlashSystemPluginName);
293 #else
294 // Chrome on other platforms does not supports system NPAPI binaries.
295 return false;
296 #endif
297 break;
298 case chrome::FILE_LOCAL_STATE:
299 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
300 return false;
301 cur = cur.Append(chrome::kLocalStateFilename);
302 break;
303 case chrome::FILE_RECORDED_SCRIPT:
304 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
305 return false;
306 cur = cur.Append(FILE_PATH_LITERAL("script.log"));
307 break;
308 case chrome::FILE_PEPPER_FLASH_PLUGIN:
309 if (!PathService::Get(chrome::DIR_PEPPER_FLASH_PLUGIN, &cur))
310 return false;
311 cur = cur.Append(chrome::kPepperFlashPluginFilename);
312 break;
313 // TODO(teravest): Remove this case once the internal NaCl plugin is gone.
314 // We currently need a path here to look up whether the plugin is disabled
315 // and what its permissions are.
316 case chrome::FILE_NACL_PLUGIN:
317 if (!GetInternalPluginsDirectory(&cur))
318 return false;
319 cur = cur.Append(kInternalNaClPluginFileName);
320 break;
321 // PNaCl is currenly installable via the component updater or by being
322 // simply built-in. DIR_PNACL_BASE is used as the base directory for
323 // installation via component updater. DIR_PNACL_COMPONENT will be
324 // the final location of pnacl, which is a subdir of DIR_PNACL_BASE.
325 case chrome::DIR_PNACL_BASE:
326 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
327 return false;
328 cur = cur.Append(FILE_PATH_LITERAL("pnacl"));
329 break;
330 // Where PNaCl files are ultimately located. The default finds the files
331 // inside the InternalPluginsDirectory / build directory, as if it
332 // was shipped along with chrome. The value can be overridden
333 // if it is installed via component updater.
334 case chrome::DIR_PNACL_COMPONENT:
335 #if defined(OS_MACOSX)
336 // PNaCl really belongs in the InternalPluginsDirectory but actually
337 // copying it there would result in the files also being shipped, which
338 // we don't want yet. So for now, just find them in the directory where
339 // they get built.
340 if (!PathService::Get(base::DIR_EXE, &cur))
341 return false;
342 if (base::mac::AmIBundled()) {
343 // If we're called from chrome, it's beside the app (outside the
344 // app bundle), if we're called from a unittest, we'll already be
345 // outside the bundle so use the exe dir.
346 // exe_dir gave us .../Chromium.app/Contents/MacOS/Chromium.
347 cur = cur.DirName();
348 cur = cur.DirName();
349 cur = cur.DirName();
351 #else
352 if (!GetInternalPluginsDirectory(&cur))
353 return false;
354 #endif
355 cur = cur.Append(FILE_PATH_LITERAL("pnacl"));
356 break;
357 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
358 #if defined(WIDEVINE_CDM_IS_COMPONENT)
359 case chrome::DIR_COMPONENT_WIDEVINE_CDM:
360 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
361 return false;
362 cur = cur.Append(kWidevineCdmBaseDirectory);
363 break;
364 #endif // defined(WIDEVINE_CDM_IS_COMPONENT)
365 // TODO(xhwang): FILE_WIDEVINE_CDM_ADAPTER has different meanings.
366 // In the component case, this is the source adapter. Otherwise, it is the
367 // actual Pepper module that gets loaded.
368 case chrome::FILE_WIDEVINE_CDM_ADAPTER:
369 if (!GetInternalPluginsDirectory(&cur))
370 return false;
371 cur = cur.AppendASCII(kWidevineCdmAdapterFileName);
372 break;
373 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
374 case chrome::FILE_RESOURCES_PACK:
375 #if defined(OS_MACOSX) && !defined(OS_IOS)
376 if (base::mac::AmIBundled()) {
377 cur = base::mac::FrameworkBundlePath();
378 cur = cur.Append(FILE_PATH_LITERAL("Resources"))
379 .Append(FILE_PATH_LITERAL("resources.pak"));
380 break;
382 #elif defined(OS_ANDROID)
383 if (!PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &cur))
384 return false;
385 #else
386 // If we're not bundled on mac or Android, resources.pak should be next
387 // to the binary (e.g., for unit tests).
388 if (!PathService::Get(base::DIR_MODULE, &cur))
389 return false;
390 #endif
391 cur = cur.Append(FILE_PATH_LITERAL("resources.pak"));
392 break;
393 case chrome::DIR_RESOURCES_EXTENSION:
394 if (!PathService::Get(base::DIR_MODULE, &cur))
395 return false;
396 cur = cur.Append(FILE_PATH_LITERAL("resources"))
397 .Append(FILE_PATH_LITERAL("extension"));
398 break;
399 #if defined(OS_CHROMEOS)
400 case chrome::DIR_CHROMEOS_WALLPAPERS:
401 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
402 return false;
403 cur = cur.Append(FILE_PATH_LITERAL("wallpapers"));
404 break;
405 case chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS:
406 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
407 return false;
408 cur = cur.Append(FILE_PATH_LITERAL("wallpaper_thumbnails"));
409 break;
410 case chrome::DIR_CHROMEOS_CUSTOM_WALLPAPERS:
411 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
412 return false;
413 cur = cur.Append(FILE_PATH_LITERAL("custom_wallpapers"));
414 break;
415 #endif
416 #if defined(OS_LINUX) && defined(ENABLE_SUPERVISED_USERS)
417 case chrome::DIR_SUPERVISED_USERS_DEFAULT_APPS:
418 if (!PathService::Get(chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS, &cur))
419 return false;
420 cur = cur.Append(FILE_PATH_LITERAL("managed_users"));
421 break;
422 #endif
423 // The following are only valid in the development environment, and
424 // will fail if executed from an installed executable (because the
425 // generated path won't exist).
426 case chrome::DIR_GEN_TEST_DATA:
427 #if defined(OS_ANDROID)
428 // On Android, our tests don't have permission to write to DIR_MODULE.
429 // gtest/test_runner.py pushes data to external storage.
430 if (!PathService::Get(base::DIR_ANDROID_EXTERNAL_STORAGE, &cur))
431 return false;
432 #else
433 if (!PathService::Get(base::DIR_MODULE, &cur))
434 return false;
435 #endif
436 cur = cur.Append(FILE_PATH_LITERAL("test_data"));
437 if (!base::PathExists(cur)) // We don't want to create this.
438 return false;
439 break;
440 case chrome::DIR_TEST_DATA:
441 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
442 return false;
443 cur = cur.Append(FILE_PATH_LITERAL("chrome"));
444 cur = cur.Append(FILE_PATH_LITERAL("test"));
445 cur = cur.Append(FILE_PATH_LITERAL("data"));
446 if (!base::PathExists(cur)) // We don't want to create this.
447 return false;
448 break;
449 case chrome::DIR_TEST_TOOLS:
450 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
451 return false;
452 cur = cur.Append(FILE_PATH_LITERAL("chrome"));
453 cur = cur.Append(FILE_PATH_LITERAL("tools"));
454 cur = cur.Append(FILE_PATH_LITERAL("test"));
455 if (!base::PathExists(cur)) // We don't want to create this
456 return false;
457 break;
458 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
459 case chrome::DIR_POLICY_FILES: {
460 #if defined(GOOGLE_CHROME_BUILD)
461 cur = base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies"));
462 #else
463 cur = base::FilePath(FILE_PATH_LITERAL("/etc/chromium/policies"));
464 #endif
465 break;
467 #endif
468 #if defined(OS_MACOSX) && !defined(OS_IOS)
469 case chrome::DIR_USER_LIBRARY: {
470 if (!GetUserLibraryDirectory(&cur))
471 return false;
472 if (!base::PathExists(cur)) // We don't want to create this.
473 return false;
474 break;
476 case chrome::DIR_USER_APPLICATIONS: {
477 if (!GetUserApplicationsDirectory(&cur))
478 return false;
479 if (!base::PathExists(cur)) // We don't want to create this.
480 return false;
481 break;
483 #endif
484 #if defined(OS_CHROMEOS) || (defined(OS_MACOSX) && !defined(OS_IOS))
485 case chrome::DIR_USER_EXTERNAL_EXTENSIONS: {
486 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
487 return false;
488 cur = cur.Append(FILE_PATH_LITERAL("External Extensions"));
489 break;
491 #endif
492 #if defined(OS_LINUX)
493 case chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS: {
494 cur = base::FilePath(kFilepathSinglePrefExtensions);
495 break;
497 #endif
498 case chrome::DIR_EXTERNAL_EXTENSIONS:
499 #if defined(OS_MACOSX) && !defined(OS_IOS)
500 if (!chrome::GetGlobalApplicationSupportDirectory(&cur))
501 return false;
503 cur = cur.Append(FILE_PATH_LITERAL("Google"))
504 .Append(FILE_PATH_LITERAL("Chrome"))
505 .Append(FILE_PATH_LITERAL("External Extensions"));
506 create_dir = false;
507 #else
508 if (!PathService::Get(base::DIR_MODULE, &cur))
509 return false;
511 cur = cur.Append(FILE_PATH_LITERAL("extensions"));
512 create_dir = true;
513 #endif
514 break;
516 case chrome::DIR_DEFAULT_APPS:
517 #if defined(OS_MACOSX)
518 cur = base::mac::FrameworkBundlePath();
519 cur = cur.Append(FILE_PATH_LITERAL("Default Apps"));
520 #else
521 if (!PathService::Get(chrome::DIR_APP, &cur))
522 return false;
523 cur = cur.Append(FILE_PATH_LITERAL("default_apps"));
524 #endif
525 break;
527 #if defined(OS_LINUX) || (defined(OS_MACOSX) && !defined(OS_IOS))
528 case chrome::DIR_NATIVE_MESSAGING:
529 #if defined(OS_MACOSX)
530 #if defined(GOOGLE_CHROME_BUILD)
531 cur = base::FilePath(FILE_PATH_LITERAL(
532 "/Library/Google/Chrome/NativeMessagingHosts"));
533 #else
534 cur = base::FilePath(FILE_PATH_LITERAL(
535 "/Library/Application Support/Chromium/NativeMessagingHosts"));
536 #endif
537 #else // defined(OS_MACOSX)
538 #if defined(GOOGLE_CHROME_BUILD)
539 cur = base::FilePath(FILE_PATH_LITERAL(
540 "/etc/opt/chrome/native-messaging-hosts"));
541 #else
542 cur = base::FilePath(FILE_PATH_LITERAL(
543 "/etc/chromium/native-messaging-hosts"));
544 #endif
545 #endif // !defined(OS_MACOSX)
546 break;
548 case chrome::DIR_USER_NATIVE_MESSAGING:
549 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
550 return false;
551 cur = cur.Append(FILE_PATH_LITERAL("NativeMessagingHosts"));
552 break;
553 #endif // defined(OS_LINUX) || (defined(OS_MACOSX) && !defined(OS_IOS))
554 #if !defined(OS_ANDROID)
555 case chrome::DIR_GLOBAL_GCM_STORE:
556 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
557 return false;
558 cur = cur.Append(kGCMStoreDirname);
559 break;
560 #endif // !defined(OS_ANDROID)
561 #if defined(OS_ANDROID)
562 case chrome::DIR_OFFLINE_PAGE_METADATA:
563 if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
564 return false;
565 cur = cur.Append(kOfflinePageMetadataDirname);
566 break;
567 #endif // defined(OS_ANDROID)
569 default:
570 return false;
573 // TODO(bauerb): http://crbug.com/259796
574 base::ThreadRestrictions::ScopedAllowIO allow_io;
575 if (create_dir && !base::PathExists(cur) &&
576 !base::CreateDirectory(cur))
577 return false;
579 *result = cur;
580 return true;
583 // This cannot be done as a static initializer sadly since Visual Studio will
584 // eliminate this object file if there is no direct entry point into it.
585 void RegisterPathProvider() {
586 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
589 void SetInvalidSpecifiedUserDataDir(const base::FilePath& user_data_dir) {
590 g_invalid_specified_user_data_dir.Get() = user_data_dir;
593 const base::FilePath& GetInvalidSpecifiedUserDataDir() {
594 return g_invalid_specified_user_data_dir.Get();
597 } // namespace chrome