xref: /aosp_15_r20/external/cronet/base/base_paths_fuchsia.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2017 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/base_paths.h"
6 
7 #include <stdlib.h>
8 
9 #include "base/command_line.h"
10 #include "base/files/file_util.h"
11 #include "base/fuchsia/file_utils.h"
12 #include "base/notimplemented.h"
13 #include "base/path_service.h"
14 #include "base/process/process.h"
15 
16 namespace base {
17 
PathProviderFuchsia(int key,FilePath * result)18 bool PathProviderFuchsia(int key, FilePath* result) {
19   switch (key) {
20     case FILE_EXE:
21       *result = CommandLine::ForCurrentProcess()->GetProgram();
22       return true;
23     case DIR_ASSETS:
24       *result = base::FilePath(base::kPackageRootDirectoryPath);
25       return true;
26 
27     // TODO(crbug.com/1459692): Align with other platforms and remove this
28     // specialization.
29     case DIR_GEN_TEST_DATA_ROOT:
30       [[fallthrough]];
31 
32     case DIR_SRC_TEST_DATA_ROOT:
33     case DIR_OUT_TEST_DATA_ROOT:
34       // These are only used by tests.
35       // Test binaries are added to the package root via GN deps.
36       *result = base::FilePath(base::kPackageRootDirectoryPath);
37       return true;
38     case DIR_USER_DESKTOP:
39       // TODO(crbug.com/1231928): Implement this case for DIR_USER_DESKTOP.
40       NOTIMPLEMENTED_LOG_ONCE();
41       return false;
42     case DIR_HOME:
43       // TODO(crbug.com/1231928) Provide a proper base::GetHomeDir()
44       // implementation for Fuchsia and remove this case statement. See also
45       // crbug.com/1261284. For now, log, return false, and let the base
46       // implementation handle it. This will end up returning a temporary
47       // directory.
48       // This is for DIR_HOME. Will use temporary dir.
49       NOTIMPLEMENTED_LOG_ONCE();
50       return false;
51   }
52 
53   return false;
54 }
55 
56 }  // namespace base
57