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.
5 #include "chromecast/base/cast_paths.h"
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"
14 namespace chromecast
{
16 bool PathProvider(int key
, base::FilePath
* result
) {
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.
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");
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");
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");
45 CHECK(PathService::Get(DIR_CAST_HOME
, &data_dir
));
46 *result
= data_dir
.Append(".eureka.conf");
47 #endif // defined(OS_ANDROID)
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");
56 CHECK(PathService::Get(base::DIR_MODULE
, &base_dir
));
57 *result
= base_dir
.Append("assets/cast_shell.pak");
58 #endif // defined(OS_ANDROID)
65 void RegisterPathProvider() {
66 PathService::RegisterProvider(PathProvider
, PATH_START
, PATH_END
);
69 } // namespace chromecast