Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: components/component_updater/component_updater_paths.cc

Issue 2085583005: Allow DCI to pick up contents from Internet Plug-Ins on OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarified comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/component_updater/component_updater_paths.h" 5 #include "components/component_updater/component_updater_paths.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 9
10 namespace component_updater { 10 namespace component_updater {
11 11
12 namespace { 12 namespace {
13 13
14 // This key gives the root directory of all the component installations. 14 // This key gives the root directory of all the component installations.
15 static int g_components_preinstalled_root_key = -1; 15 static int g_components_preinstalled_root_key = -1;
16 static int g_components_preinstalled_root_key_alt = -1;
16 static int g_components_user_root_key = -1; 17 static int g_components_user_root_key = -1;
17 18
18 } // namespace 19 } // namespace
19 20
20 const base::FilePath::CharType kSupervisedUserWhitelistDirName[] = 21 const base::FilePath::CharType kSupervisedUserWhitelistDirName[] =
21 FILE_PATH_LITERAL("SupervisedUserWhitelists"); 22 FILE_PATH_LITERAL("SupervisedUserWhitelists");
22 23
23 bool PathProvider(int key, base::FilePath* result) { 24 bool PathProvider(int key, base::FilePath* result) {
24 DCHECK_GT(g_components_user_root_key, 0); 25 DCHECK_GT(g_components_user_root_key, 0);
25 DCHECK_GT(g_components_preinstalled_root_key, 0); 26 DCHECK_GT(g_components_preinstalled_root_key, 0);
26 27
27 // Early exit here to prevent a potential infinite loop when we retrieve 28 // Early exit here to prevent a potential infinite loop when we retrieve
28 // the path for g_components_*_root_key. 29 // the path for g_components_*_root_key.
29 if (key < PATH_START || key > PATH_END) 30 if (key < PATH_START || key > PATH_END)
30 return false; 31 return false;
31 32
32 switch (key) { 33 switch (key) {
33 case DIR_COMPONENT_PREINSTALLED: 34 case DIR_COMPONENT_PREINSTALLED:
34 return PathService::Get(g_components_preinstalled_root_key, result); 35 return PathService::Get(g_components_preinstalled_root_key, result);
36 case DIR_COMPONENT_PREINSTALLED_ALT:
37 return PathService::Get(g_components_preinstalled_root_key_alt, result);
35 case DIR_COMPONENT_USER: 38 case DIR_COMPONENT_USER:
36 return PathService::Get(g_components_user_root_key, result); 39 return PathService::Get(g_components_user_root_key, result);
37 } 40 }
38 41
39 base::FilePath cur; 42 base::FilePath cur;
40 if (!PathService::Get(g_components_user_root_key, &cur)) 43 if (!PathService::Get(g_components_user_root_key, &cur))
41 return false; 44 return false;
42 45
43 switch (key) { 46 switch (key) {
44 case DIR_COMPONENT_CLD2: 47 case DIR_COMPONENT_CLD2:
(...skipping 12 matching lines...) Expand all
57 return false; 60 return false;
58 } 61 }
59 62
60 *result = cur; 63 *result = cur;
61 return true; 64 return true;
62 } 65 }
63 66
64 // This cannot be done as a static initializer sadly since Visual Studio will 67 // This cannot be done as a static initializer sadly since Visual Studio will
65 // eliminate this object file if there is no direct entry point into it. 68 // eliminate this object file if there is no direct entry point into it.
66 void RegisterPathProvider(int components_preinstalled_root_key, 69 void RegisterPathProvider(int components_preinstalled_root_key,
70 int components_preinstalled_root_key_alt,
67 int components_user_root_key) { 71 int components_user_root_key) {
68 DCHECK_EQ(g_components_preinstalled_root_key, -1); 72 DCHECK_EQ(g_components_preinstalled_root_key, -1);
73 DCHECK_EQ(g_components_preinstalled_root_key_alt, -1);
69 DCHECK_EQ(g_components_user_root_key, -1); 74 DCHECK_EQ(g_components_user_root_key, -1);
70 DCHECK_GT(components_preinstalled_root_key, 0); 75 DCHECK_GT(components_preinstalled_root_key, 0);
76 DCHECK_GT(components_preinstalled_root_key_alt, 0);
71 DCHECK_GT(components_user_root_key, 0); 77 DCHECK_GT(components_user_root_key, 0);
72 DCHECK(components_preinstalled_root_key < PATH_START || 78 DCHECK(components_preinstalled_root_key < PATH_START ||
73 components_preinstalled_root_key > PATH_END); 79 components_preinstalled_root_key > PATH_END);
80 DCHECK(components_preinstalled_root_key_alt < PATH_START ||
81 components_preinstalled_root_key_alt > PATH_END);
74 DCHECK(components_user_root_key < PATH_START || 82 DCHECK(components_user_root_key < PATH_START ||
75 components_user_root_key > PATH_END); 83 components_user_root_key > PATH_END);
76 84
77 g_components_preinstalled_root_key = components_preinstalled_root_key; 85 g_components_preinstalled_root_key = components_preinstalled_root_key;
86 g_components_preinstalled_root_key_alt = components_preinstalled_root_key_alt;
78 g_components_user_root_key = components_user_root_key; 87 g_components_user_root_key = components_user_root_key;
79 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); 88 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
80 } 89 }
81 90
82 } // namespace component_updater 91 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698