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/screens/controller_pairing_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/controller_pairing_screen.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/stl_util.h" | |
8 #include "base/values.h" | 9 #include "base/values.h" |
9 #include "chrome/browser/chromeos/login/wizard_controller.h" | 10 #include "chrome/browser/chromeos/login/wizard_controller.h" |
10 #include "google_apis/gaia/gaia_auth_util.h" | 11 #include "google_apis/gaia/gaia_auth_util.h" |
11 | 12 |
12 using namespace chromeos::controller_pairing; | 13 using namespace chromeos::controller_pairing; |
13 using namespace pairing_chromeos; | 14 using namespace pairing_chromeos; |
14 | 15 |
15 namespace chromeos { | 16 namespace chromeos { |
16 | 17 |
17 ControllerPairingScreen::ControllerPairingScreen( | 18 ControllerPairingScreen::ControllerPairingScreen( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 if (!ExpectStageIs(ControllerPairingController::STAGE_DEVICES_DISCOVERY)) | 146 if (!ExpectStageIs(ControllerPairingController::STAGE_DEVICES_DISCOVERY)) |
146 return; | 147 return; |
147 ControllerPairingController::DeviceIdList devices = | 148 ControllerPairingController::DeviceIdList devices = |
148 shark_controller_->GetDiscoveredDevices(); | 149 shark_controller_->GetDiscoveredDevices(); |
149 std::sort(devices.begin(), devices.end()); | 150 std::sort(devices.begin(), devices.end()); |
150 context_.SetStringList(kContextKeyDevices, devices); | 151 context_.SetStringList(kContextKeyDevices, devices); |
151 context_.SetString( | 152 context_.SetString( |
152 kContextKeyPage, | 153 kContextKeyPage, |
153 devices.empty() ? kPageDevicesDiscovery : kPageDeviceSelect); | 154 devices.empty() ? kPageDevicesDiscovery : kPageDeviceSelect); |
154 std::string selected_device = context_.GetString(kContextKeySelectedDevice); | 155 std::string selected_device = context_.GetString(kContextKeySelectedDevice); |
155 if (std::find(devices.begin(), devices.end(), selected_device) == | 156 if (!ContainsValue(devices, selected_device)) { |
sky
2016/03/02 17:19:34
nit: no {}
chakshu
2016/03/07 08:10:46
Done.
| |
156 devices.end()) { | |
157 selected_device.clear(); | 157 selected_device.clear(); |
158 } | 158 } |
159 if (devices.empty()) { | 159 if (devices.empty()) { |
160 device_preselected_ = false; | 160 device_preselected_ = false; |
161 } else if (!device_preselected_) { | 161 } else if (!device_preselected_) { |
162 selected_device = devices.front(); | 162 selected_device = devices.front(); |
163 device_preselected_ = true; | 163 device_preselected_ = true; |
164 } | 164 } |
165 context_.SetString(kContextKeySelectedDevice, selected_device); | 165 context_.SetString(kContextKeySelectedDevice, selected_device); |
166 context_.SetBoolean(kContextKeyControlsDisabled, selected_device.empty()); | 166 context_.SetBoolean(kContextKeyControlsDisabled, selected_device.empty()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 ++key) { | 216 ++key) { |
217 if (*key == kContextKeySelectedDevice) { | 217 if (*key == kContextKeySelectedDevice) { |
218 context_.SetBoolean(kContextKeyControlsDisabled, | 218 context_.SetBoolean(kContextKeyControlsDisabled, |
219 context_.GetString(*key).empty()); | 219 context_.GetString(*key).empty()); |
220 CommitContextChanges(); | 220 CommitContextChanges(); |
221 } | 221 } |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 } // namespace chromeos | 225 } // namespace chromeos |
OLD | NEW |