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

Side by Side Diff: chrome/browser/chromeos/login/webui_login_view.cc

Issue 10056001: chromeos: Remove old status-area related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 14 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
15 #include "chrome/browser/chromeos/cros/cros_library.h" 15 #include "chrome/browser/chromeos/cros/cros_library.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/status_area_view.h"
19 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" 19 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h"
21 #include "chrome/browser/ui/views/dom_view.h" 20 #include "chrome/browser/ui/views/dom_view.h"
22 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 21 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
23 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/render_messages.h" 23 #include "chrome/common/render_messages.h"
25 #include "chromeos/dbus/dbus_thread_manager.h" 24 #include "chromeos/dbus/dbus_thread_manager.h"
26 #include "chromeos/dbus/session_manager_client.h" 25 #include "chromeos/dbus/session_manager_client.h"
27 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/render_view_host_observer.h" 27 #include "content/public/browser/render_view_host_observer.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 100 }
102 101
103 void RightAlignedView::ChildPreferredSizeChanged(View* child) { 102 void RightAlignedView::ChildPreferredSizeChanged(View* child) {
104 Layout(); 103 Layout();
105 } 104 }
106 105
107 } // namespace 106 } // namespace
108 107
109 namespace chromeos { 108 namespace chromeos {
110 109
111 // static
112 const int WebUILoginView::kStatusAreaCornerPadding = 5;
113
114 // WebUILoginView public: ------------------------------------------------------ 110 // WebUILoginView public: ------------------------------------------------------
115 111
116 WebUILoginView::WebUILoginView() 112 WebUILoginView::WebUILoginView()
117 : status_area_(NULL), 113 : webui_login_(NULL),
118 webui_login_(NULL),
119 login_window_(NULL), 114 login_window_(NULL),
120 status_window_(NULL),
121 host_window_frozen_(false), 115 host_window_frozen_(false),
122 status_area_visibility_on_init_(true),
123 login_page_is_loaded_(false), 116 login_page_is_loaded_(false),
124 should_emit_login_prompt_visible_(true) { 117 should_emit_login_prompt_visible_(true) {
125 118
126 registrar_.Add(this, 119 registrar_.Add(this,
127 chrome::NOTIFICATION_LOGIN_WEBUI_READY, 120 chrome::NOTIFICATION_LOGIN_WEBUI_READY,
128 content::NotificationService::AllSources()); 121 content::NotificationService::AllSources());
129 registrar_.Add(this, 122 registrar_.Add(this,
130 chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED, 123 chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED,
131 content::NotificationService::AllSources()); 124 content::NotificationService::AllSources());
132 registrar_.Add(this, 125 registrar_.Add(this,
(...skipping 20 matching lines...) Expand all
153 kAccelNameVersion; 146 kAccelNameVersion;
154 147
155 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) 148 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i)
156 AddAccelerator(i->first); 149 AddAccelerator(i->first);
157 } 150 }
158 151
159 WebUILoginView::~WebUILoginView() { 152 WebUILoginView::~WebUILoginView() {
160 ash::SystemTray* tray = ash::Shell::GetInstance()->tray(); 153 ash::SystemTray* tray = ash::Shell::GetInstance()->tray();
161 if (tray) 154 if (tray)
162 tray->SetNextFocusableView(NULL); 155 tray->SetNextFocusableView(NULL);
163
164 if (status_window_)
165 status_window_->CloseNow();
166 status_window_ = NULL;
167 } 156 }
168 157
169 void WebUILoginView::Init(views::Widget* login_window) { 158 void WebUILoginView::Init(views::Widget* login_window) {
170 login_window_ = login_window; 159 login_window_ = login_window;
171 webui_login_ = new DOMView(); 160 webui_login_ = new DOMView();
172 AddChildView(webui_login_); 161 AddChildView(webui_login_);
173 webui_login_->Init(ProfileManager::GetDefaultProfile(), NULL); 162 webui_login_->Init(ProfileManager::GetDefaultProfile(), NULL);
174 webui_login_->SetVisible(true); 163 webui_login_->SetVisible(true);
175 164
176 WebContents* web_contents = webui_login_->dom_contents()->web_contents(); 165 WebContents* web_contents = webui_login_->dom_contents()->web_contents();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 content::WebUI* WebUILoginView::GetWebUI() { 209 content::WebUI* WebUILoginView::GetWebUI() {
221 return webui_login_->dom_contents()->web_contents()->GetWebUI(); 210 return webui_login_->dom_contents()->web_contents()->GetWebUI();
222 } 211 }
223 212
224 void WebUILoginView::OpenProxySettings() { 213 void WebUILoginView::OpenProxySettings() {
225 ProxySettingsDialog* dialog = 214 ProxySettingsDialog* dialog =
226 new ProxySettingsDialog(NULL, GetNativeWindow()); 215 new ProxySettingsDialog(NULL, GetNativeWindow());
227 dialog->Show(); 216 dialog->Show();
228 } 217 }
229 218
230 void WebUILoginView::SetStatusAreaEnabled(bool enable) {
231 if (status_area_)
232 status_area_->MakeButtonsActive(enable);
233 }
234
235 void WebUILoginView::SetStatusAreaVisible(bool visible) { 219 void WebUILoginView::SetStatusAreaVisible(bool visible) {
236 ash::SystemTray* tray = ash::Shell::GetInstance()->tray(); 220 ash::SystemTray* tray = ash::Shell::GetInstance()->tray();
237 if (tray) { 221 if (tray) {
238 if (visible) 222 if (visible)
239 tray->GetWidget()->Show(); 223 tray->GetWidget()->Show();
240 else 224 else
241 tray->GetWidget()->Hide(); 225 tray->GetWidget()->Hide();
242 } 226 }
243 if (status_area_)
244 status_area_->SetVisible(visible);
245 else
246 status_area_visibility_on_init_ = visible;
247 } 227 }
248 228
249 // WebUILoginView protected: --------------------------------------------------- 229 // WebUILoginView protected: ---------------------------------------------------
250 230
251 void WebUILoginView::Layout() { 231 void WebUILoginView::Layout() {
252 DCHECK(webui_login_); 232 DCHECK(webui_login_);
253 webui_login_->SetBoundsRect(bounds()); 233 webui_login_->SetBoundsRect(bounds());
254 } 234 }
255 235
256 void WebUILoginView::OnLocaleChanged() { 236 void WebUILoginView::OnLocaleChanged() {
257 } 237 }
258 238
259 void WebUILoginView::ChildPreferredSizeChanged(View* child) { 239 void WebUILoginView::ChildPreferredSizeChanged(View* child) {
260 Layout(); 240 Layout();
261 SchedulePaint(); 241 SchedulePaint();
262 } 242 }
263 243
264 void WebUILoginView::AboutToRequestFocusFromTabTraversal(bool reverse) { 244 void WebUILoginView::AboutToRequestFocusFromTabTraversal(bool reverse) {
265 // Return the focus to the web contents. 245 // Return the focus to the web contents.
266 webui_login_->dom_contents()->web_contents()-> 246 webui_login_->dom_contents()->web_contents()->
267 FocusThroughTabTraversal(reverse); 247 FocusThroughTabTraversal(reverse);
268 GetWidget()->Activate(); 248 GetWidget()->Activate();
269 } 249 }
270 250
271 // Overridden from StatusAreaButton::Delegate:
272
273 bool WebUILoginView::ShouldExecuteStatusAreaCommand(
274 const views::View* button_view, int command_id) const {
275 if (command_id == StatusAreaButton::Delegate::SHOW_NETWORK_OPTIONS)
276 return true;
277 return false;
278 }
279
280 void WebUILoginView::ExecuteStatusAreaCommand(
281 const views::View* button_view, int command_id) {
282 if (command_id == StatusAreaButton::Delegate::SHOW_NETWORK_OPTIONS)
283 OpenProxySettings();
284 }
285
286 StatusAreaButton::TextStyle WebUILoginView::GetStatusAreaTextStyle() const {
287 return StatusAreaButton::GRAY_PLAIN_LIGHT;
288 }
289
290 void WebUILoginView::ButtonVisibilityChanged(views::View* button_view) {
291 if (status_area_)
292 status_area_->UpdateButtonVisibility();
293 }
294
295 void WebUILoginView::OnRenderHostCreated(RenderViewHost* host) { 251 void WebUILoginView::OnRenderHostCreated(RenderViewHost* host) {
296 new SnifferObserver(host, GetWebUI()); 252 new SnifferObserver(host, GetWebUI());
297 } 253 }
298 254
299 void WebUILoginView::OnTabMainFrameLoaded() { 255 void WebUILoginView::OnTabMainFrameLoaded() {
300 VLOG(1) << "WebUI login main frame loaded."; 256 VLOG(1) << "WebUI login main frame loaded.";
301 } 257 }
302 258
303 void WebUILoginView::OnTabMainFrameRender() { 259 void WebUILoginView::OnTabMainFrameRender() {
304 if (!login_page_is_loaded_) 260 if (!login_page_is_loaded_)
305 return; 261 return;
306 262
307 VLOG(1) << "WebUI login main frame rendered."; 263 VLOG(1) << "WebUI login main frame rendered.";
308 tab_watcher_.reset(); 264 tab_watcher_.reset();
309 265
310 StatusAreaViewChromeos::SetScreenMode(GetScreenMode());
311 // In aura there's a global status area shown already.
312 status_area_ = ChromeShellDelegate::instance()->GetStatusArea();
313 status_area_->SetVisible(status_area_visibility_on_init_);
314
315 if (should_emit_login_prompt_visible_) { 266 if (should_emit_login_prompt_visible_) {
316 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> 267 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
317 EmitLoginPromptVisible(); 268 EmitLoginPromptVisible();
318 } 269 }
319 270
320 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController()); 271 OobeUI* oobe_ui = static_cast<OobeUI*>(GetWebUI()->GetController());
321 // Notify OOBE that the login frame has been rendered. Currently 272 // Notify OOBE that the login frame has been rendered. Currently
322 // this is used to start camera presence check. 273 // this is used to start camera presence check.
323 oobe_ui->OnLoginPromptVisible(); 274 oobe_ui->OnLoginPromptVisible();
324 } 275 }
325 276
326 void WebUILoginView::InitStatusArea() {
327 DCHECK(status_area_ == NULL);
328 DCHECK(status_window_ == NULL);
329 StatusAreaViewChromeos* status_area_chromeos = new StatusAreaViewChromeos();
330 status_area_chromeos->Init(this);
331 status_area_ = status_area_chromeos;
332 status_area_->SetVisible(status_area_visibility_on_init_);
333
334 // Width of |status_window| is meant to be large enough.
335 // The current value of status_area_->GetPreferredSize().width()
336 // will be too small when button status is changed.
337 // (e.g. when CapsLock indicator appears)
338 gfx::Size widget_size(width()/2,
339 status_area_->GetPreferredSize().height());
340 const int widget_x = base::i18n::IsRTL() ?
341 kStatusAreaCornerPadding :
342 width() - widget_size.width() - kStatusAreaCornerPadding;
343 gfx::Rect widget_bounds(widget_x, kStatusAreaCornerPadding,
344 widget_size.width(), widget_size.height());
345 // TODO(nkostylev|oshima): Make status area in the same window as
346 // |webui_login_| once RenderWidgetHostViewViews and compositor are
347 // ready. This will also avoid having to override the status area
348 // widget type for the lock screen.
349 views::Widget::InitParams widget_params(GetStatusAreaWidgetType());
350 widget_params.bounds = widget_bounds;
351 widget_params.transparent = true;
352 widget_params.parent_widget = login_window_;
353 status_window_ = new views::Widget;
354 status_window_->Init(widget_params);
355
356 views::View* contents_view = new RightAlignedView;
357 contents_view->AddChildView(status_area_);
358 status_window_->SetContentsView(contents_view);
359 status_window_->Show();
360 }
361
362 StatusAreaViewChromeos::ScreenMode WebUILoginView::GetScreenMode() {
363 return StatusAreaViewChromeos::LOGIN_MODE_WEBUI;
364 }
365
366 views::Widget::InitParams::Type WebUILoginView::GetStatusAreaWidgetType() {
367 return views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
368 }
369
370 void WebUILoginView::Observe(int type, 277 void WebUILoginView::Observe(int type,
371 const content::NotificationSource& source, 278 const content::NotificationSource& source,
372 const content::NotificationDetails& details) { 279 const content::NotificationDetails& details) {
373 switch (type) { 280 switch (type) {
374 case chrome::NOTIFICATION_LOGIN_WEBUI_READY: 281 case chrome::NOTIFICATION_LOGIN_WEBUI_READY:
375 case chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED: 282 case chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED:
376 case chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN: 283 case chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN:
377 case chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN: 284 case chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN:
378 login_page_is_loaded_ = true; 285 login_page_is_loaded_ = true;
379 break; 286 break;
(...skipping 26 matching lines...) Expand all
406 if (web_ui) 313 if (web_ui)
407 web_ui->CallJavascriptFunction("cr.ui.Oobe.clearErrors"); 314 web_ui->CallJavascriptFunction("cr.ui.Oobe.clearErrors");
408 } 315 }
409 } 316 }
410 317
411 bool WebUILoginView::IsPopupOrPanel(const WebContents* source) const { 318 bool WebUILoginView::IsPopupOrPanel(const WebContents* source) const {
412 return true; 319 return true;
413 } 320 }
414 321
415 bool WebUILoginView::TakeFocus(bool reverse) { 322 bool WebUILoginView::TakeFocus(bool reverse) {
416 if (status_area_ && status_area_->visible()) {
417 // Forward the focus to the status area.
418 base::Callback<void(bool)> return_focus_cb =
419 base::Bind(&WebUILoginView::ReturnFocus, base::Unretained(this));
420 status_area_->TakeFocus(reverse, return_focus_cb);
421 status_area_->GetWidget()->Activate();
422
423 ash::SystemTray* tray = ash::Shell::GetInstance()->tray();
424 if (tray)
425 tray->SetNextFocusableView(this);
426 }
427 return true; 323 return true;
428 } 324 }
429 325
430 void WebUILoginView::ReturnFocus(bool reverse) { 326 void WebUILoginView::ReturnFocus(bool reverse) {
431 // Return the focus to the web contents. 327 // Return the focus to the web contents.
432 webui_login_->dom_contents()->web_contents()-> 328 webui_login_->dom_contents()->web_contents()->
433 FocusThroughTabTraversal(reverse); 329 FocusThroughTabTraversal(reverse);
434 GetWidget()->Activate(); 330 GetWidget()->Activate();
435 } 331 }
436 332
437 } // namespace chromeos 333 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/webui_login_view.h ('k') | chrome/browser/chromeos/login/webui_screen_locker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698