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

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

Issue 20526005: Implement virtual keyboard hiding. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Init Created 7 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ash/root_window_controller.h"
7 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
10 #include "chrome/browser/extensions/extension_function_registry.h" 11 #include "chrome/browser/extensions/extension_function_registry.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "ui/base/events/event.h" 13 #include "ui/base/events/event.h"
14 #include "ui/keyboard/keyboard_controller.h"
13 15
14 #if defined(USE_ASH) 16 #if defined(USE_ASH)
15 #include "ash/shell.h" 17 #include "ash/shell.h"
16 #include "ui/keyboard/keyboard_util.h" 18 #include "ui/keyboard/keyboard_util.h"
17 #endif 19 #endif
18 20
19 namespace { 21 namespace {
20 22
21 const char kNotYetImplementedError[] = 23 const char kNotYetImplementedError[] =
22 "API is not implemented on this platform."; 24 "API is not implemented on this platform.";
23 25
24 } // namespace 26 } // namespace
25 27
26 namespace extensions { 28 namespace extensions {
27 29
28 bool InsertTextInputFunction::RunImpl() { 30 bool InsertTextInputFunction::RunImpl() {
29 #if defined(USE_ASH) 31 #if defined(USE_ASH)
30 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 32 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
31 33
32 string16 text; 34 string16 text;
33 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text)); 35 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text));
34 36
35 return keyboard::InsertText(text, ash::Shell::GetPrimaryRootWindow()); 37 return keyboard::InsertText(text, ash::Shell::GetPrimaryRootWindow());
36 #endif 38 #endif
37 error_ = kNotYetImplementedError; 39 error_ = kNotYetImplementedError;
38 return false; 40 return false;
39 } 41 }
40 42
43 bool HideKeyboardFunction::RunImpl() {
44 #if defined(USE_ASH)
45 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
46
47 ash::Shell::GetPrimaryRootWindowController()->keyboard_controller()->
48 HideKeyboard();
49
50 return true;
51 #endif
52 error_ = kNotYetImplementedError;
53 return false;
54 }
55
41 InputAPI::InputAPI(Profile* profile) { 56 InputAPI::InputAPI(Profile* profile) {
42 ExtensionFunctionRegistry* registry = 57 ExtensionFunctionRegistry* registry =
43 ExtensionFunctionRegistry::GetInstance(); 58 ExtensionFunctionRegistry::GetInstance();
44 registry->RegisterFunction<InsertTextInputFunction>(); 59 registry->RegisterFunction<InsertTextInputFunction>();
60 registry->RegisterFunction<HideKeyboardFunction>();
45 } 61 }
46 62
47 InputAPI::~InputAPI() { 63 InputAPI::~InputAPI() {
48 } 64 }
49 65
50 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> > 66 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> >
51 g_factory = LAZY_INSTANCE_INITIALIZER; 67 g_factory = LAZY_INSTANCE_INITIALIZER;
52 68
53 // static 69 // static
54 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() { 70 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() {
55 return &g_factory.Get(); 71 return &g_factory.Get();
56 } 72 }
57 73
58 } // namespace extensions 74 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698