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" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/chromeos/accessibility_util.h" | 12 #include "chrome/browser/chromeos/accessibility_util.h" |
13 #include "chrome/browser/chromeos/cros/cros_library.h" | 13 #include "chrome/browser/chromeos/cros/cros_library.h" |
14 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 14 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
15 #include "chrome/browser/chromeos/dbus/session_manager_client.h" | 15 #include "chrome/browser/chromeos/dbus/session_manager_client.h" |
16 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" | 16 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
17 #include "chrome/browser/chromeos/login/webui_login_display.h" | 17 #include "chrome/browser/chromeos/login/webui_login_display.h" |
18 #include "chrome/browser/chromeos/status/clock_menu_button.h" | 18 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" |
19 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | |
20 #include "chrome/browser/chromeos/status/network_menu_button.h" | |
21 #include "chrome/browser/chromeos/status/status_area_view.h" | |
22 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/browser/ui/views/dom_view.h" | 20 #include "chrome/browser/ui/views/dom_view.h" |
24 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 21 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
25 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
26 #include "content/browser/renderer_host/render_view_host_observer.h" | 23 #include "content/browser/renderer_host/render_view_host_observer.h" |
27 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
28 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
29 #include "ui/gfx/size.h" | 26 #include "ui/gfx/size.h" |
30 #include "views/desktop/desktop_window_view.h" | 27 #include "views/desktop/desktop_window_view.h" |
31 #include "views/widget/widget.h" | 28 #include "views/widget/widget.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 void WebUILoginView::Layout() { | 223 void WebUILoginView::Layout() { |
227 DCHECK(webui_login_); | 224 DCHECK(webui_login_); |
228 webui_login_->SetBoundsRect(bounds()); | 225 webui_login_->SetBoundsRect(bounds()); |
229 } | 226 } |
230 | 227 |
231 void WebUILoginView::ChildPreferredSizeChanged(View* child) { | 228 void WebUILoginView::ChildPreferredSizeChanged(View* child) { |
232 Layout(); | 229 Layout(); |
233 SchedulePaint(); | 230 SchedulePaint(); |
234 } | 231 } |
235 | 232 |
236 Profile* WebUILoginView::GetProfile() const { | 233 // Overridden from StatusAreaButton::Delegate: |
237 return NULL; | 234 |
| 235 bool WebUILoginView::ShouldExecuteStatusAreaCommand( |
| 236 const views::View* button_view, int command_id) const { |
| 237 if (command_id == StatusAreaViewChromeos::SHOW_NETWORK_OPTIONS) |
| 238 return true; |
| 239 return false; |
238 } | 240 } |
239 | 241 |
240 void WebUILoginView::ExecuteBrowserCommand(int id) const { | 242 void WebUILoginView::ExecuteStatusAreaCommand( |
241 } | 243 const views::View* button_view, int command_id) { |
242 | 244 if (command_id == StatusAreaViewChromeos::SHOW_NETWORK_OPTIONS) { |
243 bool WebUILoginView::ShouldOpenButtonOptions( | |
244 const views::View* button_view) const { | |
245 if (button_view == status_area_->network_view()) | |
246 return true; | |
247 | |
248 if (button_view == status_area_->clock_view() || | |
249 button_view == status_area_->input_method_view()) | |
250 return false; | |
251 | |
252 return true; | |
253 } | |
254 | |
255 void WebUILoginView::OpenButtonOptions(const views::View* button_view) { | |
256 if (button_view == status_area_->network_view()) { | |
257 if (proxy_settings_dialog_.get() == NULL) { | 245 if (proxy_settings_dialog_.get() == NULL) { |
258 proxy_settings_dialog_.reset(new ProxySettingsDialog( | 246 proxy_settings_dialog_.reset(new ProxySettingsDialog( |
259 this, GetNativeWindow())); | 247 this, GetNativeWindow())); |
260 } | 248 } |
261 proxy_settings_dialog_->Show(); | 249 proxy_settings_dialog_->Show(); |
262 } | 250 } |
263 } | 251 } |
264 | 252 |
265 StatusAreaHost::ScreenMode WebUILoginView::GetScreenMode() const { | 253 gfx::Font WebUILoginView::GetStatusAreaFont(const gfx::Font& font) const { |
266 return kWebUILoginMode; | 254 return font; |
267 } | 255 } |
268 | 256 |
269 StatusAreaHost::TextStyle WebUILoginView::GetTextStyle() const { | 257 StatusAreaButton::TextStyle WebUILoginView::GetStatusAreaTextStyle() const { |
270 return kGrayPlain; | 258 return StatusAreaButton::GRAY_PLAIN; |
271 } | 259 } |
272 | 260 |
273 void WebUILoginView::ButtonVisibilityChanged(views::View* button_view) { | 261 void WebUILoginView::ButtonVisibilityChanged(views::View* button_view) { |
274 status_area_->ButtonVisibilityChanged(button_view); | 262 status_area_->UpdateButtonVisibility(); |
275 } | 263 } |
276 | 264 |
| 265 // Overridden from LoginHtmlDialog::Delegate: |
| 266 |
277 void WebUILoginView::OnDialogClosed() { | 267 void WebUILoginView::OnDialogClosed() { |
278 } | 268 } |
279 | 269 |
280 void WebUILoginView::OnLocaleChanged() { | 270 void WebUILoginView::OnLocaleChanged() { |
281 // Proxy settings dialog contains localized strings. | 271 // Proxy settings dialog contains localized strings. |
282 proxy_settings_dialog_.reset(); | 272 proxy_settings_dialog_.reset(); |
283 SchedulePaint(); | 273 SchedulePaint(); |
284 } | 274 } |
285 | 275 |
286 void WebUILoginView::OnRenderHostCreated(RenderViewHost* host) { | 276 void WebUILoginView::OnRenderHostCreated(RenderViewHost* host) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 317 |
328 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()); | 318 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()); |
329 // Notify OOBE that the login frame has been rendered. Currently | 319 // Notify OOBE that the login frame has been rendered. Currently |
330 // this is used to start camera presence check. | 320 // this is used to start camera presence check. |
331 oobe_ui->OnLoginPromptVisible(); | 321 oobe_ui->OnLoginPromptVisible(); |
332 } | 322 } |
333 | 323 |
334 void WebUILoginView::InitStatusArea() { | 324 void WebUILoginView::InitStatusArea() { |
335 DCHECK(status_area_ == NULL); | 325 DCHECK(status_area_ == NULL); |
336 DCHECK(status_window_ == NULL); | 326 DCHECK(status_window_ == NULL); |
337 status_area_ = new StatusAreaView(this); | 327 status_area_ = new StatusAreaViewChromeos(); |
338 status_area_->Init(); | 328 status_area_->Init(this, StatusAreaViewChromeos::LOGIN_MODE_WEBUI); |
339 status_area_->SetVisible(status_area_visibility_on_init_); | 329 status_area_->SetVisible(status_area_visibility_on_init_); |
340 | 330 |
341 // Width of |status_window| is meant to be large enough. | 331 // Width of |status_window| is meant to be large enough. |
342 // The current value of status_area_->GetPreferredSize().width() | 332 // The current value of status_area_->GetPreferredSize().width() |
343 // will be too small when button status is changed. | 333 // will be too small when button status is changed. |
344 // (e.g. when CapsLock indicator appears) | 334 // (e.g. when CapsLock indicator appears) |
345 gfx::Size widget_size(width()/2, | 335 gfx::Size widget_size(width()/2, |
346 status_area_->GetPreferredSize().height()); | 336 status_area_->GetPreferredSize().height()); |
347 const int widget_x = base::i18n::IsRTL() ? | 337 const int widget_x = base::i18n::IsRTL() ? |
348 kStatusAreaCornerPadding : | 338 kStatusAreaCornerPadding : |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 GetFocusManager()); | 406 GetFocusManager()); |
417 | 407 |
418 // Make sure error bubble is cleared on keyboard event. This is needed | 408 // Make sure error bubble is cleared on keyboard event. This is needed |
419 // when the focus is inside an iframe. | 409 // when the focus is inside an iframe. |
420 WebUI* web_ui = GetWebUI(); | 410 WebUI* web_ui = GetWebUI(); |
421 if (web_ui) | 411 if (web_ui) |
422 web_ui->CallJavascriptFunction("cr.ui.Oobe.clearErrors"); | 412 web_ui->CallJavascriptFunction("cr.ui.Oobe.clearErrors"); |
423 } | 413 } |
424 | 414 |
425 } // namespace chromeos | 415 } // namespace chromeos |
OLD | NEW |