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

Unified Diff: chrome/browser/chromeos/login/webui_login_view.cc

Issue 7550043: CrOS OOBE: Grab accelerators in native code instead of JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/login/webui_login_view.h ('k') | chrome/browser/resources/chromeos/login/oobe.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/webui_login_view.cc
diff --git a/chrome/browser/chromeos/login/webui_login_view.cc b/chrome/browser/chromeos/login/webui_login_view.cc
index 7b32f79ca52a1a724f57a309cbca40292990c70b..5091cb15285b2938ba7f0d64043f3e038707228c 100644
--- a/chrome/browser/chromeos/login/webui_login_view.cc
+++ b/chrome/browser/chromeos/login/webui_login_view.cc
@@ -23,6 +23,10 @@ namespace {
const char kViewClassName[] = "browser/chromeos/login/WebUILoginView";
+// These strings must be kept in sync with handleAccelerator() in oobe.js.
+const char kAccelNameAccessibility[] = "accessibility";
+const char kAccelNameEnrollment[] = "enrollment";
+
} // namespace
namespace chromeos {
@@ -36,13 +40,14 @@ WebUILoginView::WebUILoginView()
: status_area_(NULL),
profile_(NULL),
webui_login_(NULL),
- status_window_(NULL),
- accel_toggle_accessibility_(
- views::Accelerator(ui::VKEY_Z, false, true, true)) {
- // Accelerator events will be sent to this window until the WebUI dialog gains
- // focus via keyboard or mouse input, so we have to watch for the
- // accessibility hotkey here as well.
- AddAccelerator(accel_toggle_accessibility_);
+ status_window_(NULL) {
+ accel_map_[views::Accelerator(ui::VKEY_Z, false, true, true)] =
+ kAccelNameAccessibility;
+ accel_map_[views::Accelerator(ui::VKEY_E, false, true, true)] =
+ kAccelNameEnrollment;
+
+ for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i)
+ AddAccelerator(i->first);
}
WebUILoginView::~WebUILoginView() {
@@ -67,11 +72,20 @@ std::string WebUILoginView::GetClassName() const {
bool WebUILoginView::AcceleratorPressed(
const views::Accelerator& accelerator) {
- if (accelerator == accel_toggle_accessibility_) {
- accessibility::ToggleAccessibility(GetWebUI());
- } else {
+ AccelMap::const_iterator entry = accel_map_.find(accelerator);
+ if (entry == accel_map_.end())
return false;
+
+ if (!webui_login_)
+ return true;
+
+ WebUI* web_ui = webui_login_->tab_contents()->web_ui();
+ if (web_ui) {
+ base::StringValue accel_name(entry->second);
+ web_ui->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator",
+ accel_name);
}
+
return true;
}
@@ -218,4 +232,9 @@ bool WebUILoginView::TakeFocus(bool reverse) {
return true;
}
+void WebUILoginView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
+ unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
+ GetFocusManager());
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/webui_login_view.h ('k') | chrome/browser/resources/chromeos/login/oobe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698