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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 namespace chromeos { | 106 namespace chromeos { |
107 | 107 |
108 // static | 108 // static |
109 const int WebUILoginView::kStatusAreaCornerPadding = 5; | 109 const int WebUILoginView::kStatusAreaCornerPadding = 5; |
110 | 110 |
111 // WebUILoginView public: ------------------------------------------------------ | 111 // WebUILoginView public: ------------------------------------------------------ |
112 | 112 |
113 WebUILoginView::WebUILoginView() | 113 WebUILoginView::WebUILoginView() |
114 : status_area_(NULL), | 114 : status_area_(NULL), |
115 webui_login_(NULL), | 115 webui_login_(NULL), |
| 116 login_window_(NULL), |
116 status_window_(NULL), | 117 status_window_(NULL), |
117 host_window_frozen_(false), | 118 host_window_frozen_(false), |
118 status_area_visibility_on_init_(true) { | 119 status_area_visibility_on_init_(true) { |
119 #if defined(USE_VIRTUAL_KEYBOARD) | 120 #if defined(USE_VIRTUAL_KEYBOARD) |
120 // Make sure the singleton VirtualKeyboardManager object is created. | 121 // Make sure the singleton VirtualKeyboardManager object is created. |
121 VirtualKeyboardManager::GetInstance(); | 122 VirtualKeyboardManager::GetInstance(); |
122 #endif | 123 #endif |
123 accel_map_[views::Accelerator(ui::VKEY_Z, false, true, true)] = | 124 accel_map_[views::Accelerator(ui::VKEY_Z, false, true, true)] = |
124 kAccelNameAccessibility; | 125 kAccelNameAccessibility; |
125 accel_map_[views::Accelerator(ui::VKEY_ESCAPE, false, false, false)] = | 126 accel_map_[views::Accelerator(ui::VKEY_ESCAPE, false, false, false)] = |
126 kAccelNameCancel; | 127 kAccelNameCancel; |
127 accel_map_[views::Accelerator(ui::VKEY_E, false, true, true)] = | 128 accel_map_[views::Accelerator(ui::VKEY_E, false, true, true)] = |
128 kAccelNameEnrollment; | 129 kAccelNameEnrollment; |
129 | 130 |
130 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) | 131 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) |
131 AddAccelerator(i->first); | 132 AddAccelerator(i->first); |
132 } | 133 } |
133 | 134 |
134 WebUILoginView::~WebUILoginView() { | 135 WebUILoginView::~WebUILoginView() { |
135 if (status_window_) | 136 if (status_window_) |
136 status_window_->CloseNow(); | 137 status_window_->CloseNow(); |
137 status_window_ = NULL; | 138 status_window_ = NULL; |
138 } | 139 } |
139 | 140 |
140 void WebUILoginView::Init() { | 141 void WebUILoginView::Init(views::Widget* login_window) { |
141 | 142 login_window_ = login_window; |
142 webui_login_ = new DOMView(); | 143 webui_login_ = new DOMView(); |
143 AddChildView(webui_login_); | 144 AddChildView(webui_login_); |
144 webui_login_->Init(ProfileManager::GetDefaultProfile(), NULL); | 145 webui_login_->Init(ProfileManager::GetDefaultProfile(), NULL); |
145 webui_login_->SetVisible(true); | 146 webui_login_->SetVisible(true); |
146 | 147 |
147 TabContents* tab_contents = webui_login_->dom_contents()->tab_contents(); | 148 TabContents* tab_contents = webui_login_->dom_contents()->tab_contents(); |
148 tab_contents->set_delegate(this); | 149 tab_contents->set_delegate(this); |
149 | 150 |
150 tab_watcher_.reset(new TabFirstRenderWatcher(tab_contents, this)); | 151 tab_watcher_.reset(new TabFirstRenderWatcher(tab_contents, this)); |
151 } | 152 } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 oobe_ui->OnLoginPromptVisible(); | 331 oobe_ui->OnLoginPromptVisible(); |
331 } | 332 } |
332 | 333 |
333 void WebUILoginView::InitStatusArea() { | 334 void WebUILoginView::InitStatusArea() { |
334 DCHECK(status_area_ == NULL); | 335 DCHECK(status_area_ == NULL); |
335 DCHECK(status_window_ == NULL); | 336 DCHECK(status_window_ == NULL); |
336 status_area_ = new StatusAreaView(this); | 337 status_area_ = new StatusAreaView(this); |
337 status_area_->Init(); | 338 status_area_->Init(); |
338 status_area_->SetVisible(status_area_visibility_on_init_); | 339 status_area_->SetVisible(status_area_visibility_on_init_); |
339 | 340 |
340 views::Widget* login_window = GetLoginWindow(); | |
341 // Width of |status_window| is meant to be large enough. | 341 // Width of |status_window| is meant to be large enough. |
342 // The current value of status_area_->GetPreferredSize().width() | 342 // The current value of status_area_->GetPreferredSize().width() |
343 // will be too small when button status is changed. | 343 // will be too small when button status is changed. |
344 // (e.g. when CapsLock indicator appears) | 344 // (e.g. when CapsLock indicator appears) |
345 gfx::Size widget_size(width()/2, | 345 gfx::Size widget_size(width()/2, |
346 status_area_->GetPreferredSize().height()); | 346 status_area_->GetPreferredSize().height()); |
347 const int widget_x = base::i18n::IsRTL() ? | 347 const int widget_x = base::i18n::IsRTL() ? |
348 kStatusAreaCornerPadding : | 348 kStatusAreaCornerPadding : |
349 width() - widget_size.width() - kStatusAreaCornerPadding; | 349 width() - widget_size.width() - kStatusAreaCornerPadding; |
350 gfx::Rect widget_bounds(widget_x, kStatusAreaCornerPadding, | 350 gfx::Rect widget_bounds(widget_x, kStatusAreaCornerPadding, |
351 widget_size.width(), widget_size.height()); | 351 widget_size.width(), widget_size.height()); |
352 #if defined(TOUCH_UI) | 352 #if defined(TOUCH_UI) |
353 views::Widget::InitParams widget_params( | 353 views::Widget::InitParams widget_params( |
354 views::Widget::InitParams::TYPE_CONTROL); | 354 views::Widget::InitParams::TYPE_CONTROL); |
355 #else | 355 #else |
356 // TODO(nkostylev|oshima): Make status area in the same window as | 356 // TODO(nkostylev|oshima): Make status area in the same window as |
357 // |webui_login_| once RenderWidgetHostViewViews and compositor are | 357 // |webui_login_| once RenderWidgetHostViewViews and compositor are |
358 // ready. | 358 // ready. |
359 views::Widget::InitParams widget_params( | 359 views::Widget::InitParams widget_params( |
360 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 360 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
361 #endif | 361 #endif |
362 widget_params.bounds = widget_bounds; | 362 widget_params.bounds = widget_bounds; |
363 widget_params.transparent = true; | 363 widget_params.transparent = true; |
364 widget_params.parent_widget = login_window; | 364 widget_params.parent_widget = login_window_; |
365 status_window_ = new views::Widget; | 365 status_window_ = new views::Widget; |
366 status_window_->Init(widget_params); | 366 status_window_->Init(widget_params); |
367 | 367 |
368 #if defined(TOOLKIT_USES_GTK) | 368 #if defined(TOOLKIT_USES_GTK) |
369 chromeos::WmIpc::instance()->SetWindowType( | 369 chromeos::WmIpc::instance()->SetWindowType( |
370 status_window_->GetNativeView(), | 370 status_window_->GetNativeView(), |
371 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, | 371 chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, |
372 NULL); | 372 NULL); |
373 #endif | 373 #endif |
374 | 374 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 415 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
416 GetFocusManager()); | 416 GetFocusManager()); |
417 | 417 |
418 // Make sure error bubble is cleared on keyboard event. This is needed | 418 // Make sure error bubble is cleared on keyboard event. This is needed |
419 // when the focus is inside an iframe. | 419 // when the focus is inside an iframe. |
420 WebUI* web_ui = GetWebUI(); | 420 WebUI* web_ui = GetWebUI(); |
421 if (web_ui) | 421 if (web_ui) |
422 web_ui->CallJavascriptFunction("cr.ui.Oobe.clearErrors"); | 422 web_ui->CallJavascriptFunction("cr.ui.Oobe.clearErrors"); |
423 } | 423 } |
424 | 424 |
425 views::Widget* WebUILoginView::GetLoginWindow() { | |
426 return WebUILoginDisplay::GetLoginWindow(); | |
427 } | |
428 | |
429 } // namespace chromeos | 425 } // namespace chromeos |
OLD | NEW |