fixup! [M120 Migration] Notify media device state to webbrowser
[platform/framework/web/chromium-efl.git] / base / base_paths_android.cc
1 // Copyright 2012 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 // Defines base::PathProviderAndroid which replaces base::PathProviderPosix for
6 // Android in base/path_service.cc.
7
8 #include <limits.h>
9 #include <unistd.h>
10
11 #include <ostream>
12
13 #include "base/android/jni_android.h"
14 #include "base/android/path_utils.h"
15 #include "base/base_paths.h"
16 #include "base/files/file_path.h"
17 #include "base/files/file_util.h"
18 #include "base/logging.h"
19 #include "base/notreached.h"
20 #include "base/process/process_metrics.h"
21
22 namespace base {
23
24 bool PathProviderAndroid(int key, FilePath* result) {
25   switch (key) {
26     case base::FILE_EXE: {
27       FilePath bin_dir;
28       if (!ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) {
29         // This fails for some devices (maybe custom OEM selinux policy?)
30         // https://crbug.com/1416753
31         LOG(ERROR) << "Unable to resolve " << kProcSelfExe << ".";
32         return false;
33       }
34       *result = bin_dir;
35       return true;
36     }
37     case base::FILE_MODULE:
38       // dladdr didn't work in Android as only the file name was returned.
39       NOTIMPLEMENTED();
40       return false;
41     case base::DIR_MODULE:
42       return base::android::GetNativeLibraryDirectory(result);
43     case base::DIR_SRC_TEST_DATA_ROOT:
44     case base::DIR_OUT_TEST_DATA_ROOT:
45       // These are only used by tests. In that context, they are overridden by
46       // PathProviders in //base/test/test_support_android.cc.
47       NOTIMPLEMENTED();
48       return false;
49     case base::DIR_USER_DESKTOP:
50       // Android doesn't support GetUserDesktop.
51       NOTIMPLEMENTED();
52       return false;
53     case base::DIR_CACHE:
54       return base::android::GetCacheDirectory(result);
55     case base::DIR_ASSETS:
56       // On Android assets are normally loaded from the APK using
57       // base::android::OpenApkAsset(). In tests, since the assets are no
58       // packaged, DIR_ASSETS is overridden to point to the build directory.
59       return false;
60     case base::DIR_ANDROID_APP_DATA:
61       return base::android::GetDataDirectory(result);
62     case base::DIR_ANDROID_EXTERNAL_STORAGE:
63       return base::android::GetExternalStorageDirectory(result);
64   }
65
66   // For all other keys, let the PathService fall back to a default, if defined.
67   return false;
68 }
69
70 }  // namespace base