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

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

Issue 13957005: Move KeyIdentifier->KeyEvent conversion to src/ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/string_util.h" 10 #include "base/string_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/extensions/extension_function_registry.h" 13 #include "chrome/browser/extensions/extension_function_registry.h"
14 #include "chrome/browser/extensions/key_identifier_conversion_views.h"
15 #include "chrome/browser/ui/top_level_widget.h" 14 #include "chrome/browser/ui/top_level_widget.h"
16 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
17 #include "ui/base/events/event.h" 16 #include "ui/base/events/event.h"
17 #include "ui/base/events/key_identifier_conversion.h"
18 18
19 #if defined(USE_ASH) && defined(USE_AURA) 19 #if defined(USE_ASH) && defined(USE_AURA)
20 #include "ash/shell.h" 20 #include "ash/shell.h"
21 #include "ui/aura/root_window.h" 21 #include "ui/aura/root_window.h"
22 #endif 22 #endif
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 namespace { 26 namespace {
27 27
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ui::EventType type = GetTypeFromString(type_name); 77 ui::EventType type = GetTypeFromString(type_name);
78 if (type == ui::ET_UNKNOWN) { 78 if (type == ui::ET_UNKNOWN) {
79 error_ = kUnknownEventTypeError; 79 error_ = kUnknownEventTypeError;
80 return false; 80 return false;
81 } 81 }
82 82
83 std::string identifier; 83 std::string identifier;
84 EXTENSION_FUNCTION_VALIDATE(args->GetString(kKeyIdentifier, &identifier)); 84 EXTENSION_FUNCTION_VALIDATE(args->GetString(kKeyIdentifier, &identifier));
85 TrimWhitespaceASCII(identifier, TRIM_ALL, &identifier); 85 TrimWhitespaceASCII(identifier, TRIM_ALL, &identifier);
86 86
87 const ui::KeyEvent& prototype_event = KeyEventFromKeyIdentifier(identifier); 87 const ui::KeyEvent& prototype_event =
88 ui::KeyEventFromKeyIdentifier(identifier);
88 uint16 character = 0; 89 uint16 character = 0;
89 if (prototype_event.key_code() == ui::VKEY_UNKNOWN) { 90 if (prototype_event.key_code() == ui::VKEY_UNKNOWN) {
90 // Check if |identifier| is "U+NNNN" format. 91 // Check if |identifier| is "U+NNNN" format.
91 character = UnicodeIdentifierStringToInt(identifier); 92 character = UnicodeIdentifierStringToInt(identifier);
92 if (!character) { 93 if (!character) {
93 error_ = kUnknownOrUnsupportedKeyIdentiferError; 94 error_ = kUnknownOrUnsupportedKeyIdentiferError;
94 return false; 95 return false;
95 } 96 }
96 } 97 }
97 98
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 138
138 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> > 139 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> >
139 g_factory = LAZY_INSTANCE_INITIALIZER; 140 g_factory = LAZY_INSTANCE_INITIALIZER;
140 141
141 // static 142 // static
142 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() { 143 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() {
143 return &g_factory.Get(); 144 return &g_factory.Get();
144 } 145 }
145 146
146 } // namespace extensions 147 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/key_identifier_conversion_views.h » ('j') | ui/base/events/key_identifier_conversion.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698