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

Side by Side Diff: chrome/browser/chromeos/policy/auto_enrollment_client.cc

Issue 14820030: Move Chrome OS switches to chromeos/chromeos_switches.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/policy/auto_enrollment_client.h" 5 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/metrics/sparse_histogram.h" 14 #include "base/metrics/sparse_histogram.h"
15 #include "base/prefs/pref_registry_simple.h" 15 #include "base/prefs/pref_registry_simple.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 19 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
20 #include "chrome/browser/policy/browser_policy_connector.h" 20 #include "chrome/browser/policy/browser_policy_connector.h"
21 #include "chrome/browser/policy/cloud/device_management_service.h" 21 #include "chrome/browser/policy/cloud/device_management_service.h"
22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "chromeos/chromeos_switches.h"
24 #include "crypto/sha2.h" 24 #include "crypto/sha2.h"
25 25
26 namespace em = enterprise_management; 26 namespace em = enterprise_management;
27 27
28 namespace { 28 namespace {
29 29
30 // UMA histogram names. 30 // UMA histogram names.
31 const char kUMAProtocolTime[] = "Enterprise.AutoEnrollmentProtocolTime"; 31 const char kUMAProtocolTime[] = "Enterprise.AutoEnrollmentProtocolTime";
32 const char kUMAExtraTime[] = "Enterprise.AutoEnrollmentExtraTime"; 32 const char kUMAExtraTime[] = "Enterprise.AutoEnrollmentExtraTime";
33 const char kUMARequestStatus[] = "Enterprise.AutoEnrollmentRequestStatus"; 33 const char kUMARequestStatus[] = "Enterprise.AutoEnrollmentRequestStatus";
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 // static 103 // static
104 void AutoEnrollmentClient::RegisterPrefs(PrefRegistrySimple* registry) { 104 void AutoEnrollmentClient::RegisterPrefs(PrefRegistrySimple* registry) {
105 registry->RegisterBooleanPref(prefs::kShouldAutoEnroll, false); 105 registry->RegisterBooleanPref(prefs::kShouldAutoEnroll, false);
106 registry->RegisterIntegerPref(prefs::kAutoEnrollmentPowerLimit, -1); 106 registry->RegisterIntegerPref(prefs::kAutoEnrollmentPowerLimit, -1);
107 } 107 }
108 108
109 // static 109 // static
110 bool AutoEnrollmentClient::IsDisabled() { 110 bool AutoEnrollmentClient::IsDisabled() {
111 CommandLine* command_line = CommandLine::ForCurrentProcess(); 111 CommandLine* command_line = CommandLine::ForCurrentProcess();
112 return 112 return !command_line->HasSwitch(
113 !command_line->HasSwitch(switches::kEnterpriseEnrollmentInitialModulus) && 113 chromeos::switches::kEnterpriseEnrollmentInitialModulus) &&
114 !command_line->HasSwitch(switches::kEnterpriseEnrollmentModulusLimit); 114 !command_line->HasSwitch(
115 chromeos::switches::kEnterpriseEnrollmentModulusLimit);
115 } 116 }
116 117
117 // static 118 // static
118 AutoEnrollmentClient* AutoEnrollmentClient::Create( 119 AutoEnrollmentClient* AutoEnrollmentClient::Create(
119 const base::Closure& completion_callback) { 120 const base::Closure& completion_callback) {
120 // The client won't do anything if |service| is NULL. 121 // The client won't do anything if |service| is NULL.
121 DeviceManagementService* service = NULL; 122 DeviceManagementService* service = NULL;
122 if (IsDisabled()) { 123 if (IsDisabled()) {
123 VLOG(1) << "Auto-enrollment is disabled"; 124 VLOG(1) << "Auto-enrollment is disabled";
124 } else { 125 } else {
125 std::string url = BrowserPolicyConnector::GetDeviceManagementUrl(); 126 std::string url = BrowserPolicyConnector::GetDeviceManagementUrl();
126 if (!url.empty()) { 127 if (!url.empty()) {
127 service = new DeviceManagementService(url); 128 service = new DeviceManagementService(url);
128 service->ScheduleInitialization(0); 129 service->ScheduleInitialization(0);
129 } 130 }
130 } 131 }
131 132
132 int power_initial = GetSanitizedArg( 133 int power_initial = GetSanitizedArg(
133 switches::kEnterpriseEnrollmentInitialModulus); 134 chromeos::switches::kEnterpriseEnrollmentInitialModulus);
134 int power_limit = GetSanitizedArg( 135 int power_limit = GetSanitizedArg(
135 switches::kEnterpriseEnrollmentModulusLimit); 136 chromeos::switches::kEnterpriseEnrollmentModulusLimit);
136 if (power_initial > power_limit) { 137 if (power_initial > power_limit) {
137 LOG(ERROR) << "Initial auto-enrollment modulus is larger than the limit, " 138 LOG(ERROR) << "Initial auto-enrollment modulus is larger than the limit, "
138 << "clamping to the limit."; 139 << "clamping to the limit.";
139 power_initial = power_limit; 140 power_initial = power_limit;
140 } 141 }
141 142
142 return new AutoEnrollmentClient( 143 return new AutoEnrollmentClient(
143 completion_callback, 144 completion_callback,
144 service, 145 service,
145 g_browser_process->local_state(), 146 g_browser_process->local_state(),
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // This samples |kZero| when there was no need for extra time, so that we can 340 // This samples |kZero| when there was no need for extra time, so that we can
340 // measure the ratio of users that succeeded without needing a delay to the 341 // measure the ratio of users that succeeded without needing a delay to the
341 // total users going through OOBE. 342 // total users going through OOBE.
342 UMA_HISTOGRAM_CUSTOM_TIMES(kUMAExtraTime, delta, kMin, kMax, kBuckets); 343 UMA_HISTOGRAM_CUSTOM_TIMES(kUMAExtraTime, delta, kMin, kMax, kBuckets);
343 344
344 if (!completion_callback_.is_null()) 345 if (!completion_callback_.is_null())
345 completion_callback_.Run(); 346 completion_callback_.Run();
346 } 347 }
347 348
348 } // namespace policy 349 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/net/network_portal_detector.cc ('k') | chrome/browser/chromeos/preferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698