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

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

Issue 7058046: Adjust virtual keyboard size base on input method candidates. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase on trunk Created 9 years, 6 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"
(...skipping 27 matching lines...) Expand all
38 const char kKeyDown[] = "keydown"; 38 const char kKeyDown[] = "keydown";
39 const char kKeyUp[] = "keyup"; 39 const char kKeyUp[] = "keyup";
40 40
41 // Errors. 41 // Errors.
42 const char kUnknownEventTypeError[] = "Unknown event type."; 42 const char kUnknownEventTypeError[] = "Unknown event type.";
43 const char kUnknownOrUnsupportedKeyIdentiferError[] = "Unknown or unsupported " 43 const char kUnknownOrUnsupportedKeyIdentiferError[] = "Unknown or unsupported "
44 "key identifier."; 44 "key identifier.";
45 const char kUnsupportedModifier[] = "Unsupported modifier."; 45 const char kUnsupportedModifier[] = "Unsupported modifier.";
46 const char kNoValidRecipientError[] = "No valid recipient for event."; 46 const char kNoValidRecipientError[] = "No valid recipient for event.";
47 const char kKeyEventUnprocessedError[] = "Event was not handled."; 47 const char kKeyEventUnprocessedError[] = "Event was not handled.";
48 const char kInvalidHeight[] = "Invalid height.";
48 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) 49 #if defined(OS_CHROMEOS) && defined(TOUCH_UI)
49 const char kCrosLibraryNotLoadedError[] = "Cros shared library not loaded."; 50 const char kCrosLibraryNotLoadedError[] = "Cros shared library not loaded.";
50 #endif 51 #endif
51 52
52 ui::EventType GetTypeFromString(const std::string& type) { 53 ui::EventType GetTypeFromString(const std::string& type) {
53 if (type == kKeyDown) { 54 if (type == kKeyDown) {
54 return ui::ET_KEY_PRESSED; 55 return ui::ET_KEY_PRESSED;
55 } else if (type == kKeyUp) { 56 } else if (type == kKeyUp) {
56 return ui::ET_KEY_RELEASED; 57 return ui::ET_KEY_RELEASED;
57 } 58 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 138 }
138 139
139 #if defined(TOUCH_UI) 140 #if defined(TOUCH_UI)
140 bool HideKeyboardFunction::RunImpl() { 141 bool HideKeyboardFunction::RunImpl() {
141 NotificationService::current()->Notify( 142 NotificationService::current()->Notify(
142 NotificationType::HIDE_KEYBOARD_INVOKED, 143 NotificationType::HIDE_KEYBOARD_INVOKED,
143 Source<HideKeyboardFunction>(this), 144 Source<HideKeyboardFunction>(this),
144 NotificationService::NoDetails()); 145 NotificationService::NoDetails());
145 return true; 146 return true;
146 } 147 }
148
149 bool SetKeyboardHeightFunction::RunImpl() {
150 int height = 0;
151 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &height));
152
153 if (height < 0) {
154 error_ = kInvalidHeight;
155 return false;
156 }
157
158 // TODO(penghuang) Check the height is not greater than height of browser view
159 // and set the height of virtual keyboard directly instead of using
160 // notification.
161 NotificationService::current()->Notify(
162 NotificationType::SET_KEYBOARD_HEIGHT_INVOKED,
163 Source<SetKeyboardHeightFunction>(this),
164 Details<int>(&height));
165 return true;
166 }
147 #endif 167 #endif
148 168
149 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) 169 #if defined(OS_CHROMEOS) && defined(TOUCH_UI)
150 // TODO(yusukes): This part should be moved to extension_input_api_chromeos.cc. 170 // TODO(yusukes): This part should be moved to extension_input_api_chromeos.cc.
151 bool SendHandwritingStrokeFunction::RunImpl() { 171 bool SendHandwritingStrokeFunction::RunImpl() {
152 chromeos::CrosLibrary* cros_library = chromeos::CrosLibrary::Get(); 172 chromeos::CrosLibrary* cros_library = chromeos::CrosLibrary::Get();
153 if (!cros_library->EnsureLoaded()) { 173 if (!cros_library->EnsureLoaded()) {
154 error_ = kCrosLibraryNotLoadedError; 174 error_ = kCrosLibraryNotLoadedError;
155 return false; 175 return false;
156 } 176 }
(...skipping 26 matching lines...) Expand all
183 // TODO(yusukes): Add a parameter for an input context ID. 203 // TODO(yusukes): Add a parameter for an input context ID.
184 int stroke_count = 0; // zero means 'clear all strokes'. 204 int stroke_count = 0; // zero means 'clear all strokes'.
185 if (HasOptionalArgument(0)) { 205 if (HasOptionalArgument(0)) {
186 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &stroke_count)); 206 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &stroke_count));
187 EXTENSION_FUNCTION_VALIDATE(stroke_count >= 0); 207 EXTENSION_FUNCTION_VALIDATE(stroke_count >= 0);
188 } 208 }
189 cros_library->GetInputMethodLibrary()->CancelHandwritingStrokes(stroke_count); 209 cros_library->GetInputMethodLibrary()->CancelHandwritingStrokes(stroke_count);
190 return true; 210 return true;
191 } 211 }
192 #endif 212 #endif
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_input_api.h ('k') | chrome/browser/resources/keyboard/ime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698