Index: chrome/browser/extensions/api/input/input.cc |
diff --git a/chrome/browser/extensions/api/input/input.cc b/chrome/browser/extensions/api/input/input.cc |
index b4d264fcbec26bc28dc068196428d7b505126d8a..c4f93d54732a725023b63070ec4a6da16eda1c1a 100644 |
--- a/chrome/browser/extensions/api/input/input.cc |
+++ b/chrome/browser/extensions/api/input/input.cc |
@@ -1,11 +1,10 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
#include "chrome/browser/extensions/api/input/input.h" |
#include "base/lazy_instance.h" |
-#include "base/memory/scoped_ptr.h" |
#include "base/strings/string16.h" |
#include "chrome/browser/extensions/extension_function_registry.h" |
#include "content/public/browser/browser_thread.h" |
@@ -38,10 +37,29 @@ bool InsertTextInputFunction::RunImpl() { |
return false; |
} |
+bool DispatchKeyEventFunction::RunImpl() { |
+#if defined(USE_ASH) |
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ |
+ // Extract type and charcter code |
+ std::string typeStr; |
+ int charCode; |
+ EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &typeStr)); |
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &charCode)); |
+ |
+ return keyboard::DispatchKeyEvent(typeStr, |
+ charCode, |
+ ash::Shell::GetPrimaryRootWindow()); |
+#endif |
+ error_ = kNotYetImplementedError; |
+ return false; |
+} |
+ |
InputAPI::InputAPI(Profile* profile) { |
ExtensionFunctionRegistry* registry = |
ExtensionFunctionRegistry::GetInstance(); |
registry->RegisterFunction<InsertTextInputFunction>(); |
+ registry->RegisterFunction<DispatchKeyEventFunction>(); |
} |
InputAPI::~InputAPI() { |