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

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

Issue 10825254: Remove views::KeyEvent, replacing uses of it with ui::KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | 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/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 <utility> 9 #include <utility>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "ui/base/event.h"
15 #include "ui/base/keycodes/keyboard_codes.h" 16 #include "ui/base/keycodes/keyboard_codes.h"
16 #include "ui/views/events/event.h" 17 #include "ui/views/events/event.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 20
20 namespace { 21 namespace {
21 22
22 static const int kNumIdentifierTypes = 3; 23 static const int kNumIdentifierTypes = 3;
23 24
24 typedef struct KeyIdentifier { 25 typedef struct KeyIdentifier {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 { {"DeadCedilla", "", "U+0327"}, ui::VKEY_UNKNOWN, 0 }, 282 { {"DeadCedilla", "", "U+0327"}, ui::VKEY_UNKNOWN, 0 },
282 { {"DeadOgonek", "", "U+0328"}, ui::VKEY_UNKNOWN, 0 }, 283 { {"DeadOgonek", "", "U+0328"}, ui::VKEY_UNKNOWN, 0 },
283 { {"DeadIota", "", "U+0345"}, ui::VKEY_UNKNOWN, 0 }, 284 { {"DeadIota", "", "U+0345"}, ui::VKEY_UNKNOWN, 0 },
284 { {"Euro", "", "U+20AC"}, ui::VKEY_UNKNOWN, 0 }, 285 { {"Euro", "", "U+20AC"}, ui::VKEY_UNKNOWN, 0 },
285 { {"DeadVoicedSound", "", "U+3099"}, ui::VKEY_UNKNOWN, 0 }, 286 { {"DeadVoicedSound", "", "U+3099"}, ui::VKEY_UNKNOWN, 0 },
286 { {"DeadSemivoicedSound", "", "U+309A"}, ui::VKEY_UNKNOWN, 0 } 287 { {"DeadSemivoicedSound", "", "U+309A"}, ui::VKEY_UNKNOWN, 0 }
287 }; 288 };
288 289
289 static const int kNumKeyIdentifiers = arraysize(kKeyIdentifiers); 290 static const int kNumKeyIdentifiers = arraysize(kKeyIdentifiers);
290 291
291 typedef base::hash_map<std::string, const views::KeyEvent*> IdentifierMap; 292 typedef base::hash_map<std::string, const ui::KeyEvent*> IdentifierMap;
292 typedef std::pair<std::string, const views::KeyEvent*> IdentifierPair; 293 typedef std::pair<std::string, const ui::KeyEvent*> IdentifierPair;
293 static IdentifierMap* identifierMaps[kNumIdentifierTypes] = { NULL }; 294 static IdentifierMap* identifierMaps[kNumIdentifierTypes] = { NULL };
294 295
295 static views::KeyEvent* kUnknownKeyEvent = NULL; 296 static ui::KeyEvent* kUnknownKeyEvent = NULL;
296 297
297 static void InitializeMaps() { 298 static void InitializeMaps() {
298 if (identifierMaps[0]) 299 if (identifierMaps[0])
299 return; 300 return;
300 301
301 kUnknownKeyEvent = new views::KeyEvent( 302 kUnknownKeyEvent = new ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0);
302 ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0);
303 303
304 for (int i = 0; i < kNumIdentifierTypes; ++i) 304 for (int i = 0; i < kNumIdentifierTypes; ++i)
305 identifierMaps[i] = new IdentifierMap; 305 identifierMaps[i] = new IdentifierMap;
306 306
307 for (int i = 0; i < kNumKeyIdentifiers; ++i) { 307 for (int i = 0; i < kNumKeyIdentifiers; ++i) {
308 const KeyIdentifier& key = kKeyIdentifiers[i]; 308 const KeyIdentifier& key = kKeyIdentifiers[i];
309 309
310 views::KeyEvent* event = new views::KeyEvent( 310 ui::KeyEvent* event =
311 ui::ET_KEY_PRESSED, key.key_code, key.event_flags); 311 new ui::KeyEvent(ui::ET_KEY_PRESSED, key.key_code, key.event_flags);
312 312
313 for (int j = 0; j < kNumIdentifierTypes; ++j) { 313 for (int j = 0; j < kNumIdentifierTypes; ++j) {
314 if (key.identifiers[j][0] != '\0') { 314 if (key.identifiers[j][0] != '\0') {
315 std::pair<IdentifierMap::iterator, bool> result = 315 std::pair<IdentifierMap::iterator, bool> result =
316 identifierMaps[j]->insert( 316 identifierMaps[j]->insert(
317 IdentifierPair(key.identifiers[j], event)); 317 IdentifierPair(key.identifiers[j], event));
318 DCHECK(result.second); 318 DCHECK(result.second);
319 } 319 }
320 } 320 }
321 } 321 }
322 } 322 }
323 323
324 } // namespace 324 } // namespace
325 325
326 326
327 const views::KeyEvent& KeyEventFromKeyIdentifier( 327 const ui::KeyEvent& KeyEventFromKeyIdentifier(
328 const std::string& key_identifier) { 328 const std::string& key_identifier) {
329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
330 InitializeMaps(); 330 InitializeMaps();
331 331
332 for (int i = 0; i < kNumIdentifierTypes; ++i) { 332 for (int i = 0; i < kNumIdentifierTypes; ++i) {
333 const IdentifierMap& map = *identifierMaps[i]; 333 const IdentifierMap& map = *identifierMaps[i];
334 334
335 IdentifierMap::const_iterator iter = map.find(key_identifier); 335 IdentifierMap::const_iterator iter = map.find(key_identifier);
336 if (iter != map.end()) 336 if (iter != map.end())
337 return *iter->second; 337 return *iter->second;
338 } 338 }
339 339
340 return *kUnknownKeyEvent; 340 return *kUnknownKeyEvent;
341 } 341 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698