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

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: 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
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 ba055f91747c77a85aa17fd0db1d2db7960ca0ed..89d2cb3f97280260f54635590784419d785f4006 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,17 @@ std::string WebUILoginView::GetClassName() const {
bool WebUILoginView::AcceleratorPressed(
const views::Accelerator& accelerator) {
- if (accelerator == accel_toggle_accessibility_) {
- accessibility::ToggleAccessibility();
- } else {
+ AccelMap::const_iterator entry = accel_map_.find(accelerator);
+ if (entry == accel_map_.end())
return false;
+
+ WebUI* web_ui = webui_login_ ? webui_login_->tab_contents()->web_ui() : NULL;
+ if (web_ui) {
whywhat 2011/08/08 08:09:08 Maybe change to: if (webui_login_) { WebUI* web_
Mattias Nissler (ping if slow) 2011/08/08 11:11:47 I put a webui_login_ NULL check with early return
+ base::StringValue accel_name(entry->second);
+ web_ui->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator",
+ accel_name);
}
+
return true;
}
@@ -211,4 +222,9 @@ bool WebUILoginView::HandleContextMenu(const ContextMenuParams& params) {
#endif
}
+void WebUILoginView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
+ unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
+ GetFocusManager());
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698