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

Side by Side Diff: components/policy/core/common/policy_loader_win.cc

Issue 375903002: Fix EnterpriseDeviceManagementStatus UMA enum, add comments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cosmetics. Created 6 years, 5 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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/policy/core/common/policy_loader_win.h" 5 #include "components/policy/core/common/policy_loader_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <lm.h> // For limits. 8 #include <lm.h> // For limits.
9 #include <ntdsapi.h> // For Ds[Un]Bind 9 #include <ntdsapi.h> // For Ds[Un]Bind
10 #include <rpc.h> // For struct GUID 10 #include <rpc.h> // For struct GUID
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const char kExpectedWebStoreUrl[] = 70 const char kExpectedWebStoreUrl[] =
71 ";https://clients2.google.com/service/update2/crx"; 71 ";https://clients2.google.com/service/update2/crx";
72 // String to be prepended to each blocked entry. 72 // String to be prepended to each blocked entry.
73 const char kBlockedExtensionPrefix[] = "[BLOCKED]"; 73 const char kBlockedExtensionPrefix[] = "[BLOCKED]";
74 74
75 // The GUID of the registry settings group policy extension. 75 // The GUID of the registry settings group policy extension.
76 GUID kRegistrySettingsCSEGUID = REGISTRY_EXTENSION_GUID; 76 GUID kRegistrySettingsCSEGUID = REGISTRY_EXTENSION_GUID;
77 77
78 // The list of possible errors that can occur while collecting information about 78 // The list of possible errors that can occur while collecting information about
79 // the current enterprise environment. 79 // the current enterprise environment.
80 // This enum is used to define the buckets for an enumerated UMA histogram.
81 // Hence,
82 // (a) existing enumerated constants should never be deleted or reordered, and
83 // (b) new constants should only be appended at the end of the enumeration.
80 enum DomainCheckErrors { 84 enum DomainCheckErrors {
81 DOMAIN_CHECK_ERROR_GET_JOIN_INFO = 0, 85 DOMAIN_CHECK_ERROR_GET_JOIN_INFO = 0,
82 DOMAIN_CHECK_ERROR_DS_BIND, 86 DOMAIN_CHECK_ERROR_DS_BIND = 1,
83 DOMAIN_CHECK_ERROR_LAST, 87 DOMAIN_CHECK_ERROR_SIZE, // Not a DomainCheckError. Must be last.
84 }; 88 };
85 89
86 // If the LBS extension is found and contains a schema in the registry then this 90 // If the LBS extension is found and contains a schema in the registry then this
87 // function is used to patch it, and make it compliant. The fix is to 91 // function is used to patch it, and make it compliant. The fix is to
88 // add an "items" attribute to lists that don't declare it. 92 // add an "items" attribute to lists that don't declare it.
89 std::string PatchSchema(const std::string& schema) { 93 std::string PatchSchema(const std::string& schema) {
90 base::JSONParserOptions options = base::JSON_PARSE_RFC; 94 base::JSONParserOptions options = base::JSON_PARSE_RFC;
91 scoped_ptr<base::Value> json(base::JSONReader::Read(schema, options)); 95 scoped_ptr<base::Value> json(base::JSONReader::Read(schema, options));
92 base::DictionaryValue* dict = NULL; 96 base::DictionaryValue* dict = NULL;
93 base::DictionaryValue* properties = NULL; 97 base::DictionaryValue* properties = NULL;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.OSType", 301 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.OSType",
298 base::win::OSInfo::GetInstance()->version_type(), 302 base::win::OSInfo::GetInstance()->version_type(),
299 base::win::SUITE_LAST); 303 base::win::SUITE_LAST);
300 304
301 // Get the computer's domain status. 305 // Get the computer's domain status.
302 LPWSTR domain; 306 LPWSTR domain;
303 NETSETUP_JOIN_STATUS join_status; 307 NETSETUP_JOIN_STATUS join_status;
304 if (NERR_Success != ::NetGetJoinInformation(NULL, &domain, &join_status)) { 308 if (NERR_Success != ::NetGetJoinInformation(NULL, &domain, &join_status)) {
305 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.DomainCheckFailed", 309 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.DomainCheckFailed",
306 DOMAIN_CHECK_ERROR_GET_JOIN_INFO, 310 DOMAIN_CHECK_ERROR_GET_JOIN_INFO,
307 DOMAIN_CHECK_ERROR_LAST); 311 DOMAIN_CHECK_ERROR_SIZE);
308 return; 312 return;
309 } 313 }
310 ::NetApiBufferFree(domain); 314 ::NetApiBufferFree(domain);
311 315
312 bool in_domain = join_status == NetSetupDomainName; 316 bool in_domain = join_status == NetSetupDomainName;
313 UMA_HISTOGRAM_BOOLEAN("EnterpriseCheck.InDomain", in_domain); 317 UMA_HISTOGRAM_BOOLEAN("EnterpriseCheck.InDomain", in_domain);
314 if (in_domain) { 318 if (in_domain) {
315 // This check will tell us how often are domain computers actually 319 // This check will tell us how often are domain computers actually
316 // connected to the enterprise network while Chrome is running. 320 // connected to the enterprise network while Chrome is running.
317 HANDLE server_bind; 321 HANDLE server_bind;
318 if (ERROR_SUCCESS == ::DsBind(NULL, NULL, &server_bind)) { 322 if (ERROR_SUCCESS == ::DsBind(NULL, NULL, &server_bind)) {
319 UMA_HISTOGRAM_COUNTS("EnterpriseCheck.DomainBindSucceeded", 1); 323 UMA_HISTOGRAM_COUNTS("EnterpriseCheck.DomainBindSucceeded", 1);
320 ::DsUnBind(&server_bind); 324 ::DsUnBind(&server_bind);
321 } else { 325 } else {
322 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.DomainCheckFailed", 326 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.DomainCheckFailed",
323 DOMAIN_CHECK_ERROR_DS_BIND, 327 DOMAIN_CHECK_ERROR_DS_BIND,
324 DOMAIN_CHECK_ERROR_LAST); 328 DOMAIN_CHECK_ERROR_SIZE);
325 } 329 }
326 } 330 }
327 } 331 }
328 332
329 } // namespace 333 } // namespace
330 334
331 const base::FilePath::CharType PolicyLoaderWin::kPRegFileName[] = 335 const base::FilePath::CharType PolicyLoaderWin::kPRegFileName[] =
332 FILE_PATH_LITERAL("Registry.pol"); 336 FILE_PATH_LITERAL("Registry.pol");
333 337
334 PolicyLoaderWin::PolicyLoaderWin( 338 PolicyLoaderWin::PolicyLoaderWin(
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 650
647 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) { 651 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) {
648 DCHECK(object == user_policy_changed_event_.handle() || 652 DCHECK(object == user_policy_changed_event_.handle() ||
649 object == machine_policy_changed_event_.handle()) 653 object == machine_policy_changed_event_.handle())
650 << "unexpected object signaled policy reload, obj = " 654 << "unexpected object signaled policy reload, obj = "
651 << std::showbase << std::hex << object; 655 << std::showbase << std::hex << object;
652 Reload(false); 656 Reload(false);
653 } 657 }
654 658
655 } // namespace policy 659 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_load_status.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698