Roll src/third_party/skia f5872d2:ef0b4e7
[chromium-blink-merge.git] / chromeos / chromeos_paths.cc
blob07b7f9fee7bad2b1be2cf0486db7de49698f4844
1 // Copyright (c) 2013 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 "chromeos/chromeos_paths.h"
7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h"
9 #include "base/path_service.h"
10 #include "base/sys_info.h"
12 namespace chromeos {
14 namespace {
16 const base::FilePath::CharType kDefaultAppOrderFileName[] =
17 #if defined(GOOGLE_CHROME_BUILD)
18 FILE_PATH_LITERAL("/usr/share/google-chrome/default_app_order.json");
19 #else
20 FILE_PATH_LITERAL("/usr/share/chromium/default_app_order.json");
21 #endif // defined(GOOGLE_CHROME_BUILD)
23 const base::FilePath::CharType kDefaultUserPolicyKeysDir[] =
24 FILE_PATH_LITERAL("/var/run/user_policy");
26 const base::FilePath::CharType kOwnerKeyFileName[] =
27 FILE_PATH_LITERAL("/var/lib/whitelist/owner.key");
29 const base::FilePath::CharType kInstallAttributesFileName[] =
30 FILE_PATH_LITERAL("/var/run/lockbox/install_attributes.pb");
32 const base::FilePath::CharType kMachineHardwareInfoFileName[] =
33 FILE_PATH_LITERAL("/tmp/machine-info");
35 const base::FilePath::CharType kUptimeFileName[] =
36 FILE_PATH_LITERAL("/proc/uptime");
38 const base::FilePath::CharType kUpdateRebootNeededUptimeFile[] =
39 FILE_PATH_LITERAL("/var/run/chrome/update_reboot_needed_uptime");
41 const base::FilePath::CharType kDeviceLocalAccountExtensionDir[] =
42 FILE_PATH_LITERAL("/var/cache/device_local_account_extensions");
44 const base::FilePath::CharType kDeviceLocalAccountExternalDataDir[] =
45 FILE_PATH_LITERAL("/var/cache/device_local_account_external_policy_data");
47 const base::FilePath::CharType kDeviceLocalAccountComponentPolicy[] =
48 FILE_PATH_LITERAL("/var/cache/device_local_account_component_policy");
50 bool PathProvider(int key, base::FilePath* result) {
51 switch (key) {
52 case FILE_DEFAULT_APP_ORDER:
53 *result = base::FilePath(kDefaultAppOrderFileName);
54 break;
55 case DIR_USER_POLICY_KEYS:
56 *result = base::FilePath(kDefaultUserPolicyKeysDir);
57 break;
58 case FILE_OWNER_KEY:
59 *result = base::FilePath(kOwnerKeyFileName);
60 break;
61 case FILE_INSTALL_ATTRIBUTES:
62 *result = base::FilePath(kInstallAttributesFileName);
63 break;
64 case FILE_MACHINE_INFO:
65 *result = base::FilePath(kMachineHardwareInfoFileName);
66 break;
67 case FILE_UPTIME:
68 *result = base::FilePath(kUptimeFileName);
69 break;
70 case FILE_UPDATE_REBOOT_NEEDED_UPTIME:
71 *result = base::FilePath(kUpdateRebootNeededUptimeFile);
72 break;
73 case DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS:
74 *result = base::FilePath(kDeviceLocalAccountExtensionDir);
75 break;
76 case DIR_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA:
77 *result = base::FilePath(kDeviceLocalAccountExternalDataDir);
78 break;
79 case DIR_DEVICE_LOCAL_ACCOUNT_COMPONENT_POLICY:
80 *result = base::FilePath(kDeviceLocalAccountComponentPolicy);
81 break;
82 default:
83 return false;
85 return true;
88 } // namespace
90 void RegisterPathProvider() {
91 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
94 void RegisterStubPathOverrides(const base::FilePath& stubs_dir) {
95 CHECK(!base::SysInfo::IsRunningOnChromeOS());
96 // Override these paths on the desktop, so that enrollment and cloud
97 // policy work and can be tested.
98 base::FilePath parent = base::MakeAbsoluteFilePath(stubs_dir);
99 PathService::Override(
100 DIR_USER_POLICY_KEYS,
101 parent.AppendASCII("stub_user_policy"));
102 const bool is_absolute = true;
103 const bool create = false;
104 PathService::OverrideAndCreateIfNeeded(
105 FILE_OWNER_KEY,
106 parent.AppendASCII("stub_owner.key"),
107 is_absolute,
108 create);
109 PathService::OverrideAndCreateIfNeeded(
110 FILE_INSTALL_ATTRIBUTES,
111 parent.AppendASCII("stub_install_attributes.pb"),
112 is_absolute,
113 create);
114 PathService::OverrideAndCreateIfNeeded(
115 FILE_MACHINE_INFO,
116 parent.AppendASCII("stub_machine-info"),
117 is_absolute,
118 create);
119 PathService::Override(
120 DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS,
121 parent.AppendASCII("stub_device_local_account_extensions"));
122 PathService::Override(
123 DIR_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA,
124 parent.AppendASCII("stub_device_local_account_external_data"));
125 PathService::Override(
126 DIR_DEVICE_LOCAL_ACCOUNT_COMPONENT_POLICY,
127 parent.AppendASCII("stub_device_local_account_component_policy"));
130 } // namespace chromeos