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

Side by Side Diff: extensions/browser/api/virtual_keyboard/virtual_keyboard_api.cc

Issue 2953033002: Hide handwriting and voice buttons when keyboard is in restricted state (Closed)
Patch Set: Created 3 years, 5 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "extensions/browser/api/virtual_keyboard/virtual_keyboard_api.h" 5 #include "extensions/browser/api/virtual_keyboard/virtual_keyboard_api.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_deleg ate.h" 9 #include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_deleg ate.h"
10 #include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_priva te_api.h" 10 #include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_priva te_api.h"
11 #include "extensions/common/api/virtual_keyboard.h" 11 #include "extensions/common/api/virtual_keyboard.h"
12 12
13 #if defined(OS_CHROMEOS)
14 #include "ui/base/ime/chromeos/input_method_manager.h"
15 using chromeos::input_method::InputMethodManager;
16 #endif
17
13 namespace extensions { 18 namespace extensions {
14 19
15 VirtualKeyboardRestrictFeaturesFunction:: 20 VirtualKeyboardRestrictFeaturesFunction::
16 VirtualKeyboardRestrictFeaturesFunction() {} 21 VirtualKeyboardRestrictFeaturesFunction() {}
17 22
18 ExtensionFunction::ResponseAction 23 ExtensionFunction::ResponseAction
19 VirtualKeyboardRestrictFeaturesFunction::Run() { 24 VirtualKeyboardRestrictFeaturesFunction::Run() {
20 std::unique_ptr<api::virtual_keyboard::RestrictFeatures::Params> params( 25 std::unique_ptr<api::virtual_keyboard::RestrictFeatures::Params> params(
21 api::virtual_keyboard::RestrictFeatures::Params::Create(*args_)); 26 api::virtual_keyboard::RestrictFeatures::Params::Create(*args_));
22 EXTENSION_FUNCTION_VALIDATE(params); 27 EXTENSION_FUNCTION_VALIDATE(params);
23 28
24 bool features_enabled = params->restrictions.auto_correct_enabled; 29 bool features_enabled = params->restrictions.auto_correct_enabled;
25 if (params->restrictions.auto_complete_enabled != features_enabled || 30 if (params->restrictions.auto_complete_enabled != features_enabled ||
26 params->restrictions.spell_check_enabled != features_enabled || 31 params->restrictions.spell_check_enabled != features_enabled ||
27 params->restrictions.voice_input_enabled != features_enabled || 32 params->restrictions.voice_input_enabled != features_enabled ||
28 params->restrictions.handwriting_enabled != features_enabled) { 33 params->restrictions.handwriting_enabled != features_enabled) {
29 return RespondNow( 34 return RespondNow(
James Cook 2017/06/27 16:31:11 Won't this function early-exit if the features hav
Azure Wei 2017/06/29 16:37:03 Yes, this will early-exit. The current API doesn't
James Cook 2017/06/29 16:48:29 OK. Do you know who is going to fix that?
30 Error("All features are expected to have the same enabled state.")); 35 Error("All features are expected to have the same enabled state."));
31 } 36 }
32 VirtualKeyboardAPI* api = 37 VirtualKeyboardAPI* api =
33 BrowserContextKeyedAPIFactory<VirtualKeyboardAPI>::Get(browser_context()); 38 BrowserContextKeyedAPIFactory<VirtualKeyboardAPI>::Get(browser_context());
34 api->delegate()->SetKeyboardRestricted(!features_enabled); 39 api->delegate()->SetKeyboardRestricted(!features_enabled);
40
41 #if defined(OS_CHROMEOS)
42 InputMethodManager* input_method_manager = InputMethodManager::Get();
43 if (input_method_manager) {
44 input_method_manager->SetFeaturesRestricted(
45 InputMethodManager::FeaturesRestricted::VOICE,
46 params->restrictions.voice_input_enabled);
James Cook 2017/06/27 16:31:11 Are you sure this is correct? You are restricting
tbarzic 2017/06/27 17:51:19 yeah, this looks wrong; feature should be restrict
Azure Wei 2017/06/29 16:37:03 You are right, this is wrong. Corrected. Thanks!
47 input_method_manager->SetFeaturesRestricted(
48 InputMethodManager::FeaturesRestricted::HANDWRITING,
49 params->restrictions.handwriting_enabled);
50 }
51 #endif
35 return RespondNow(NoArguments()); 52 return RespondNow(NoArguments());
36 } 53 }
37 54
38 } // namespace extensions 55 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698