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

Side by Side Diff: chrome/browser/extensions/api/input/input.cc

Issue 20145004: Switch from text insertion to key press and release events on the virtual k… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Formatting. Created 7 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/api/input/input.h" 5 #include "chrome/browser/extensions/api/input/input.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
10 #include "chrome/browser/extensions/extension_function_registry.h" 9 #include "chrome/browser/extensions/extension_function_registry.h"
11 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
12 #include "ui/base/events/event.h" 11 #include "ui/base/events/event.h"
13 12
14 #if defined(USE_ASH) 13 #if defined(USE_ASH)
15 #include "ash/shell.h" 14 #include "ash/shell.h"
16 #include "ui/keyboard/keyboard_util.h" 15 #include "ui/keyboard/keyboard_util.h"
17 #endif 16 #endif
18 17
(...skipping 12 matching lines...) Expand all
31 30
32 string16 text; 31 string16 text;
33 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text)); 32 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text));
34 33
35 return keyboard::InsertText(text, ash::Shell::GetPrimaryRootWindow()); 34 return keyboard::InsertText(text, ash::Shell::GetPrimaryRootWindow());
36 #endif 35 #endif
37 error_ = kNotYetImplementedError; 36 error_ = kNotYetImplementedError;
38 return false; 37 return false;
39 } 38 }
40 39
40 bool DispatchKeyEventFunction::RunImpl() {
41 #if defined(USE_ASH)
42 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
43
44 // Extract type and charcter code
45 std::string typeStr;
46 int charCode;
47 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &typeStr));
48 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &charCode));
49
50 return keyboard::DispatchKeyEvent(typeStr,
51 charCode,
52 ash::Shell::GetPrimaryRootWindow());
53 #endif
54 error_ = kNotYetImplementedError;
55 return false;
56 }
57
41 InputAPI::InputAPI(Profile* profile) { 58 InputAPI::InputAPI(Profile* profile) {
42 ExtensionFunctionRegistry* registry = 59 ExtensionFunctionRegistry* registry =
43 ExtensionFunctionRegistry::GetInstance(); 60 ExtensionFunctionRegistry::GetInstance();
44 registry->RegisterFunction<InsertTextInputFunction>(); 61 registry->RegisterFunction<InsertTextInputFunction>();
62 registry->RegisterFunction<DispatchKeyEventFunction>();
45 } 63 }
46 64
47 InputAPI::~InputAPI() { 65 InputAPI::~InputAPI() {
48 } 66 }
49 67
50 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> > 68 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> >
51 g_factory = LAZY_INSTANCE_INITIALIZER; 69 g_factory = LAZY_INSTANCE_INITIALIZER;
52 70
53 // static 71 // static
54 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() { 72 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() {
55 return &g_factory.Get(); 73 return &g_factory.Get();
56 } 74 }
57 75
58 } // namespace extensions 76 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698