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 "components/component_updater/component_updater_paths.h"
7 #include "base/lazy_instance.h"
8 #include "base/path_service.h"
10 namespace component_updater
{
14 // This key gives the root directory of all the component installations.
15 static int g_components_root_key
= -1;
19 bool PathProvider(int key
, base::FilePath
* result
) {
20 DCHECK_GT(g_components_root_key
, 0);
22 // Early exit here to prevent a potential infinite loop when we retrieve
23 // the path for g_components_root_key.
24 if (key
< PATH_START
|| key
> PATH_END
)
28 if (!PathService::Get(g_components_root_key
, &cur
))
32 case DIR_COMPONENT_CLD2
:
33 cur
= cur
.Append(FILE_PATH_LITERAL("CLD"));
35 case DIR_RECOVERY_BASE
:
36 cur
= cur
.Append(FILE_PATH_LITERAL("recovery"));
38 case DIR_SWIFT_SHADER
:
39 cur
= cur
.Append(FILE_PATH_LITERAL("SwiftShader"));
42 cur
= cur
.Append(FILE_PATH_LITERAL("SwReporter"));
44 case DIR_COMPONENT_EV_WHITELIST
:
45 cur
= cur
.Append(FILE_PATH_LITERAL("EVWhitelist"));
47 case DIR_SUPERVISED_USER_WHITELISTS
:
48 cur
= cur
.Append(FILE_PATH_LITERAL("SupervisedUserWhitelists"));
58 // This cannot be done as a static initializer sadly since Visual Studio will
59 // eliminate this object file if there is no direct entry point into it.
60 void RegisterPathProvider(int components_root_key
) {
61 DCHECK_EQ(g_components_root_key
, -1);
62 DCHECK_GT(components_root_key
, 0);
63 DCHECK(components_root_key
< PATH_START
|| components_root_key
> PATH_END
);
65 g_components_root_key
= components_root_key
;
66 PathService::RegisterProvider(PathProvider
, PATH_START
, PATH_END
);
69 } // namespace component_updater