OLD | NEW |
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/chromeos/login/webui_login_view.h" | 5 #include "chrome/browser/chromeos/login/webui_login_view.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/accessibility_util.h" | 7 #include "chrome/browser/chromeos/accessibility_util.h" |
8 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" | 8 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
9 #include "chrome/browser/chromeos/login/webui_login_display.h" | 9 #include "chrome/browser/chromeos/login/webui_login_display.h" |
10 #include "chrome/browser/chromeos/status/clock_menu_button.h" | 10 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
11 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | 11 #include "chrome/browser/chromeos/status/input_method_menu_button.h" |
12 #include "chrome/browser/chromeos/status/network_menu_button.h" | 12 #include "chrome/browser/chromeos/status/network_menu_button.h" |
13 #include "chrome/browser/chromeos/status/status_area_view.h" | 13 #include "chrome/browser/chromeos/status/status_area_view.h" |
14 #include "chrome/browser/chromeos/wm_ipc.h" | 14 #include "chrome/browser/chromeos/wm_ipc.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/browser/ui/views/dom_view.h" | 16 #include "chrome/browser/ui/views/dom_view.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
19 #include "ui/gfx/size.h" | 19 #include "ui/gfx/size.h" |
20 #include "views/widget/widget.h" | 20 #include "views/widget/widget.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const char kViewClassName[] = "browser/chromeos/login/WebUILoginView"; | 24 const char kViewClassName[] = "browser/chromeos/login/WebUILoginView"; |
25 | 25 |
| 26 // These strings must be kept in sync with handleAccelerator() in oobe.js. |
| 27 const char kAccelNameAccessibility[] = "accessibility"; |
| 28 const char kAccelNameEnrollment[] = "enrollment"; |
| 29 |
26 } // namespace | 30 } // namespace |
27 | 31 |
28 namespace chromeos { | 32 namespace chromeos { |
29 | 33 |
30 // static | 34 // static |
31 const int WebUILoginView::kStatusAreaCornerPadding = 5; | 35 const int WebUILoginView::kStatusAreaCornerPadding = 5; |
32 | 36 |
33 // WebUILoginView public: ------------------------------------------------------ | 37 // WebUILoginView public: ------------------------------------------------------ |
34 | 38 |
35 WebUILoginView::WebUILoginView() | 39 WebUILoginView::WebUILoginView() |
36 : status_area_(NULL), | 40 : status_area_(NULL), |
37 profile_(NULL), | 41 profile_(NULL), |
38 webui_login_(NULL), | 42 webui_login_(NULL), |
39 status_window_(NULL), | 43 status_window_(NULL) { |
40 accel_toggle_accessibility_( | 44 accel_map_[views::Accelerator(ui::VKEY_Z, false, true, true)] = |
41 views::Accelerator(ui::VKEY_Z, false, true, true)) { | 45 kAccelNameAccessibility; |
42 // Accelerator events will be sent to this window until the WebUI dialog gains | 46 accel_map_[views::Accelerator(ui::VKEY_E, false, true, true)] = |
43 // focus via keyboard or mouse input, so we have to watch for the | 47 kAccelNameEnrollment; |
44 // accessibility hotkey here as well. | 48 |
45 AddAccelerator(accel_toggle_accessibility_); | 49 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) |
| 50 AddAccelerator(i->first); |
46 } | 51 } |
47 | 52 |
48 WebUILoginView::~WebUILoginView() { | 53 WebUILoginView::~WebUILoginView() { |
49 if (status_window_) | 54 if (status_window_) |
50 status_window_->Close(); | 55 status_window_->Close(); |
51 status_window_ = NULL; | 56 status_window_ = NULL; |
52 } | 57 } |
53 | 58 |
54 void WebUILoginView::Init() { | 59 void WebUILoginView::Init() { |
55 profile_ = ProfileManager::GetDefaultProfile(); | 60 profile_ = ProfileManager::GetDefaultProfile(); |
56 | 61 |
57 webui_login_ = new DOMView(); | 62 webui_login_ = new DOMView(); |
58 AddChildView(webui_login_); | 63 AddChildView(webui_login_); |
59 webui_login_->Init(profile_, NULL); | 64 webui_login_->Init(profile_, NULL); |
60 webui_login_->SetVisible(true); | 65 webui_login_->SetVisible(true); |
61 webui_login_->tab_contents()->set_delegate(this); | 66 webui_login_->tab_contents()->set_delegate(this); |
62 } | 67 } |
63 | 68 |
64 std::string WebUILoginView::GetClassName() const { | 69 std::string WebUILoginView::GetClassName() const { |
65 return kViewClassName; | 70 return kViewClassName; |
66 } | 71 } |
67 | 72 |
68 bool WebUILoginView::AcceleratorPressed( | 73 bool WebUILoginView::AcceleratorPressed( |
69 const views::Accelerator& accelerator) { | 74 const views::Accelerator& accelerator) { |
70 if (accelerator == accel_toggle_accessibility_) { | 75 AccelMap::const_iterator entry = accel_map_.find(accelerator); |
71 accessibility::ToggleAccessibility(GetWebUI()); | 76 if (entry == accel_map_.end()) |
72 } else { | |
73 return false; | 77 return false; |
| 78 |
| 79 if (!webui_login_) |
| 80 return true; |
| 81 |
| 82 WebUI* web_ui = webui_login_->tab_contents()->web_ui(); |
| 83 if (web_ui) { |
| 84 base::StringValue accel_name(entry->second); |
| 85 web_ui->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
| 86 accel_name); |
74 } | 87 } |
| 88 |
75 return true; | 89 return true; |
76 } | 90 } |
77 | 91 |
78 gfx::NativeWindow WebUILoginView::GetNativeWindow() const { | 92 gfx::NativeWindow WebUILoginView::GetNativeWindow() const { |
79 return GetWidget()->GetNativeWindow(); | 93 return GetWidget()->GetNativeWindow(); |
80 } | 94 } |
81 | 95 |
82 void WebUILoginView::OnWindowCreated() { | 96 void WebUILoginView::OnWindowCreated() { |
83 InitStatusArea(); | 97 InitStatusArea(); |
84 } | 98 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 return true; | 225 return true; |
212 #endif | 226 #endif |
213 } | 227 } |
214 | 228 |
215 bool WebUILoginView::TakeFocus(bool reverse) { | 229 bool WebUILoginView::TakeFocus(bool reverse) { |
216 // Forward the focus back to web contents. | 230 // Forward the focus back to web contents. |
217 webui_login_->tab_contents()->FocusThroughTabTraversal(reverse); | 231 webui_login_->tab_contents()->FocusThroughTabTraversal(reverse); |
218 return true; | 232 return true; |
219 } | 233 } |
220 | 234 |
| 235 void WebUILoginView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 236 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
| 237 GetFocusManager()); |
| 238 } |
| 239 |
221 } // namespace chromeos | 240 } // namespace chromeos |
OLD | NEW |