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

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: 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
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/wm/shelf_layout_manager.h"
17 #include "base/i18n/time_formatting.h" 18 #include "base/i18n/time_formatting.h"
18 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
19 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
21 #include "ui/gfx/screen.h"
20 22
21 namespace ash { 23 namespace ash {
22 24
23 namespace { 25 namespace {
24 26
25 class DummySystemTrayDelegate : public SystemTrayDelegate { 27 class DummySystemTrayDelegate : public SystemTrayDelegate {
26 public: 28 public:
27 DummySystemTrayDelegate() 29 DummySystemTrayDelegate()
28 : muted_(false), 30 : muted_(false),
29 wifi_enabled_(true), 31 wifi_enabled_(true),
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 }; 274 };
273 275
274 } // namespace 276 } // namespace
275 277
276 namespace internal { 278 namespace internal {
277 279
278 StatusAreaWidget::StatusAreaWidget() 280 StatusAreaWidget::StatusAreaWidget()
279 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), 281 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate),
280 system_tray_(NULL), 282 system_tray_(NULL),
281 web_notification_tray_(NULL), 283 web_notification_tray_(NULL),
282 login_status_(user::LOGGED_IN_NONE) { 284 login_status_(user::LOGGED_IN_NONE),
285 should_show_launcher_(false) {
283 views::Widget::InitParams params( 286 views::Widget::InitParams params(
284 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 287 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
285 params.delegate = status_area_widget_delegate_; 288 params.delegate = status_area_widget_delegate_;
286 params.parent = 289 params.parent =
287 Shell::GetPrimaryRootWindowController()->GetContainer( 290 Shell::GetPrimaryRootWindowController()->GetContainer(
288 ash::internal::kShellWindowId_StatusContainer); 291 ash::internal::kShellWindowId_StatusContainer);
289 params.transparent = true; 292 params.transparent = true;
290 Init(params); 293 Init(params);
291 set_focus_on_creation(false); 294 set_focus_on_creation(false);
292 SetContentsView(status_area_widget_delegate_); 295 SetContentsView(status_area_widget_delegate_);
293 GetNativeView()->SetName("StatusAreaWidget"); 296 GetNativeView()->SetName("StatusAreaWidget");
294 } 297 }
295 298
296 StatusAreaWidget::~StatusAreaWidget() { 299 StatusAreaWidget::~StatusAreaWidget() {
297 } 300 }
298 301
299 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) { 302 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) {
303 AddSystemTray(shell_delegate);
300 AddWebNotificationTray(); 304 AddWebNotificationTray();
301 AddSystemTray(shell_delegate); 305 // Initialize() must be called after all trays have been created.
302 // SetBorder() must be called after all trays have been created. 306 if (system_tray_) {
303 web_notification_tray_->SetBorder(); 307 system_tray_->Initialize();
304 system_tray_->SetBorder(); 308 system_tray_->CreateItems();
sadrul 2012/08/15 16:47:01 Maybe CreateItems can be called from Initialize no
stevenjb 2012/08/15 21:51:04 Done.
309 }
310 if (web_notification_tray_) {
311 web_notification_tray_->Initialize();
312 }
313 if (system_tray_delegate()) {
314 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus());
sadrul 2012/08/15 16:47:01 Can system_tray_delegate() be NULL here?
stevenjb 2012/08/15 21:51:04 Looks like not, removed test.
315 }
305 } 316 }
306 317
307 void StatusAreaWidget::Shutdown() { 318 void StatusAreaWidget::Shutdown() {
308 // Destroy the trays early, causing them to be removed from the view 319 // Destroy the trays early, causing them to be removed from the view
309 // hierarchy. Do not used scoped pointers since we don't want to destroy them 320 // hierarchy. Do not used scoped pointers since we don't want to destroy them
310 // in the destructor if Shutdown() is not called (e.g. in tests). 321 // in the destructor if Shutdown() is not called (e.g. in tests).
311 system_tray_delegate_.reset(); 322 system_tray_delegate_.reset();
312 delete system_tray_; 323 delete system_tray_;
313 system_tray_ = NULL; 324 system_tray_ = NULL;
314 delete web_notification_tray_; 325 delete web_notification_tray_;
315 web_notification_tray_ = NULL; 326 web_notification_tray_ = NULL;
316 } 327 }
317 328
318 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) { 329 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) {
319 system_tray_ = new SystemTray(this); 330 system_tray_ = new SystemTray(this);
320 status_area_widget_delegate_->AddTray(system_tray_); 331 status_area_widget_delegate_->AddTray(system_tray_);
321 system_tray_->Initialize(); // Called after added to widget.
322 332
323 if (shell_delegate) { 333 if (shell_delegate) {
324 system_tray_delegate_.reset( 334 system_tray_delegate_.reset(
325 shell_delegate->CreateSystemTrayDelegate(system_tray_)); 335 shell_delegate->CreateSystemTrayDelegate(system_tray_));
326 } 336 }
327 if (!system_tray_delegate_.get()) 337 if (!system_tray_delegate_.get())
328 system_tray_delegate_.reset(new DummySystemTrayDelegate()); 338 system_tray_delegate_.reset(new DummySystemTrayDelegate());
329
330 system_tray_->CreateItems(); // Called after delegate is created.
331 UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus());
332 } 339 }
333 340
334 void StatusAreaWidget::AddWebNotificationTray() { 341 void StatusAreaWidget::AddWebNotificationTray() {
335 web_notification_tray_ = new WebNotificationTray(this); 342 web_notification_tray_ = new WebNotificationTray(this);
336 status_area_widget_delegate_->AddTray(web_notification_tray_); 343 status_area_widget_delegate_->AddTray(web_notification_tray_);
337 } 344 }
338 345
339 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { 346 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
340 status_area_widget_delegate_->set_alignment(alignment); 347 status_area_widget_delegate_->set_alignment(alignment);
341 if (system_tray_) 348 if (system_tray_)
(...skipping 30 matching lines...) Expand all
372 user::LoginStatus login_status) { 379 user::LoginStatus login_status) {
373 if (login_status_ == login_status) 380 if (login_status_ == login_status)
374 return; 381 return;
375 login_status_ = login_status; 382 login_status_ = login_status;
376 if (system_tray_) 383 if (system_tray_)
377 system_tray_->UpdateAfterLoginStatusChange(login_status); 384 system_tray_->UpdateAfterLoginStatusChange(login_status);
378 if (web_notification_tray_) 385 if (web_notification_tray_)
379 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 386 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
380 } 387 }
381 388
389 void StatusAreaWidget::UpdateShouldShowLauncher() {
390 bool should_show_launcher =
391 (system_tray_ && system_tray_->IsSystemBubbleVisible()) ||
392 (web_notification_tray_ &&
393 web_notification_tray_->IsMessageCenterBubbleVisible());
394 if (!should_show_launcher && Shell::GetInstance()->shelf()->IsVisible()) {
395 // If the launcher is currently visible, don't hide the launcher
396 // if the mouse is in this widget or in any notification bubbles.
397 should_show_launcher =
398 (GetWindowBoundsInScreen().Contains(
399 gfx::Screen::GetCursorScreenPoint())) ||
400 (system_tray_ && system_tray_->IsMouseInNotificationBubble()) ||
401 (web_notification_tray_ &&
402 web_notification_tray_->IsMouseInNotificationBubble());
403 }
404 if (should_show_launcher != should_show_launcher_) {
405 should_show_launcher_ = should_show_launcher;
406 Shell::GetInstance()->shelf()->UpdateAutoHideState();
407 }
408 }
409
382 } // namespace internal 410 } // namespace internal
383 } // namespace ash 411 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698