Simple Cache: remove experiment code for flush intervals.
[chromium-blink-merge.git] / chromeos / chromeos_paths.cc
bloba9963affe335654e38df140c71d496dfbebd4af2
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/file_util.h"
8 #include "base/files/file_path.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 kUptimeFileName[] =
33 FILE_PATH_LITERAL("/proc/uptime");
35 const base::FilePath::CharType kUpdateRebootNeededUptimeFile[] =
36 FILE_PATH_LITERAL("/var/run/chrome/update_reboot_needed_uptime");
38 const base::FilePath::CharType kDeviceLocalAccountExtensionDir[] =
39 FILE_PATH_LITERAL("/var/cache/device_local_account_extensions");
41 const base::FilePath::CharType kDeviceLocalAccountExternalDataDir[] =
42 FILE_PATH_LITERAL("/var/cache/device_local_account_external_policy_data");
44 bool PathProvider(int key, base::FilePath* result) {
45 switch (key) {
46 case FILE_DEFAULT_APP_ORDER:
47 *result = base::FilePath(kDefaultAppOrderFileName);
48 break;
49 case DIR_USER_POLICY_KEYS:
50 *result = base::FilePath(kDefaultUserPolicyKeysDir);
51 break;
52 case FILE_OWNER_KEY:
53 *result = base::FilePath(kOwnerKeyFileName);
54 break;
55 case FILE_INSTALL_ATTRIBUTES:
56 *result = base::FilePath(kInstallAttributesFileName);
57 break;
58 case FILE_UPTIME:
59 *result = base::FilePath(kUptimeFileName);
60 break;
61 case FILE_UPDATE_REBOOT_NEEDED_UPTIME:
62 *result = base::FilePath(kUpdateRebootNeededUptimeFile);
63 break;
64 case DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS:
65 *result = base::FilePath(kDeviceLocalAccountExtensionDir);
66 break;
67 case DIR_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA:
68 *result = base::FilePath(kDeviceLocalAccountExternalDataDir);
69 break;
70 default:
71 return false;
73 return true;
76 } // namespace
78 void RegisterPathProvider() {
79 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
82 void RegisterStubPathOverrides(const base::FilePath& stubs_dir) {
83 CHECK(!base::SysInfo::IsRunningOnChromeOS());
84 // Override these paths on the desktop, so that enrollment and cloud
85 // policy work and can be tested.
86 base::FilePath parent = base::MakeAbsoluteFilePath(stubs_dir);
87 PathService::Override(
88 DIR_USER_POLICY_KEYS,
89 parent.AppendASCII("stub_user_policy"));
90 const bool is_absolute = true;
91 const bool create = false;
92 PathService::OverrideAndCreateIfNeeded(
93 FILE_OWNER_KEY,
94 parent.AppendASCII("stub_owner.key"),
95 is_absolute,
96 create);
97 PathService::OverrideAndCreateIfNeeded(
98 FILE_INSTALL_ATTRIBUTES,
99 parent.AppendASCII("stub_install_attributes.pb"),
100 is_absolute,
101 create);
104 } // namespace chromeos