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

Side by Side Diff: chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter.cc

Issue 1191783002: Support Compat mode inside of the desktop tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@commands_alt
Patch Set: Different approach. Created 5 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chromeos/accessibility/spoken_feedback_event_rewriter.h " 5 #include "chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter.h "
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 21 matching lines...) Expand all
32 32
33 content::BrowserContext* context = 33 content::BrowserContext* context =
34 g_browser_process->profile_manager()->GetLastUsedProfile(); 34 g_browser_process->profile_manager()->GetLastUsedProfile();
35 35
36 const extensions::Extension* extension = 36 const extensions::Extension* extension =
37 extensions::ExtensionRegistry::Get(context)->enabled_extensions().GetByID( 37 extensions::ExtensionRegistry::Get(context)->enabled_extensions().GetByID(
38 extension_misc::kChromeVoxExtensionId); 38 extension_misc::kChromeVoxExtensionId);
39 if (!extension) 39 if (!extension)
40 return ui::EVENT_REWRITE_CONTINUE; 40 return ui::EVENT_REWRITE_CONTINUE;
41 41
42 extensions::EventRouter* event_router = extensions::EventRouter::Get(context);
43 if (!event_router->ExtensionHasEventListener(
44 extension_misc::kChromeVoxExtensionId, "commands.onCommand"))
45 return ui::EVENT_REWRITE_CONTINUE;
46
42 const extensions::CommandMap* commands = 47 const extensions::CommandMap* commands =
43 extensions::CommandsInfo::GetNamedCommands(extension); 48 extensions::CommandsInfo::GetNamedCommands(extension);
44 if (!commands) 49 if (!commands)
45 return ui::EVENT_REWRITE_CONTINUE; 50 return ui::EVENT_REWRITE_CONTINUE;
46 51
47 const ui::KeyEvent key_event = static_cast<const ui::KeyEvent&>(event); 52 const ui::KeyEvent key_event = static_cast<const ui::KeyEvent&>(event);
53 int modifiers = key_event.flags() & ui::EF_ALL_MODIFIERS;
48 std::string command_name; 54 std::string command_name;
49 for (extensions::CommandMap::const_iterator iter = commands->begin(); 55 for (extensions::CommandMap::const_iterator iter = commands->begin();
50 iter != commands->end(); ++iter) { 56 iter != commands->end(); ++iter) {
57 int command_modifiers =
58 iter->second.accelerator().modifiers() & ui::EF_ALL_MODIFIERS;
51 if (iter->second.accelerator().key_code() == key_event.key_code() && 59 if (iter->second.accelerator().key_code() == key_event.key_code() &&
52 iter->second.accelerator().modifiers() == key_event.flags()) 60 command_modifiers == modifiers)
53 command_name = iter->second.command_name(); 61 command_name = iter->second.command_name();
54 } 62 }
55 63
56 if (command_name.empty()) 64 if (command_name.empty())
57 return ui::EVENT_REWRITE_CONTINUE; 65 return ui::EVENT_REWRITE_CONTINUE;
58 66
59 scoped_ptr<base::ListValue> args(new base::ListValue()); 67 scoped_ptr<base::ListValue> args(new base::ListValue());
60 args->Append(new base::StringValue(command_name)); 68 args->Append(new base::StringValue(command_name));
61 69
62 scoped_ptr<extensions::Event> extension_event( 70 scoped_ptr<extensions::Event> extension_event(
63 new extensions::Event("commands.onCommand", args.Pass())); 71 new extensions::Event("commands.onCommand", args.Pass()));
64 extension_event->restrict_to_browser_context = context; 72 extension_event->restrict_to_browser_context = context;
65 73
66 extensions::EventRouter::Get(context)->DispatchEventToExtension( 74 event_router->DispatchEventToExtension(extension_misc::kChromeVoxExtensionId,
67 extension_misc::kChromeVoxExtensionId, extension_event.Pass()); 75 extension_event.Pass());
68 76
69 return ui::EVENT_REWRITE_DISCARD; 77 return ui::EVENT_REWRITE_DISCARD;
70 } 78 }
71 79
72 ui::EventRewriteStatus SpokenFeedbackEventRewriter::NextDispatchEvent( 80 ui::EventRewriteStatus SpokenFeedbackEventRewriter::NextDispatchEvent(
73 const ui::Event& last_event, 81 const ui::Event& last_event,
74 scoped_ptr<ui::Event>* new_event) { 82 scoped_ptr<ui::Event>* new_event) {
75 return ui::EVENT_REWRITE_CONTINUE; 83 return ui::EVENT_REWRITE_CONTINUE;
76 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698