Chromium Code Reviews| 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(); | 76 if (entry == accel_map_.end()) |
| 72 } else { | |
| 73 return false; | 77 return false; |
| 78 | |
| 79 WebUI* web_ui = webui_login_ ? webui_login_->tab_contents()->web_ui() : NULL; | |
| 80 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
| |
| 81 base::StringValue accel_name(entry->second); | |
| 82 web_ui->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | |
| 83 accel_name); | |
| 74 } | 84 } |
| 85 | |
| 75 return true; | 86 return true; |
| 76 } | 87 } |
| 77 | 88 |
| 78 gfx::NativeWindow WebUILoginView::GetNativeWindow() const { | 89 gfx::NativeWindow WebUILoginView::GetNativeWindow() const { |
| 79 return GetWidget()->GetNativeWindow(); | 90 return GetWidget()->GetNativeWindow(); |
| 80 } | 91 } |
| 81 | 92 |
| 82 void WebUILoginView::OnWindowCreated() { | 93 void WebUILoginView::OnWindowCreated() { |
| 83 InitStatusArea(); | 94 InitStatusArea(); |
| 84 } | 95 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 | 215 |
| 205 bool WebUILoginView::HandleContextMenu(const ContextMenuParams& params) { | 216 bool WebUILoginView::HandleContextMenu(const ContextMenuParams& params) { |
| 206 // Do not show the context menu. | 217 // Do not show the context menu. |
| 207 #ifndef NDEBUG | 218 #ifndef NDEBUG |
| 208 return false; | 219 return false; |
| 209 #else | 220 #else |
| 210 return true; | 221 return true; |
| 211 #endif | 222 #endif |
| 212 } | 223 } |
| 213 | 224 |
| 225 void WebUILoginView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | |
| 226 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | |
| 227 GetFocusManager()); | |
| 228 } | |
| 229 | |
| 214 } // namespace chromeos | 230 } // namespace chromeos |
| OLD | NEW |