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

Side by Side Diff: ash/virtual_keyboard_controller.cc

Issue 703703004: Fix infinite loop causing iterator to go out of bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Const Created 6 years, 1 month 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 | « no previous file | ash/virtual_keyboard_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/virtual_keyboard_controller.h" 5 #include "ash/virtual_keyboard_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 10 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 void VirtualKeyboardController::UpdateDevices() { 65 void VirtualKeyboardController::UpdateDevices() {
66 ui::DeviceDataManager* device_data_manager = 66 ui::DeviceDataManager* device_data_manager =
67 ui::DeviceDataManager::GetInstance(); 67 ui::DeviceDataManager::GetInstance();
68 68
69 // Checks for touchscreens. 69 // Checks for touchscreens.
70 has_touchscreen_ = device_data_manager->touchscreen_devices().size() > 0; 70 has_touchscreen_ = device_data_manager->touchscreen_devices().size() > 0;
71 71
72 // Checks for keyboards. 72 // Checks for keyboards.
73 has_external_keyboard_ = false; 73 has_external_keyboard_ = false;
74 has_internal_keyboard_ = false; 74 has_internal_keyboard_ = false;
75 std::vector<ui::KeyboardDevice> keyboards = 75 for (const ui::KeyboardDevice& device :
76 device_data_manager->keyboard_devices(); 76 device_data_manager->keyboard_devices()) {
77 for (auto iter = keyboards.begin(); 77 if (has_internal_keyboard_ && has_external_keyboard_)
78 iter != keyboards.end() || 78 break;
79 (has_internal_keyboard_ && has_external_keyboard_); 79 ui::InputDeviceType type = device.type;
80 ++iter) {
81 ui::InputDeviceType type = (*iter).type;
82 if (type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) 80 if (type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL)
83 has_internal_keyboard_ = true; 81 has_internal_keyboard_ = true;
84 if (type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL) 82 if (type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)
85 has_external_keyboard_ = true; 83 has_external_keyboard_ = true;
86 } 84 }
87 // Update keyboard state. 85 // Update keyboard state.
88 UpdateKeyboardEnabled(); 86 UpdateKeyboardEnabled();
89 } 87 }
90 88
91 void VirtualKeyboardController::UpdateKeyboardEnabled() { 89 void VirtualKeyboardController::UpdateKeyboardEnabled() {
(...skipping 17 matching lines...) Expand all
109 keyboard::SetTouchKeyboardEnabled(enabled); 107 keyboard::SetTouchKeyboardEnabled(enabled);
110 if (enabled) { 108 if (enabled) {
111 Shell::GetInstance()->CreateKeyboard(); 109 Shell::GetInstance()->CreateKeyboard();
112 } else { 110 } else {
113 if (!keyboard::IsKeyboardEnabled()) 111 if (!keyboard::IsKeyboardEnabled())
114 Shell::GetInstance()->DeactivateKeyboard(); 112 Shell::GetInstance()->DeactivateKeyboard();
115 } 113 }
116 } 114 }
117 115
118 } // namespace ash 116 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/virtual_keyboard_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698