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

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: gyp fix 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
« no previous file with comments | « no previous file | chrome/browser/extensions/key_identifier_conversion_views.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
16 #include "content/public/browser/browser_thread.h"
17 #include "ui/base/events/event.h" 17 #include "ui/base/events/event.h"
18 #include "ui/base/events/key_identifier_conversion.h"
18 19
19 #if defined(USE_ASH) && defined(USE_AURA) 20 #if defined(USE_ASH) && defined(USE_AURA)
20 #include "ash/shell.h" 21 #include "ash/shell.h"
21 #include "ui/aura/root_window.h" 22 #include "ui/aura/root_window.h"
22 #endif 23 #endif
23 24
24 namespace extensions { 25 namespace extensions {
25 26
26 namespace { 27 namespace {
27 28
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ui::EventType type = GetTypeFromString(type_name); 78 ui::EventType type = GetTypeFromString(type_name);
78 if (type == ui::ET_UNKNOWN) { 79 if (type == ui::ET_UNKNOWN) {
79 error_ = kUnknownEventTypeError; 80 error_ = kUnknownEventTypeError;
80 return false; 81 return false;
81 } 82 }
82 83
83 std::string identifier; 84 std::string identifier;
84 EXTENSION_FUNCTION_VALIDATE(args->GetString(kKeyIdentifier, &identifier)); 85 EXTENSION_FUNCTION_VALIDATE(args->GetString(kKeyIdentifier, &identifier));
85 TrimWhitespaceASCII(identifier, TRIM_ALL, &identifier); 86 TrimWhitespaceASCII(identifier, TRIM_ALL, &identifier);
86 87
87 const ui::KeyEvent& prototype_event = KeyEventFromKeyIdentifier(identifier); 88 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
89 const ui::KeyEvent& prototype_event =
90 ui::KeyEventFromKeyIdentifier(identifier);
88 uint16 character = 0; 91 uint16 character = 0;
89 if (prototype_event.key_code() == ui::VKEY_UNKNOWN) { 92 if (prototype_event.key_code() == ui::VKEY_UNKNOWN) {
90 // Check if |identifier| is "U+NNNN" format. 93 // Check if |identifier| is "U+NNNN" format.
91 character = UnicodeIdentifierStringToInt(identifier); 94 character = UnicodeIdentifierStringToInt(identifier);
92 if (!character) { 95 if (!character) {
93 error_ = kUnknownOrUnsupportedKeyIdentiferError; 96 error_ = kUnknownOrUnsupportedKeyIdentiferError;
94 return false; 97 return false;
95 } 98 }
96 } 99 }
97 100
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 140
138 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> > 141 static base::LazyInstance<ProfileKeyedAPIFactory<InputAPI> >
139 g_factory = LAZY_INSTANCE_INITIALIZER; 142 g_factory = LAZY_INSTANCE_INITIALIZER;
140 143
141 // static 144 // static
142 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() { 145 ProfileKeyedAPIFactory<InputAPI>* InputAPI::GetFactoryInstance() {
143 return &g_factory.Get(); 146 return &g_factory.Get();
144 } 147 }
145 148
146 } // namespace extensions 149 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/key_identifier_conversion_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698