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

Side by Side Diff: chrome/browser/chromeos/login/screens/controller_pairing_screen.cc

Issue 1715683002: chrome: Use base's ContainsValue helper function instead of std::find (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated as per latest code Created 4 years, 8 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 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
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))
156 devices.end()) {
157 selected_device.clear(); 157 selected_device.clear();
158 }
159 if (devices.empty()) { 158 if (devices.empty()) {
160 device_preselected_ = false; 159 device_preselected_ = false;
161 } else if (!device_preselected_) { 160 } else if (!device_preselected_) {
162 selected_device = devices.front(); 161 selected_device = devices.front();
163 device_preselected_ = true; 162 device_preselected_ = true;
164 } 163 }
165 context_.SetString(kContextKeySelectedDevice, selected_device); 164 context_.SetString(kContextKeySelectedDevice, selected_device);
166 context_.SetBoolean(kContextKeyControlsDisabled, selected_device.empty()); 165 context_.SetBoolean(kContextKeyControlsDisabled, selected_device.empty());
167 CommitContextChanges(); 166 CommitContextChanges();
168 } 167 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 ++key) { 215 ++key) {
217 if (*key == kContextKeySelectedDevice) { 216 if (*key == kContextKeySelectedDevice) {
218 context_.SetBoolean(kContextKeyControlsDisabled, 217 context_.SetBoolean(kContextKeyControlsDisabled,
219 context_.GetString(*key).empty()); 218 context_.GetString(*key).empty());
220 CommitContextChanges(); 219 CommitContextChanges();
221 } 220 }
222 } 221 }
223 } 222 }
224 223
225 } // namespace chromeos 224 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/apps/app_window_registry_util.cc ('k') | chrome/browser/chromeos/platform_keys/platform_keys_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698