Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chromecast / common / cast_paths.cc
blobec485c7e57537f92eff02238fafc1c0649c90192
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/common/cast_paths.h"
7 #include "base/base_paths.h"
8 #include "base/file_util.h"
9 #include "base/files/file_path.h"
10 #include "base/path_service.h"
11 #include "build/build_config.h"
13 namespace chromecast {
15 bool PathProvider(int key, base::FilePath* result) {
16 switch (key) {
17 case DIR_CAST_HOME: {
18 base::FilePath home = base::GetHomeDir();
19 #if defined(ARCH_CPU_ARMEL)
20 // When running on the actual device, $HOME is set to the user's
21 // directory under the data partition.
22 *result = home;
23 #else
24 // When running a development instance as a regular user, use
25 // a data directory under $HOME (similar to Chrome).
26 *result = home.Append(".config/cast_shell");
27 #endif
28 return true;
30 case FILE_CAST_CONFIG: {
31 base::FilePath data_dir;
32 #if defined(OS_ANDROID)
33 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &data_dir);
34 *result = data_dir.Append("cast_shell.conf");
35 #else
36 CHECK(PathService::Get(DIR_CAST_HOME, &data_dir));
37 *result = data_dir.Append(".eureka.conf");
38 #endif // defined(OS_ANDROID)
39 return true;
41 case FILE_CAST_PAK: {
42 base::FilePath base_dir;
43 #if defined(OS_ANDROID)
44 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &base_dir));
45 *result = base_dir.Append("paks/cast_shell.pak");
46 #else
47 CHECK(PathService::Get(base::DIR_MODULE, &base_dir));
48 *result = base_dir.Append("assets/cast_shell.pak");
49 #endif // defined(OS_ANDROID)
50 return true;
53 return false;
56 void RegisterPathProvider() {
57 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
60 } // namespace chromecast