Index: chrome/browser/extensions/extension_input_api.cc |
diff --git a/chrome/browser/extensions/extension_input_api.cc b/chrome/browser/extensions/extension_input_api.cc |
index ffcd6594505e0498fe6807c978e2c119f986944b..0ff4b199e715872b1058297c406411e07b4ed82e 100644 |
--- a/chrome/browser/extensions/extension_input_api.cc |
+++ b/chrome/browser/extensions/extension_input_api.cc |
@@ -8,6 +8,9 @@ |
#include "base/string_util.h" |
#include "base/values.h" |
+#include "chrome/browser/chromeos/cros/cros_library.h" |
+#include "chrome/browser/chromeos/cros/input_method_library.h" |
+#include "chrome/browser/extensions/extension_tabs_module.h" |
Mihai Parparita -not on Chrome
2011/04/27 23:34:51
Why do you need this include?
Yusuke Sato
2011/04/28 10:57:07
Removed, thanks.
On 2011/04/27 23:34:51, Mihai Pa
|
#include "chrome/browser/extensions/key_identifier_conversion_views.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_window.h" |
@@ -45,6 +48,18 @@ ui::EventType GetTypeFromString(const std::string& type) { |
return ui::ET_UNKNOWN; |
} |
+bool GetDoubleValue( |
Mihai Parparita -not on Chrome
2011/04/27 23:34:51
This is at least the third implementation of such
Yusuke Sato
2011/04/28 10:57:07
I did it in a separate CL. Please review http://co
Yusuke Sato
2011/05/02 07:01:02
Done.
|
+ const DictionaryValue* dict, const char* key, double* result) { |
Zachary Kuznia
2011/04/27 10:25:09
nit: This should fit on the previous line
Yusuke Sato
2011/04/28 10:57:07
I'll remove the function.
On 2011/04/27 10:25:09,
|
+ int result_int = 0; |
+ // Since number literals in JS like 0.0 and 1.0 are treated as Integers, we |
+ // have to call GetInteger() first. |
+ if (dict->GetInteger(key, &result_int)) { |
+ *result = result_int; |
+ return true; |
+ } |
+ return dict->GetDouble(key, result); |
+} |
+ |
} // namespace |
void InputFunction::Run() { |
@@ -116,3 +131,32 @@ bool SendKeyboardEventInputFunction::RunImpl() { |
return true; |
} |
+ |
+bool SendHandwritingStrokesFunction::RunImpl() { |
+ ListValue* value = NULL; |
+ EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &value)); |
+ |
+ chromeos::HandwritingStrokes strokes; |
+ for (size_t i = 0; i < value->GetSize(); ++i) { |
+ DictionaryValue* dict; |
+ double x = 0.0; |
+ double y = 0.0; |
+ EXTENSION_FUNCTION_VALIDATE(value->GetDictionary(i, &dict)); |
+ EXTENSION_FUNCTION_VALIDATE(GetDoubleValue(dict, "x", &x)); |
+ EXTENSION_FUNCTION_VALIDATE(GetDoubleValue(dict, "y", &y)); |
+ strokes.push_back(std::make_pair(x, y)); |
+ } |
+ chromeos::CrosLibrary::Get()->GetInputMethodLibrary()-> |
Mihai Parparita -not on Chrome
2011/04/27 23:34:51
Other extensions that use CrosLibrary check if it'
Yusuke Sato
2011/04/28 10:57:07
It's definitely better to have the check. Added. T
|
+ SendHandwritingStrokes(strokes); |
+ return true; |
+} |
+ |
+bool CancelHandwritingFunction::RunImpl() { |
+ int n_strokes = 0; // zero means 'clear all strokes'. |
+ if (HasOptionalArgument(0)) { |
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &n_strokes)); |
+ } |
+ chromeos::CrosLibrary::Get()->GetInputMethodLibrary()-> |
+ CancelHandwriting(n_strokes); |
+ return true; |
+} |