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

Side by Side Diff: chrome/browser/extensions/key_identifier_conversion_views.cc

Issue 6487002: Add a new constructor to KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/key_identifier_conversion_views.h" 5 #include "chrome/browser/extensions/key_identifier_conversion_views.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 typedef std::pair<std::string, const views::KeyEvent*> IdentifierPair; 287 typedef std::pair<std::string, const views::KeyEvent*> IdentifierPair;
288 static IdentifierMap* identifierMaps[kNumIdentifierTypes] = { NULL }; 288 static IdentifierMap* identifierMaps[kNumIdentifierTypes] = { NULL };
289 289
290 static views::KeyEvent* kUnknownKeyEvent = NULL; 290 static views::KeyEvent* kUnknownKeyEvent = NULL;
291 291
292 static void InitializeMaps() { 292 static void InitializeMaps() {
293 if (identifierMaps[0]) 293 if (identifierMaps[0])
294 return; 294 return;
295 295
296 kUnknownKeyEvent = new views::KeyEvent( 296 kUnknownKeyEvent = new views::KeyEvent(
297 ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0, 0, 0); 297 ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0);
298 298
299 for (int i = 0; i < kNumIdentifierTypes; ++i) 299 for (int i = 0; i < kNumIdentifierTypes; ++i)
300 identifierMaps[i] = new IdentifierMap; 300 identifierMaps[i] = new IdentifierMap;
301 301
302 for (int i = 0; i < kNumKeyIdentifiers; ++i) { 302 for (int i = 0; i < kNumKeyIdentifiers; ++i) {
303 const KeyIdentifier& key = kKeyIdentifiers[i]; 303 const KeyIdentifier& key = kKeyIdentifiers[i];
304 304
305 views::KeyEvent* event = new views::KeyEvent( 305 views::KeyEvent* event = new views::KeyEvent(
306 ui::ET_KEY_PRESSED, key.key_code, key.event_flags, 0, 0); 306 ui::ET_KEY_PRESSED, key.key_code, key.event_flags);
307 307
308 for (int j = 0; j < kNumIdentifierTypes; ++j) { 308 for (int j = 0; j < kNumIdentifierTypes; ++j) {
309 if (key.identifiers[j][0] != '\0') { 309 if (key.identifiers[j][0] != '\0') {
310 std::pair<IdentifierMap::iterator, bool> result = 310 std::pair<IdentifierMap::iterator, bool> result =
311 identifierMaps[j]->insert( 311 identifierMaps[j]->insert(
312 IdentifierPair(key.identifiers[j], event)); 312 IdentifierPair(key.identifiers[j], event));
313 DCHECK(result.second); 313 DCHECK(result.second);
314 } 314 }
315 } 315 }
316 } 316 }
(...skipping 10 matching lines...) Expand all
327 for (int i = 0; i < kNumIdentifierTypes; ++i) { 327 for (int i = 0; i < kNumIdentifierTypes; ++i) {
328 const IdentifierMap& map = *identifierMaps[i]; 328 const IdentifierMap& map = *identifierMaps[i];
329 329
330 IdentifierMap::const_iterator iter = map.find(key_identifier); 330 IdentifierMap::const_iterator iter = map.find(key_identifier);
331 if (iter != map.end()) 331 if (iter != map.end())
332 return *iter->second; 332 return *iter->second;
333 } 333 }
334 334
335 return *kUnknownKeyEvent; 335 return *kUnknownKeyEvent;
336 } 336 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_input_api.cc ('k') | chrome/browser/ui/views/dropdown_bar_host_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698