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

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

Issue 2056033002: Clean Up Remaining Domain Check Call and netapi32.lib Usage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@isos
Patch Set: 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
« no previous file with comments | « components/policy/core/common/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
9 #include <ntdsapi.h> // For Ds[Un]Bind 8 #include <ntdsapi.h> // For Ds[Un]Bind
10 #include <rpc.h> // For struct GUID 9 #include <rpc.h> // For struct GUID
11 #include <shlwapi.h> // For PathIsUNC() 10 #include <shlwapi.h> // For PathIsUNC()
12 #include <stddef.h> 11 #include <stddef.h>
13 #include <userenv.h> // For GPO functions 12 #include <userenv.h> // For GPO functions
14 13
15 #include <memory> 14 #include <memory>
16 #include <string> 15 #include <string>
17 #include <vector> 16 #include <vector>
18 17
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 GUID kRegistrySettingsCSEGUID = REGISTRY_EXTENSION_GUID; 87 GUID kRegistrySettingsCSEGUID = REGISTRY_EXTENSION_GUID;
89 #pragma warning(pop) 88 #pragma warning(pop)
90 89
91 // The list of possible errors that can occur while collecting information about 90 // The list of possible errors that can occur while collecting information about
92 // the current enterprise environment. 91 // the current enterprise environment.
93 // This enum is used to define the buckets for an enumerated UMA histogram. 92 // This enum is used to define the buckets for an enumerated UMA histogram.
94 // Hence, 93 // Hence,
95 // (a) existing enumerated constants should never be deleted or reordered, and 94 // (a) existing enumerated constants should never be deleted or reordered, and
96 // (b) new constants should only be appended at the end of the enumeration. 95 // (b) new constants should only be appended at the end of the enumeration.
97 enum DomainCheckErrors { 96 enum DomainCheckErrors {
98 DOMAIN_CHECK_ERROR_GET_JOIN_INFO = 0, 97 // The check error below is no longer possible.
98 DEPRECATED_DOMAIN_CHECK_ERROR_GET_JOIN_INFO = 0,
99 DOMAIN_CHECK_ERROR_DS_BIND = 1, 99 DOMAIN_CHECK_ERROR_DS_BIND = 1,
100 DOMAIN_CHECK_ERROR_SIZE, // Not a DomainCheckError. Must be last. 100 DOMAIN_CHECK_ERROR_SIZE, // Not a DomainCheckError. Must be last.
101 }; 101 };
102 102
103 // If the LBS extension is found and contains a schema in the registry then this 103 // If the LBS extension is found and contains a schema in the registry then this
104 // function is used to patch it, and make it compliant. The fix is to 104 // function is used to patch it, and make it compliant. The fix is to
105 // add an "items" attribute to lists that don't declare it. 105 // add an "items" attribute to lists that don't declare it.
106 std::string PatchSchema(const std::string& schema) { 106 std::string PatchSchema(const std::string& schema) {
107 base::JSONParserOptions options = base::JSON_PARSE_RFC; 107 base::JSONParserOptions options = base::JSON_PARSE_RFC;
108 std::unique_ptr<base::Value> json = base::JSONReader::Read(schema, options); 108 std::unique_ptr<base::Value> json = base::JSONReader::Read(schema, options);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 327 }
328 328
329 // Collects stats about the enterprise environment that can be used to decide 329 // Collects stats about the enterprise environment that can be used to decide
330 // how to parse the existing policy information. 330 // how to parse the existing policy information.
331 void CollectEnterpriseUMAs() { 331 void CollectEnterpriseUMAs() {
332 // Collect statistics about the windows suite. 332 // Collect statistics about the windows suite.
333 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.OSType", 333 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.OSType",
334 base::win::OSInfo::GetInstance()->version_type(), 334 base::win::OSInfo::GetInstance()->version_type(),
335 base::win::SUITE_LAST); 335 base::win::SUITE_LAST);
336 336
337 // Get the computer's domain status. 337 bool in_domain = base::win::IsEnrolledToDomain();
338 LPWSTR domain;
339 NETSETUP_JOIN_STATUS join_status;
340 if (NERR_Success != ::NetGetJoinInformation(NULL, &domain, &join_status)) {
341 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.DomainCheckFailed",
342 DOMAIN_CHECK_ERROR_GET_JOIN_INFO,
343 DOMAIN_CHECK_ERROR_SIZE);
344 return;
345 }
346 ::NetApiBufferFree(domain);
347
348 bool in_domain = join_status == NetSetupDomainName;
349 UMA_HISTOGRAM_BOOLEAN("EnterpriseCheck.InDomain", in_domain); 338 UMA_HISTOGRAM_BOOLEAN("EnterpriseCheck.InDomain", in_domain);
350 if (in_domain) { 339 if (in_domain) {
351 // This check will tell us how often are domain computers actually 340 // This check will tell us how often are domain computers actually
352 // connected to the enterprise network while Chrome is running. 341 // connected to the enterprise network while Chrome is running.
353 HANDLE server_bind; 342 HANDLE server_bind;
354 if (ERROR_SUCCESS == ::DsBind(NULL, NULL, &server_bind)) { 343 if (ERROR_SUCCESS == ::DsBind(NULL, NULL, &server_bind)) {
355 UMA_HISTOGRAM_COUNTS("EnterpriseCheck.DomainBindSucceeded", 1); 344 UMA_HISTOGRAM_COUNTS("EnterpriseCheck.DomainBindSucceeded", 1);
356 ::DsUnBind(&server_bind); 345 ::DsUnBind(&server_bind);
357 } else { 346 } else {
358 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.DomainCheckFailed", 347 UMA_HISTOGRAM_ENUMERATION("EnterpriseCheck.DomainCheckFailed",
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 674
686 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) { 675 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) {
687 DCHECK(object == user_policy_changed_event_.handle() || 676 DCHECK(object == user_policy_changed_event_.handle() ||
688 object == machine_policy_changed_event_.handle()) 677 object == machine_policy_changed_event_.handle())
689 << "unexpected object signaled policy reload, obj = " 678 << "unexpected object signaled policy reload, obj = "
690 << std::showbase << std::hex << object; 679 << std::showbase << std::hex << object;
691 Reload(false); 680 Reload(false);
692 } 681 }
693 682
694 } // namespace policy 683 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698