OLD | NEW |
| (Empty) |
1 // Copyright 2014 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. | |
4 | |
5 #include "chromecast/common/cast_paths.h" | |
6 | |
7 #include "base/base_paths.h" | |
8 #include "base/files/file_path.h" | |
9 #include "base/files/file_util.h" | |
10 #include "base/logging.h" | |
11 #include "base/path_service.h" | |
12 #include "build/build_config.h" | |
13 | |
14 namespace chromecast { | |
15 | |
16 bool PathProvider(int key, base::FilePath* result) { | |
17 switch (key) { | |
18 case DIR_CAST_HOME: { | |
19 base::FilePath home = base::GetHomeDir(); | |
20 #if defined(ARCH_CPU_ARMEL) | |
21 // When running on the actual device, $HOME is set to the user's | |
22 // directory under the data partition. | |
23 *result = home; | |
24 #else | |
25 // When running a development instance as a regular user, use | |
26 // a data directory under $HOME (similar to Chrome). | |
27 *result = home.Append(".config/cast_shell"); | |
28 #endif | |
29 return true; | |
30 } | |
31 #if defined(OS_ANDROID) | |
32 case FILE_CAST_ANDROID_LOG: { | |
33 base::FilePath base_dir; | |
34 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &base_dir)); | |
35 *result = base_dir.AppendASCII("cast_shell.log"); | |
36 return true; | |
37 } | |
38 #endif // defined(OS_ANDROID) | |
39 case FILE_CAST_CONFIG: { | |
40 base::FilePath data_dir; | |
41 #if defined(OS_ANDROID) | |
42 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &data_dir)); | |
43 *result = data_dir.Append("cast_shell.conf"); | |
44 #else | |
45 CHECK(PathService::Get(DIR_CAST_HOME, &data_dir)); | |
46 *result = data_dir.Append(".eureka.conf"); | |
47 #endif // defined(OS_ANDROID) | |
48 return true; | |
49 } | |
50 case FILE_CAST_PAK: { | |
51 base::FilePath base_dir; | |
52 #if defined(OS_ANDROID) | |
53 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &base_dir)); | |
54 *result = base_dir.Append("paks/cast_shell.pak"); | |
55 #else | |
56 CHECK(PathService::Get(base::DIR_MODULE, &base_dir)); | |
57 *result = base_dir.Append("assets/cast_shell.pak"); | |
58 #endif // defined(OS_ANDROID) | |
59 return true; | |
60 } | |
61 } | |
62 return false; | |
63 } | |
64 | |
65 void RegisterPathProvider() { | |
66 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | |
67 } | |
68 | |
69 } // namespace chromecast | |
OLD | NEW |