Add DIR_ASSETS in PathService.
Currently DIR_MODULE is used when loading assets such as ICU data or .pak
files. On some platforms these files are stored in a separate directory.
Fuchsia solves this problem with DIR_FUCHSIA_RESOURCE. Android uses
DIR_ANDROID_APP_DATA in tests. This approach doesn't scale well because it
requires platform-specific ifdefs when loading asset files, and this
defeats the purpose of base::PathServer.
This change adds cross-platform DIR_ASSETS that can be used on all
platforms. The values is platform specific:
Win/Linux/ChromeOS: DIR_ASSETS = DIR_MODULE
Mac: DIR_ASSETS = <bundle_path>/Resources
or DIR_MODULE when not bundled.
Android: DIR_ASSETS = Undefined since resources are loaded from APK.
Overriden in test.
Fuchsia: DIR_ASSETS = DIR_FUCHSIA_RESOURCE (i.e. /pkg)
or DIR_MODULE when not packaged.
Also removed DIR_FUCHSIA_RESOURCE and marked DIR_ANDROID_APP_DATA as
deprecated.
Bug: 805727, 617734
Change-Id: Id54305669f786c41c2dde0851daea1504547a866
Reviewed-on: https://chromium-review.googlesource.com/885002
Reviewed-by: danakj <[email protected]>
Reviewed-by: Wez <[email protected]>
Reviewed-by: Jochen Eisinger <[email protected]>
Reviewed-by: Kevin Marshall <[email protected]>
Commit-Queue: Sergey Ulanov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#535118}
diff --git a/base/base_paths.cc b/base/base_paths.cc
index 31bc554..e3f322e 100644
--- a/base/base_paths.cc
+++ b/base/base_paths.cc
@@ -15,17 +15,19 @@
switch (key) {
case DIR_EXE:
- PathService::Get(FILE_EXE, result);
+ if (!PathService::Get(FILE_EXE, result))
+ return false;
*result = result->DirName();
return true;
case DIR_MODULE:
- PathService::Get(FILE_MODULE, result);
+ if (!PathService::Get(FILE_MODULE, result))
+ return false;
*result = result->DirName();
return true;
+ case DIR_ASSETS:
+ return PathService::Get(DIR_MODULE, result);
case DIR_TEMP:
- if (!GetTempDir(result))
- return false;
- return true;
+ return GetTempDir(result);
case base::DIR_HOME:
*result = GetHomeDir();
return true;