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

Side by Side Diff: chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc

Issue 1315233006: Add chrome.virtualKeyboardPrivate.setHotrodKeyboard api (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 3 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/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 "ash/shell.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 } // namespace 67 } // namespace
68 68
69 namespace extensions { 69 namespace extensions {
70 70
71 bool ChromeVirtualKeyboardDelegate::GetKeyboardConfig( 71 bool ChromeVirtualKeyboardDelegate::GetKeyboardConfig(
72 base::DictionaryValue* results) { 72 base::DictionaryValue* results) {
73 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 73 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
74 results->SetString("layout", keyboard::GetKeyboardLayout()); 74 results->SetString("layout", keyboard::GetKeyboardLayout());
75 // TODO(bshe): Consolidate a11y, hotrod and normal mode into a mode enum. See
76 // crbug.com/529474.
75 results->SetBoolean("a11ymode", keyboard::GetAccessibilityKeyboardEnabled()); 77 results->SetBoolean("a11ymode", keyboard::GetAccessibilityKeyboardEnabled());
78 results->SetBoolean("hotrodmode", keyboard::GetHotrodKeyboardEnabled());
76 scoped_ptr<base::ListValue> features(new base::ListValue()); 79 scoped_ptr<base::ListValue> features(new base::ListValue());
77 features->AppendString(GenerateFeatureFlag( 80 features->AppendString(GenerateFeatureFlag(
78 "floatingvirtualkeyboard", keyboard::IsFloatingVirtualKeyboardEnabled())); 81 "floatingvirtualkeyboard", keyboard::IsFloatingVirtualKeyboardEnabled()));
79 features->AppendString( 82 features->AppendString(
80 GenerateFeatureFlag("gesturetyping", keyboard::IsGestureTypingEnabled())); 83 GenerateFeatureFlag("gesturetyping", keyboard::IsGestureTypingEnabled()));
81 features->AppendString(GenerateFeatureFlag( 84 features->AppendString(GenerateFeatureFlag(
82 "gestureediting", keyboard::IsGestureEditingEnabled())); 85 "gestureediting", keyboard::IsGestureEditingEnabled()));
83 features->AppendString( 86 features->AppendString(
84 GenerateFeatureFlag("voiceinput", keyboard::IsVoiceInputEnabled())); 87 GenerateFeatureFlag("voiceinput", keyboard::IsVoiceInputEnabled()));
85 features->AppendString(GenerateFeatureFlag("experimental", 88 features->AppendString(GenerateFeatureFlag("experimental",
(...skipping 24 matching lines...) Expand all
110 return keyboard::InsertText(text); 113 return keyboard::InsertText(text);
111 } 114 }
112 115
113 bool ChromeVirtualKeyboardDelegate::OnKeyboardLoaded() { 116 bool ChromeVirtualKeyboardDelegate::OnKeyboardLoaded() {
114 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 117 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
115 keyboard::MarkKeyboardLoadFinished(); 118 keyboard::MarkKeyboardLoadFinished();
116 base::UserMetricsAction("VirtualKeyboardLoaded"); 119 base::UserMetricsAction("VirtualKeyboardLoaded");
117 return true; 120 return true;
118 } 121 }
119 122
123 void ChromeVirtualKeyboardDelegate::SetHotrodKeyboard(bool enable) {
124 if (keyboard::GetHotrodKeyboardEnabled() == enable)
125 return;
126
127 keyboard::SetHotrodKeyboardEnabled(enable);
128 // This reloads virtual keyboard even if it exists. This ensures virtual
129 // keyboard gets the correct state of the hotrod keyboard through
130 // chrome.virtualKeyboardPrivate.getKeyboardConfig.
131 if (enable && keyboard::IsKeyboardEnabled())
132 ash::Shell::GetInstance()->CreateKeyboard();
133 }
134
120 bool ChromeVirtualKeyboardDelegate::LockKeyboard(bool state) { 135 bool ChromeVirtualKeyboardDelegate::LockKeyboard(bool state) {
121 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 136 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
122 keyboard::KeyboardController* controller = 137 keyboard::KeyboardController* controller =
123 keyboard::KeyboardController::GetInstance(); 138 keyboard::KeyboardController::GetInstance();
124 if (!controller) 139 if (!controller)
125 return false; 140 return false;
126 141
127 keyboard::KeyboardController::GetInstance()->set_lock_keyboard(state); 142 keyboard::KeyboardController::GetInstance()->set_lock_keyboard(state);
128 return true; 143 return true;
129 } 144 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 195 }
181 196
182 bool ChromeVirtualKeyboardDelegate::IsLanguageSettingsEnabled() { 197 bool ChromeVirtualKeyboardDelegate::IsLanguageSettingsEnabled() {
183 return (user_manager::UserManager::Get()->IsUserLoggedIn() && 198 return (user_manager::UserManager::Get()->IsUserLoggedIn() &&
184 !chromeos::UserAddingScreen::Get()->IsRunning() && 199 !chromeos::UserAddingScreen::Get()->IsRunning() &&
185 !(chromeos::ScreenLocker::default_screen_locker() && 200 !(chromeos::ScreenLocker::default_screen_locker() &&
186 chromeos::ScreenLocker::default_screen_locker()->locked())); 201 chromeos::ScreenLocker::default_screen_locker()->locked()));
187 } 202 }
188 203
189 } // namespace extensions 204 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698