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

Side by Side Diff: chrome/browser/extensions/extension_input_api.cc

Issue 7033033: Add hideKeyboard API to chrome.experimental.input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 'Rename HideKeyboardInputFunction to HideKeyboardFunction' Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_input_api.h" 5 #include "chrome/browser/extensions/extension_input_api.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/extensions/key_identifier_conversion_views.h" 11 #include "chrome/browser/extensions/key_identifier_conversion_views.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/views/frame/browser_view.h" 14 #include "chrome/browser/ui/views/frame/browser_view.h"
15 #include "views/events/event.h" 15 #include "views/events/event.h"
16 #include "views/ime/input_method.h" 16 #include "views/ime/input_method.h"
17 #include "views/widget/widget.h" 17 #include "views/widget/widget.h"
18 18
19 #if defined(TOUCH_UI)
20 #include "content/common/notification_service.h"
21 #endif
22
19 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) 23 #if defined(OS_CHROMEOS) && defined(TOUCH_UI)
20 #include "chrome/browser/chromeos/cros/cros_library.h" 24 #include "chrome/browser/chromeos/cros/cros_library.h"
21 #include "chrome/browser/chromeos/cros/input_method_library.h" 25 #include "chrome/browser/chromeos/cros/input_method_library.h"
22 #endif 26 #endif
23 27
24 namespace { 28 namespace {
25 29
26 // Keys. 30 // Keys.
27 const char kType[] = "type"; 31 const char kType[] = "type";
28 const char kKeyIdentifier[] = "keyIdentifier"; 32 const char kKeyIdentifier[] = "keyIdentifier";
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (ime) { 122 if (ime) {
119 ime->DispatchKeyEvent(event); 123 ime->DispatchKeyEvent(event);
120 } else if (!widget->OnKeyEvent(event)) { 124 } else if (!widget->OnKeyEvent(event)) {
121 error_ = kKeyEventUnprocessedError; 125 error_ = kKeyEventUnprocessedError;
122 return false; 126 return false;
123 } 127 }
124 128
125 return true; 129 return true;
126 } 130 }
127 131
132 #if defined(TOUCH_UI)
133 bool HideKeyboardFunction::RunImpl() {
134 NotificationService::current()->Notify(
135 NotificationType::HIDE_KEYBOARD_INVOKED,
136 Source<HideKeyboardFunction>(this),
137 NotificationService::NoDetails());
138 return true;
139 }
140 #endif
141
128 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) 142 #if defined(OS_CHROMEOS) && defined(TOUCH_UI)
129 // TODO(yusukes): This part should be moved to extension_input_api_chromeos.cc. 143 // TODO(yusukes): This part should be moved to extension_input_api_chromeos.cc.
130 bool SendHandwritingStrokeFunction::RunImpl() { 144 bool SendHandwritingStrokeFunction::RunImpl() {
131 chromeos::CrosLibrary* cros_library = chromeos::CrosLibrary::Get(); 145 chromeos::CrosLibrary* cros_library = chromeos::CrosLibrary::Get();
132 if (!cros_library->EnsureLoaded()) { 146 if (!cros_library->EnsureLoaded()) {
133 error_ = kCrosLibraryNotLoadedError; 147 error_ = kCrosLibraryNotLoadedError;
134 return false; 148 return false;
135 } 149 }
136 150
137 // TODO(yusukes): Add a parameter for an input context ID. 151 // TODO(yusukes): Add a parameter for an input context ID.
(...skipping 24 matching lines...) Expand all
162 // TODO(yusukes): Add a parameter for an input context ID. 176 // TODO(yusukes): Add a parameter for an input context ID.
163 int stroke_count = 0; // zero means 'clear all strokes'. 177 int stroke_count = 0; // zero means 'clear all strokes'.
164 if (HasOptionalArgument(0)) { 178 if (HasOptionalArgument(0)) {
165 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &stroke_count)); 179 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &stroke_count));
166 EXTENSION_FUNCTION_VALIDATE(stroke_count >= 0); 180 EXTENSION_FUNCTION_VALIDATE(stroke_count >= 0);
167 } 181 }
168 cros_library->GetInputMethodLibrary()->CancelHandwritingStrokes(stroke_count); 182 cros_library->GetInputMethodLibrary()->CancelHandwritingStrokes(stroke_count);
169 return true; 183 return true;
170 } 184 }
171 #endif 185 #endif
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_input_api.h ('k') | chrome/browser/resources/keyboard/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698