| OLD | NEW |
| 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_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/key_identifier_conversion_views.h" | 12 #include "chrome/browser/extensions/key_identifier_conversion_views.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "ui/views/events/event.h" | 17 #include "ui/views/events/event.h" |
| 18 #include "ui/views/ime/input_method.h" | 18 #include "ui/views/ime/input_method.h" |
| 19 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 20 #include "views/views_delegate.h" | 20 #include "views/views_delegate.h" |
| 21 | 21 |
| 22 #if defined(USE_VIRTUAL_KEYBOARD) | 22 #if defined(USE_VIRTUAL_KEYBOARD) |
| 23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) | 26 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) |
| 27 #include "chrome/browser/chromeos/input_method/ibus_controller.h" | 27 #include "chrome/browser/chromeos/input_method/ibus_controller.h" |
| 28 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 28 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 29 #include "chrome/browser/chromeos/login/base_login_display_host.h" | 29 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // Keys. | 34 // Keys. |
| 35 const char kType[] = "type"; | 35 const char kType[] = "type"; |
| 36 const char kKeyIdentifier[] = "keyIdentifier"; | 36 const char kKeyIdentifier[] = "keyIdentifier"; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 67 (key_identifier.substr(2).find_first_not_of("0123456789abcdefABCDEF") == | 67 (key_identifier.substr(2).find_first_not_of("0123456789abcdefABCDEF") == |
| 68 std::string::npos)) { | 68 std::string::npos)) { |
| 69 const bool result = | 69 const bool result = |
| 70 base::HexStringToInt(key_identifier.substr(2), &character); | 70 base::HexStringToInt(key_identifier.substr(2), &character); |
| 71 DCHECK(result) << key_identifier; | 71 DCHECK(result) << key_identifier; |
| 72 } | 72 } |
| 73 return character; | 73 return character; |
| 74 } | 74 } |
| 75 | 75 |
| 76 views::Widget* GetTopLevelWidget(Browser* browser) { | 76 views::Widget* GetTopLevelWidget(Browser* browser) { |
| 77 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) | 77 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) |
| 78 chromeos::LoginDisplayHost* host = | 78 chromeos::LoginDisplayHost* host = |
| 79 chromeos::BaseLoginDisplayHost::default_host(); | 79 chromeos::BaseLoginDisplayHost::default_host(); |
| 80 if (host) | 80 if (host) |
| 81 return views::Widget::GetWidgetForNativeWindow(host->GetNativeWindow()); | 81 return views::Widget::GetWidgetForNativeWindow(host->GetNativeWindow()); |
| 82 #endif | 82 #endif |
| 83 | 83 |
| 84 if (!browser) | 84 if (!browser) |
| 85 return NULL; | 85 return NULL; |
| 86 | 86 |
| 87 BrowserWindow* window = browser->window(); | 87 BrowserWindow* window = browser->window(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // and set the height of virtual keyboard directly instead of using | 180 // and set the height of virtual keyboard directly instead of using |
| 181 // notification. | 181 // notification. |
| 182 content::NotificationService::current()->Notify( | 182 content::NotificationService::current()->Notify( |
| 183 chrome::NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED, | 183 chrome::NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED, |
| 184 content::Source<SetKeyboardHeightFunction>(this), | 184 content::Source<SetKeyboardHeightFunction>(this), |
| 185 content::Details<int>(&height)); | 185 content::Details<int>(&height)); |
| 186 return true; | 186 return true; |
| 187 } | 187 } |
| 188 #endif | 188 #endif |
| 189 | 189 |
| 190 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) | 190 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) |
| 191 // TODO(yusukes): This part should be moved to extension_input_api_chromeos.cc. | 191 // TODO(yusukes): This part should be moved to extension_input_api_chromeos.cc. |
| 192 bool SendHandwritingStrokeFunction::RunImpl() { | 192 bool SendHandwritingStrokeFunction::RunImpl() { |
| 193 // TODO(yusukes): Add a parameter for an input context ID. | 193 // TODO(yusukes): Add a parameter for an input context ID. |
| 194 ListValue* value = NULL; | 194 ListValue* value = NULL; |
| 195 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &value)); | 195 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &value)); |
| 196 | 196 |
| 197 chromeos::input_method::HandwritingStroke stroke; | 197 chromeos::input_method::HandwritingStroke stroke; |
| 198 for (size_t i = 0; i < value->GetSize(); ++i) { | 198 for (size_t i = 0; i < value->GetSize(); ++i) { |
| 199 DictionaryValue* dict; | 199 DictionaryValue* dict; |
| 200 double x = 0.0; | 200 double x = 0.0; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 229 int stroke_count = 0; // zero means 'clear all strokes'. | 229 int stroke_count = 0; // zero means 'clear all strokes'. |
| 230 if (HasOptionalArgument(0)) { | 230 if (HasOptionalArgument(0)) { |
| 231 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &stroke_count)); | 231 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &stroke_count)); |
| 232 EXTENSION_FUNCTION_VALIDATE(stroke_count >= 0); | 232 EXTENSION_FUNCTION_VALIDATE(stroke_count >= 0); |
| 233 } | 233 } |
| 234 chromeos::input_method::InputMethodManager::GetInstance()-> | 234 chromeos::input_method::InputMethodManager::GetInstance()-> |
| 235 CancelHandwritingStrokes(stroke_count); | 235 CancelHandwritingStrokes(stroke_count); |
| 236 return true; | 236 return true; |
| 237 } | 237 } |
| 238 #endif | 238 #endif |
| OLD | NEW |