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/extensions/api/virtual_keyboard_private/chrome_virtual_
keyboard_delegate.h" | 5 #include "chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_
keyboard_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
| 9 #include "ash/shell.h" |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
11 #include "base/metrics/user_metrics_action.h" | 12 #include "base/metrics/user_metrics_action.h" |
12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
13 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 14 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
14 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 15 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/browser/ui/chrome_pages.h" | 17 #include "chrome/browser/ui/chrome_pages.h" |
17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
18 #include "components/user_manager/user_manager.h" | 19 #include "components/user_manager/user_manager.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 52 |
52 } // namespace | 53 } // namespace |
53 | 54 |
54 namespace extensions { | 55 namespace extensions { |
55 | 56 |
56 bool ChromeVirtualKeyboardDelegate::GetKeyboardConfig( | 57 bool ChromeVirtualKeyboardDelegate::GetKeyboardConfig( |
57 base::DictionaryValue* results) { | 58 base::DictionaryValue* results) { |
58 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 59 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
59 results->SetString("layout", keyboard::GetKeyboardLayout()); | 60 results->SetString("layout", keyboard::GetKeyboardLayout()); |
60 results->SetBoolean("a11ymode", keyboard::GetAccessibilityKeyboardEnabled()); | 61 results->SetBoolean("a11ymode", keyboard::GetAccessibilityKeyboardEnabled()); |
| 62 results->SetBoolean("hotrodmode", keyboard::GetHotrodKeyboardEnabled()); |
61 scoped_ptr<base::ListValue> features(new base::ListValue()); | 63 scoped_ptr<base::ListValue> features(new base::ListValue()); |
62 features->AppendString(GenerateFeatureFlag( | 64 features->AppendString(GenerateFeatureFlag( |
63 "floatingvirtualkeyboard", keyboard::IsFloatingVirtualKeyboardEnabled())); | 65 "floatingvirtualkeyboard", keyboard::IsFloatingVirtualKeyboardEnabled())); |
64 features->AppendString( | 66 features->AppendString( |
65 GenerateFeatureFlag("gesturetyping", keyboard::IsGestureTypingEnabled())); | 67 GenerateFeatureFlag("gesturetyping", keyboard::IsGestureTypingEnabled())); |
66 features->AppendString(GenerateFeatureFlag( | 68 features->AppendString(GenerateFeatureFlag( |
67 "gestureediting", keyboard::IsGestureEditingEnabled())); | 69 "gestureediting", keyboard::IsGestureEditingEnabled())); |
68 features->AppendString( | 70 features->AppendString( |
69 GenerateFeatureFlag("voiceinput", keyboard::IsVoiceInputEnabled())); | 71 GenerateFeatureFlag("voiceinput", keyboard::IsVoiceInputEnabled())); |
70 features->AppendString(GenerateFeatureFlag("experimental", | 72 features->AppendString(GenerateFeatureFlag("experimental", |
(...skipping 24 matching lines...) Expand all Loading... |
95 return keyboard::InsertText(text); | 97 return keyboard::InsertText(text); |
96 } | 98 } |
97 | 99 |
98 bool ChromeVirtualKeyboardDelegate::OnKeyboardLoaded() { | 100 bool ChromeVirtualKeyboardDelegate::OnKeyboardLoaded() { |
99 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 101 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
100 keyboard::MarkKeyboardLoadFinished(); | 102 keyboard::MarkKeyboardLoadFinished(); |
101 base::UserMetricsAction("VirtualKeyboardLoaded"); | 103 base::UserMetricsAction("VirtualKeyboardLoaded"); |
102 return true; | 104 return true; |
103 } | 105 } |
104 | 106 |
| 107 void ChromeVirtualKeyboardDelegate::SetHotrodKeyboard(bool enable) { |
| 108 if (keyboard::GetHotrodKeyboardEnabled() == enable) |
| 109 return; |
| 110 |
| 111 keyboard::SetHotrodKeyboardEnabled(enable); |
| 112 // This reloads virtual keyboard even if it exists. This ensures virtual |
| 113 // keyboard gets the correct state of the hotrod keyboard through |
| 114 // chrome.virtualKeyboardPrivate.getKeyboardConfig. |
| 115 if (enable && keyboard::IsKeyboardEnabled()) |
| 116 ash::Shell::GetInstance()->CreateKeyboard(); |
| 117 } |
| 118 |
105 bool ChromeVirtualKeyboardDelegate::LockKeyboard(bool state) { | 119 bool ChromeVirtualKeyboardDelegate::LockKeyboard(bool state) { |
106 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 120 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
107 keyboard::KeyboardController* controller = | 121 keyboard::KeyboardController* controller = |
108 keyboard::KeyboardController::GetInstance(); | 122 keyboard::KeyboardController::GetInstance(); |
109 if (!controller) | 123 if (!controller) |
110 return false; | 124 return false; |
111 | 125 |
112 keyboard::KeyboardController::GetInstance()->set_lock_keyboard(state); | 126 keyboard::KeyboardController::GetInstance()->set_lock_keyboard(state); |
113 return true; | 127 return true; |
114 } | 128 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 163 } |
150 | 164 |
151 bool ChromeVirtualKeyboardDelegate::IsLanguageSettingsEnabled() { | 165 bool ChromeVirtualKeyboardDelegate::IsLanguageSettingsEnabled() { |
152 return (user_manager::UserManager::Get()->IsUserLoggedIn() && | 166 return (user_manager::UserManager::Get()->IsUserLoggedIn() && |
153 !chromeos::UserAddingScreen::Get()->IsRunning() && | 167 !chromeos::UserAddingScreen::Get()->IsRunning() && |
154 !(chromeos::ScreenLocker::default_screen_locker() && | 168 !(chromeos::ScreenLocker::default_screen_locker() && |
155 chromeos::ScreenLocker::default_screen_locker()->locked())); | 169 chromeos::ScreenLocker::default_screen_locker()->locked())); |
156 } | 170 } |
157 | 171 |
158 } // namespace extensions | 172 } // namespace extensions |
OLD | NEW |