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

Side by Side Diff: ash/system/status_area_widget.cc

Issue 10836227: Fix status area accessability issues. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 8 years, 4 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
« no previous file with comments | « ash/system/status_area_widget.h ('k') | ash/system/status_area_widget_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/system/status_area_widget.h" 5 #include "ash/system/status_area_widget.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_delegate.h" 9 #include "ash/shell_delegate.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
11 #include "ash/system/bluetooth/bluetooth_observer.h" 11 #include "ash/system/bluetooth/bluetooth_observer.h"
12 #include "ash/system/network/network_observer.h" 12 #include "ash/system/network/network_observer.h"
13 #include "ash/system/status_area_widget_delegate.h" 13 #include "ash/system/status_area_widget_delegate.h"
14 #include "ash/system/tray/system_tray.h" 14 #include "ash/system/tray/system_tray.h"
15 #include "ash/system/tray/system_tray_delegate.h" 15 #include "ash/system/tray/system_tray_delegate.h"
16 #include "ash/system/web_notification/web_notification_tray.h" 16 #include "ash/system/web_notification/web_notification_tray.h"
17 #include "ash/volume_control_delegate.h" 17 #include "ash/volume_control_delegate.h"
18 #include "ash/wm/shelf_layout_manager.h"
18 #include "base/i18n/time_formatting.h" 19 #include "base/i18n/time_formatting.h"
19 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
20 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/gfx/screen.h"
21 23
22 namespace ash { 24 namespace ash {
23 25
24 namespace { 26 namespace {
25 27
26 class DummyVolumeControlDelegate : public VolumeControlDelegate { 28 class DummyVolumeControlDelegate : public VolumeControlDelegate {
27 public: 29 public:
28 DummyVolumeControlDelegate() {} 30 DummyVolumeControlDelegate() {}
29 virtual ~DummyVolumeControlDelegate() {} 31 virtual ~DummyVolumeControlDelegate() {}
30 32
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 }; 299 };
298 300
299 } // namespace 301 } // namespace
300 302
301 namespace internal { 303 namespace internal {
302 304
303 StatusAreaWidget::StatusAreaWidget() 305 StatusAreaWidget::StatusAreaWidget()
304 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), 306 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate),
305 system_tray_(NULL), 307 system_tray_(NULL),
306 web_notification_tray_(NULL), 308 web_notification_tray_(NULL),
307 login_status_(user::LOGGED_IN_NONE) { 309 login_status_(user::LOGGED_IN_NONE),
310 should_show_launcher_(false) {
308 views::Widget::InitParams params( 311 views::Widget::InitParams params(
309 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 312 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
310 params.delegate = status_area_widget_delegate_; 313 params.delegate = status_area_widget_delegate_;
311 params.parent = 314 params.parent =
312 Shell::GetPrimaryRootWindowController()->GetContainer( 315 Shell::GetPrimaryRootWindowController()->GetContainer(
313 ash::internal::kShellWindowId_StatusContainer); 316 ash::internal::kShellWindowId_StatusContainer);
314 params.transparent = true; 317 params.transparent = true;
315 Init(params); 318 Init(params);
316 set_focus_on_creation(false); 319 set_focus_on_creation(false);
317 SetContentsView(status_area_widget_delegate_); 320 SetContentsView(status_area_widget_delegate_);
318 GetNativeView()->SetName("StatusAreaWidget"); 321 GetNativeView()->SetName("StatusAreaWidget");
319 } 322 }
320 323
321 StatusAreaWidget::~StatusAreaWidget() { 324 StatusAreaWidget::~StatusAreaWidget() {
322 } 325 }
323 326
324 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) { 327 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) {
328 AddSystemTray(shell_delegate);
325 AddWebNotificationTray(); 329 AddWebNotificationTray();
326 AddSystemTray(shell_delegate); 330 // Initialize() must be called after all trays have been created.
327 // SetBorder() must be called after all trays have been created. 331 if (system_tray_)
328 web_notification_tray_->SetBorder(); 332 system_tray_->Initialize();
329 system_tray_->SetBorder(); 333 if (web_notification_tray_)
334 web_notification_tray_->Initialize();
335 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus());
330 } 336 }
331 337
332 void StatusAreaWidget::Shutdown() { 338 void StatusAreaWidget::Shutdown() {
333 // Destroy the trays early, causing them to be removed from the view 339 // Destroy the trays early, causing them to be removed from the view
334 // hierarchy. Do not used scoped pointers since we don't want to destroy them 340 // hierarchy. Do not used scoped pointers since we don't want to destroy them
335 // in the destructor if Shutdown() is not called (e.g. in tests). 341 // in the destructor if Shutdown() is not called (e.g. in tests).
336 system_tray_delegate_.reset(); 342 system_tray_delegate_.reset();
337 delete system_tray_; 343 delete system_tray_;
338 system_tray_ = NULL; 344 system_tray_ = NULL;
339 delete web_notification_tray_; 345 delete web_notification_tray_;
340 web_notification_tray_ = NULL; 346 web_notification_tray_ = NULL;
341 } 347 }
342 348
343 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) { 349 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) {
344 system_tray_ = new SystemTray(this); 350 system_tray_ = new SystemTray(this);
345 status_area_widget_delegate_->AddTray(system_tray_); 351 status_area_widget_delegate_->AddTray(system_tray_);
346 system_tray_->Initialize(); // Called after added to widget.
347 352
348 if (shell_delegate) { 353 if (shell_delegate) {
349 system_tray_delegate_.reset( 354 system_tray_delegate_.reset(
350 shell_delegate->CreateSystemTrayDelegate(system_tray_)); 355 shell_delegate->CreateSystemTrayDelegate(system_tray_));
351 } 356 }
352 if (!system_tray_delegate_.get()) 357 if (!system_tray_delegate_.get())
353 system_tray_delegate_.reset(new DummySystemTrayDelegate()); 358 system_tray_delegate_.reset(new DummySystemTrayDelegate());
354
355 system_tray_->CreateItems(); // Called after delegate is created.
356 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus());
357 } 359 }
358 360
359 void StatusAreaWidget::AddWebNotificationTray() { 361 void StatusAreaWidget::AddWebNotificationTray() {
360 web_notification_tray_ = new WebNotificationTray(this); 362 web_notification_tray_ = new WebNotificationTray(this);
361 status_area_widget_delegate_->AddTray(web_notification_tray_); 363 status_area_widget_delegate_->AddTray(web_notification_tray_);
362 } 364 }
363 365
364 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { 366 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
365 status_area_widget_delegate_->set_alignment(alignment); 367 status_area_widget_delegate_->set_alignment(alignment);
366 if (system_tray_) 368 if (system_tray_)
(...skipping 30 matching lines...) Expand all
397 user::LoginStatus login_status) { 399 user::LoginStatus login_status) {
398 if (login_status_ == login_status) 400 if (login_status_ == login_status)
399 return; 401 return;
400 login_status_ = login_status; 402 login_status_ = login_status;
401 if (system_tray_) 403 if (system_tray_)
402 system_tray_->UpdateAfterLoginStatusChange(login_status); 404 system_tray_->UpdateAfterLoginStatusChange(login_status);
403 if (web_notification_tray_) 405 if (web_notification_tray_)
404 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 406 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
405 } 407 }
406 408
409 void StatusAreaWidget::UpdateShouldShowLauncher() {
410 bool should_show_launcher =
411 (system_tray_ && system_tray_->IsSystemBubbleVisible()) ||
412 (web_notification_tray_ &&
413 web_notification_tray_->IsMessageCenterBubbleVisible());
414 if (!should_show_launcher && Shell::GetInstance()->shelf()->IsVisible()) {
415 // If the launcher is currently visible, don't hide the launcher
416 // if the mouse is in this widget or in any notification bubbles.
417 should_show_launcher =
418 (GetWindowBoundsInScreen().Contains(
419 gfx::Screen::GetCursorScreenPoint())) ||
420 (system_tray_ && system_tray_->IsMouseInNotificationBubble()) ||
421 (web_notification_tray_ &&
422 web_notification_tray_->IsMouseInNotificationBubble());
423 }
424 if (should_show_launcher != should_show_launcher_) {
425 should_show_launcher_ = should_show_launcher;
426 Shell::GetInstance()->shelf()->UpdateAutoHideState();
427 }
428 }
429
407 } // namespace internal 430 } // namespace internal
408 } // namespace ash 431 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/status_area_widget.h ('k') | ash/system/status_area_widget_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698