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

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

Issue 14674004: DRAFT: Add setKeyboardVisibility API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 (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 <string> 7 #include <string>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/extensions/extension_function_registry.h" 11 #include "chrome/browser/extensions/extension_function_registry.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "ui/base/events/event.h" 13 #include "ui/base/events/event.h"
14 14
15 #if defined(USE_ASH) 15 #if defined(USE_ASH)
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
18 #include "ui/keyboard/keyboard_controller.h"
18 #include "ui/keyboard/keyboard_util.h" 19 #include "ui/keyboard/keyboard_util.h"
19 #endif 20 #endif
20 21
21 namespace { 22 namespace {
22 23
23 const char kNotYetImplementedError[] = 24 const char kNotYetImplementedError[] =
24 "API is not implemented on this platform."; 25 "API is not implemented on this platform.";
25 26
26 } // namespace 27 } // namespace
27 28
(...skipping 10 matching lines...) Expand all
38 39
39 ash::Shell::GetActiveRootWindow()->AsRootWindowHostDelegate()->OnHostKeyEvent( 40 ash::Shell::GetActiveRootWindow()->AsRootWindowHostDelegate()->OnHostKeyEvent(
40 event.get()); 41 event.get());
41 42
42 return true; 43 return true;
43 #endif 44 #endif
44 error_ = kNotYetImplementedError; 45 error_ = kNotYetImplementedError;
45 return false; 46 return false;
46 } 47 }
47 48
49 bool SetKeyboardVisibilityFunction::RunImpl() {
50 #if defined(USE_ASH)
51 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
52
53 bool visible;
54 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &visible));
55
56 ash::Shell::GetKeyboardController()->SetKeyboardVisibility(visible);
57
58 return true;
59 #endif
60 error_ = kNotYetImplementedError;
61 return false;
62 }
63
64
48 InputAPI::InputAPI(Profile* profile) { 65 InputAPI::InputAPI(Profile* profile) {
49 ExtensionFunctionRegistry* registry = 66 ExtensionFunctionRegistry* registry =
50 ExtensionFunctionRegistry::GetInstance(); 67 ExtensionFunctionRegistry::GetInstance();
68 registry->RegisterFunction<SetKeyboardVisibilityFunction>();
51 registry->RegisterFunction<SendKeyboardEventInputFunction>(); 69 registry->RegisterFunction<SendKeyboardEventInputFunction>();
52 } 70 }
53 71
54 InputAPI::~InputAPI() { 72 InputAPI::~InputAPI() {
55 } 73 }
56 74
57 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> > 75 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> >
58 g_factory = LAZY_INSTANCE_INITIALIZER; 76 g_factory = LAZY_INSTANCE_INITIALIZER;
59 77
60 // static 78 // static
61 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() { 79 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() {
62 return &g_factory.Get(); 80 return &g_factory.Get();
63 } 81 }
64 82
65 } // namespace extensions 83 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698