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