OLD | NEW |
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/tray/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell/panel_window.h" | 8 #include "ash/shell/panel_window.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/system/audio/tray_volume.h" |
| 11 #include "ash/system/bluetooth/tray_bluetooth.h" |
| 12 #include "ash/system/brightness/tray_brightness.h" |
| 13 #include "ash/system/date/tray_date.h" |
| 14 #include "ash/system/ime/tray_ime.h" |
| 15 #include "ash/system/network/tray_network.h" |
| 16 #include "ash/system/power/power_status_observer.h" |
| 17 #include "ash/system/power/power_supply_status.h" |
| 18 #include "ash/system/power/tray_power.h" |
| 19 #include "ash/system/settings/tray_settings.h" |
| 20 #include "ash/system/tray/tray_empty.h" |
10 #include "ash/system/tray/tray_constants.h" | 21 #include "ash/system/tray/tray_constants.h" |
11 #include "ash/system/tray/system_tray_delegate.h" | 22 #include "ash/system/tray/system_tray_delegate.h" |
12 #include "ash/system/tray/system_tray_item.h" | 23 #include "ash/system/tray/system_tray_item.h" |
| 24 #include "ash/system/tray/system_tray_widget_delegate.h" |
| 25 #include "ash/system/tray_accessibility.h" |
| 26 #include "ash/system/tray_caps_lock.h" |
| 27 #include "ash/system/tray_update.h" |
| 28 #include "ash/system/user/tray_user.h" |
13 #include "ash/system/user/login_status.h" | 29 #include "ash/system/user/login_status.h" |
14 #include "ash/wm/shadow_types.h" | 30 #include "ash/wm/shadow_types.h" |
15 #include "ash/wm/shelf_layout_manager.h" | 31 #include "ash/wm/shelf_layout_manager.h" |
16 #include "ash/wm/window_animations.h" | 32 #include "ash/wm/window_animations.h" |
17 #include "base/i18n/rtl.h" | 33 #include "base/i18n/rtl.h" |
18 #include "base/logging.h" | 34 #include "base/logging.h" |
19 #include "base/message_loop.h" | 35 #include "base/message_loop.h" |
20 #include "base/timer.h" | 36 #include "base/timer.h" |
21 #include "base/utf_string_conversions.h" | 37 #include "base/utf_string_conversions.h" |
22 #include "grit/ash_strings.h" | 38 #include "grit/ash_strings.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 audio_observer_(NULL), | 415 audio_observer_(NULL), |
400 bluetooth_observer_(NULL), | 416 bluetooth_observer_(NULL), |
401 brightness_observer_(NULL), | 417 brightness_observer_(NULL), |
402 caps_lock_observer_(NULL), | 418 caps_lock_observer_(NULL), |
403 clock_observer_(NULL), | 419 clock_observer_(NULL), |
404 ime_observer_(NULL), | 420 ime_observer_(NULL), |
405 network_observer_(NULL), | 421 network_observer_(NULL), |
406 power_status_observer_(NULL), | 422 power_status_observer_(NULL), |
407 update_observer_(NULL), | 423 update_observer_(NULL), |
408 user_observer_(NULL), | 424 user_observer_(NULL), |
| 425 widget_(NULL), |
409 bubble_(NULL), | 426 bubble_(NULL), |
410 popup_(NULL), | 427 popup_(NULL), |
411 background_(new internal::SystemTrayBackground), | 428 background_(new internal::SystemTrayBackground), |
412 should_show_launcher_(false), | 429 should_show_launcher_(false), |
413 ALLOW_THIS_IN_INITIALIZER_LIST(hide_background_animator_(this, | 430 ALLOW_THIS_IN_INITIALIZER_LIST(hide_background_animator_(this, |
414 0, kTrayBackgroundAlpha)), | 431 0, kTrayBackgroundAlpha)), |
415 ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(this, | 432 ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(this, |
416 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) { | 433 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) { |
417 container_ = new views::View; | 434 container_ = new views::View; |
418 container_->SetLayoutManager(new views::BoxLayout( | 435 container_->SetLayoutManager(new views::BoxLayout( |
(...skipping 16 matching lines...) Expand all Loading... |
435 SystemTray::~SystemTray() { | 452 SystemTray::~SystemTray() { |
436 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); | 453 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); |
437 it != items_.end(); | 454 it != items_.end(); |
438 ++it) { | 455 ++it) { |
439 (*it)->DestroyTrayView(); | 456 (*it)->DestroyTrayView(); |
440 } | 457 } |
441 if (popup_) | 458 if (popup_) |
442 popup_->CloseNow(); | 459 popup_->CloseNow(); |
443 } | 460 } |
444 | 461 |
| 462 void SystemTray::CreateItems() { |
| 463 internal::TrayVolume* tray_volume = new internal::TrayVolume(); |
| 464 internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth(); |
| 465 internal::TrayBrightness* tray_brightness = new internal::TrayBrightness(); |
| 466 internal::TrayDate* tray_date = new internal::TrayDate(); |
| 467 internal::TrayPower* tray_power = new internal::TrayPower(); |
| 468 internal::TrayNetwork* tray_network = new internal::TrayNetwork; |
| 469 internal::TrayUser* tray_user = new internal::TrayUser; |
| 470 internal::TrayAccessibility* tray_accessibility = |
| 471 new internal::TrayAccessibility; |
| 472 internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; |
| 473 internal::TrayIME* tray_ime = new internal::TrayIME; |
| 474 internal::TrayUpdate* tray_update = new internal::TrayUpdate; |
| 475 |
| 476 accessibility_observer_ = tray_accessibility; |
| 477 audio_observer_ = tray_volume; |
| 478 bluetooth_observer_ = tray_bluetooth; |
| 479 brightness_observer_ = tray_brightness; |
| 480 caps_lock_observer_ = tray_caps_lock; |
| 481 clock_observer_ = tray_date; |
| 482 ime_observer_ = tray_ime; |
| 483 network_observer_ = tray_network; |
| 484 power_status_observer_ = tray_power; |
| 485 update_observer_ = tray_update; |
| 486 user_observer_ = tray_user; |
| 487 |
| 488 AddTrayItem(tray_user); |
| 489 AddTrayItem(new internal::TrayEmpty()); |
| 490 AddTrayItem(tray_power); |
| 491 AddTrayItem(tray_network); |
| 492 AddTrayItem(tray_bluetooth); |
| 493 AddTrayItem(tray_ime); |
| 494 AddTrayItem(tray_volume); |
| 495 AddTrayItem(tray_brightness); |
| 496 AddTrayItem(tray_update); |
| 497 AddTrayItem(new internal::TraySettings()); |
| 498 AddTrayItem(tray_accessibility); |
| 499 AddTrayItem(tray_caps_lock); |
| 500 AddTrayItem(tray_date); |
| 501 SetVisible(ash::Shell::GetInstance()->tray_delegate()-> |
| 502 GetTrayVisibilityOnStartup()); |
| 503 } |
| 504 |
| 505 void SystemTray::CreateWidget() { |
| 506 if (widget_) |
| 507 widget_->Close(); |
| 508 widget_ = new views::Widget; |
| 509 internal::StatusAreaView* status_area_view = new internal::StatusAreaView; |
| 510 views::Widget::InitParams params( |
| 511 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 512 gfx::Size ps = GetPreferredSize(); |
| 513 params.bounds = gfx::Rect(0, 0, ps.width(), ps.height()); |
| 514 params.delegate = status_area_view; |
| 515 params.parent = Shell::GetInstance()->GetContainer( |
| 516 ash::internal::kShellWindowId_StatusContainer); |
| 517 params.transparent = true; |
| 518 widget_->Init(params); |
| 519 widget_->set_focus_on_creation(false); |
| 520 status_area_view->AddChildView(this); |
| 521 widget_->SetContentsView(status_area_view); |
| 522 widget_->Show(); |
| 523 widget_->GetNativeView()->SetName("StatusTrayWidget"); |
| 524 } |
| 525 |
445 void SystemTray::AddTrayItem(SystemTrayItem* item) { | 526 void SystemTray::AddTrayItem(SystemTrayItem* item) { |
446 items_.push_back(item); | 527 items_.push_back(item); |
447 | 528 |
448 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 529 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
449 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); | 530 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); |
450 if (tray_item) { | 531 if (tray_item) { |
451 container_->AddChildViewAt(tray_item, 0); | 532 container_->AddChildViewAt(tray_item, 0); |
452 PreferredSizeChanged(); | 533 PreferredSizeChanged(); |
453 } | 534 } |
454 } | 535 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 popup_->Hide(); | 712 popup_->Hide(); |
632 } | 713 } |
633 } | 714 } |
634 return base::EVENT_CONTINUE; | 715 return base::EVENT_CONTINUE; |
635 } | 716 } |
636 | 717 |
637 void SystemTray::DidProcessEvent(const base::NativeEvent& event) { | 718 void SystemTray::DidProcessEvent(const base::NativeEvent& event) { |
638 } | 719 } |
639 | 720 |
640 } // namespace ash | 721 } // namespace ash |
OLD | NEW |