OLD | NEW |
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 "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" | 5 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace chromeos { | 21 namespace chromeos { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Maximum time to wait before forcing a decision. | 25 // Maximum time to wait before forcing a decision. |
26 const int kSafeguardTimeoutSeconds = 30; | 26 const int kSafeguardTimeoutSeconds = 30; |
27 | 27 |
28 // Returns the int value of the |switch_name| argument, clamped to the [0, 62] | 28 // Returns the int value of the |switch_name| argument, clamped to the [0, 62] |
29 // interval. Returns 0 if the argument doesn't exist or isn't an int value. | 29 // interval. Returns 0 if the argument doesn't exist or isn't an int value. |
30 int GetSanitizedArg(const std::string& switch_name) { | 30 int GetSanitizedArg(const std::string& switch_name) { |
31 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 31 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
32 if (!command_line->HasSwitch(switch_name)) | 32 if (!command_line->HasSwitch(switch_name)) |
33 return 0; | 33 return 0; |
34 std::string value = command_line->GetSwitchValueASCII(switch_name); | 34 std::string value = command_line->GetSwitchValueASCII(switch_name); |
35 int int_value; | 35 int int_value; |
36 if (!base::StringToInt(value, &int_value)) { | 36 if (!base::StringToInt(value, &int_value)) { |
37 LOG(ERROR) << "Switch \"" << switch_name << "\" is not a valid int. " | 37 LOG(ERROR) << "Switch \"" << switch_name << "\" is not a valid int. " |
38 << "Defaulting to 0."; | 38 << "Defaulting to 0."; |
39 return 0; | 39 return 0; |
40 } | 40 } |
41 if (int_value < 0) { | 41 if (int_value < 0) { |
(...skipping 23 matching lines...) Expand all Loading... |
65 } | 65 } |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 const char AutoEnrollmentController::kForcedReEnrollmentAlways[] = "always"; | 69 const char AutoEnrollmentController::kForcedReEnrollmentAlways[] = "always"; |
70 const char AutoEnrollmentController::kForcedReEnrollmentNever[] = "never"; | 70 const char AutoEnrollmentController::kForcedReEnrollmentNever[] = "never"; |
71 const char AutoEnrollmentController::kForcedReEnrollmentOfficialBuild[] = | 71 const char AutoEnrollmentController::kForcedReEnrollmentOfficialBuild[] = |
72 "official"; | 72 "official"; |
73 | 73 |
74 AutoEnrollmentController::Mode AutoEnrollmentController::GetMode() { | 74 AutoEnrollmentController::Mode AutoEnrollmentController::GetMode() { |
75 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 75 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
76 | 76 |
77 std::string command_line_mode = command_line->GetSwitchValueASCII( | 77 std::string command_line_mode = command_line->GetSwitchValueASCII( |
78 switches::kEnterpriseEnableForcedReEnrollment); | 78 switches::kEnterpriseEnableForcedReEnrollment); |
79 if (command_line_mode == kForcedReEnrollmentAlways) { | 79 if (command_line_mode == kForcedReEnrollmentAlways) { |
80 return MODE_FORCED_RE_ENROLLMENT; | 80 return MODE_FORCED_RE_ENROLLMENT; |
81 } else if (command_line_mode.empty() || | 81 } else if (command_line_mode.empty() || |
82 command_line_mode == kForcedReEnrollmentOfficialBuild) { | 82 command_line_mode == kForcedReEnrollmentOfficialBuild) { |
83 #if defined(OFFICIAL_BUILD) | 83 #if defined(OFFICIAL_BUILD) |
84 std::string firmware_type; | 84 std::string firmware_type; |
85 const bool non_chrome_firmware = | 85 const bool non_chrome_firmware = |
(...skipping 25 matching lines...) Expand all Loading... |
111 // accepted, or right after a reboot if the EULA has already been accepted. | 111 // accepted, or right after a reboot if the EULA has already been accepted. |
112 | 112 |
113 // Do not communicate auto-enrollment data to the server if | 113 // Do not communicate auto-enrollment data to the server if |
114 // 1. we are running telemetry tests. | 114 // 1. we are running telemetry tests. |
115 // 2. modulus configuration is not present. | 115 // 2. modulus configuration is not present. |
116 // 3. Auto-enrollment is disabled via the command line. | 116 // 3. Auto-enrollment is disabled via the command line. |
117 // 4. This is the first boot ever, so re-enrollment checks are pointless. This | 117 // 4. This is the first boot ever, so re-enrollment checks are pointless. This |
118 // also enables factories to start full guest sessions for testing, see | 118 // also enables factories to start full guest sessions for testing, see |
119 // http://crbug.com/397354 for more context. | 119 // http://crbug.com/397354 for more context. |
120 | 120 |
121 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 121 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
122 if (command_line->HasSwitch(chromeos::switches::kDisableGaiaServices) || | 122 if (command_line->HasSwitch(chromeos::switches::kDisableGaiaServices) || |
123 (!command_line->HasSwitch( | 123 (!command_line->HasSwitch( |
124 chromeos::switches::kEnterpriseEnrollmentInitialModulus) && | 124 chromeos::switches::kEnterpriseEnrollmentInitialModulus) && |
125 !command_line->HasSwitch( | 125 !command_line->HasSwitch( |
126 chromeos::switches::kEnterpriseEnrollmentModulusLimit)) || | 126 chromeos::switches::kEnterpriseEnrollmentModulusLimit)) || |
127 GetMode() == MODE_NONE || | 127 GetMode() == MODE_NONE || |
128 IsFirstDeviceSetup()) { | 128 IsFirstDeviceSetup()) { |
129 VLOG(1) << "Auto-enrollment disabled."; | 129 VLOG(1) << "Auto-enrollment disabled."; |
130 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); | 130 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); |
131 return; | 131 return; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // open. | 264 // open. |
265 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit."; | 265 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit."; |
266 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR); | 266 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR); |
267 } | 267 } |
268 | 268 |
269 // Reset state. | 269 // Reset state. |
270 Cancel(); | 270 Cancel(); |
271 } | 271 } |
272 | 272 |
273 } // namespace chromeos | 273 } // namespace chromeos |
OLD | NEW |