| 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/chromeos/settings/tray_settings.h" | 5 #include "ash/system/chromeos/settings/tray_settings.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/chromeos/power/power_status.h" | 8 #include "ash/system/chromeos/power/power_status.h" |
| 9 #include "ash/system/chromeos/power/power_status_view.h" | 9 #include "ash/system/chromeos/power/power_status_view.h" |
| 10 #include "ash/system/tray/actionable_view.h" | 10 #include "ash/system/tray/actionable_view.h" |
| 11 #include "ash/system/tray/fixed_sized_image_view.h" | 11 #include "ash/system/tray/fixed_sized_image_view.h" |
| 12 #include "ash/system/tray/system_tray_delegate.h" | 12 #include "ash/system/tray/system_tray_delegate.h" |
| 13 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "grit/ash_resources.h" | 16 #include "grit/ash_resources.h" |
| 17 #include "grit/ash_strings.h" | 17 #include "grit/ash_strings.h" |
| 18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| 21 #include "ui/views/controls/image_view.h" | 21 #include "ui/views/controls/image_view.h" |
| 22 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
| 23 #include "ui/views/layout/box_layout.h" | 23 #include "ui/views/layout/box_layout.h" |
| 24 #include "ui/views/layout/fill_layout.h" | 24 #include "ui/views/layout/fill_layout.h" |
| 25 #include "ui/views/view.h" | 25 #include "ui/views/view.h" |
| 26 | 26 |
| 27 namespace ash { | 27 namespace ash { |
| 28 namespace internal { | |
| 29 | |
| 30 namespace tray { | 28 namespace tray { |
| 31 | 29 |
| 32 class SettingsDefaultView : public ActionableView, | 30 class SettingsDefaultView : public ActionableView, |
| 33 public PowerStatus::Observer { | 31 public PowerStatus::Observer { |
| 34 public: | 32 public: |
| 35 explicit SettingsDefaultView(user::LoginStatus status) | 33 explicit SettingsDefaultView(user::LoginStatus status) |
| 36 : login_status_(status), | 34 : login_status_(status), |
| 37 label_(NULL), | 35 label_(NULL), |
| 38 power_status_view_(NULL) { | 36 power_status_view_(NULL) { |
| 39 PowerStatus::Get()->AddObserver(this); | 37 PowerStatus::Get()->AddObserver(this); |
| 40 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 38 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 41 ash::kTrayPopupPaddingHorizontal, 0, | 39 ash::kTrayPopupPaddingHorizontal, 0, |
| 42 ash::kTrayPopupPaddingBetweenItems)); | 40 ash::kTrayPopupPaddingBetweenItems)); |
| 43 | 41 |
| 44 bool power_view_right_align = false; | 42 bool power_view_right_align = false; |
| 45 if (login_status_ != user::LOGGED_IN_NONE && | 43 if (login_status_ != user::LOGGED_IN_NONE && |
| 46 login_status_ != user::LOGGED_IN_LOCKED) { | 44 login_status_ != user::LOGGED_IN_LOCKED) { |
| 47 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 45 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 48 views::ImageView* icon = | 46 views::ImageView* icon = |
| 49 new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight); | 47 new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight); |
| 50 icon->SetImage( | 48 icon->SetImage( |
| 51 rb.GetImageNamed(IDR_AURA_UBER_TRAY_SETTINGS).ToImageSkia()); | 49 rb.GetImageNamed(IDR_AURA_UBER_TRAY_SETTINGS).ToImageSkia()); |
| 52 AddChildView(icon); | 50 AddChildView(icon); |
| 53 | 51 |
| 54 base::string16 text = rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_SETTINGS); | 52 base::string16 text = rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_SETTINGS); |
| 55 label_ = new views::Label(text); | 53 label_ = new views::Label(text); |
| 56 AddChildView(label_); | 54 AddChildView(label_); |
| 57 SetAccessibleName(text); | 55 SetAccessibleName(text); |
| 58 | 56 |
| 59 power_view_right_align = true; | 57 power_view_right_align = true; |
| 60 } | 58 } |
| 61 | 59 |
| 62 if (PowerStatus::Get()->IsBatteryPresent()) { | 60 if (PowerStatus::Get()->IsBatteryPresent()) { |
| 63 power_status_view_ = new ash::internal::PowerStatusView( | 61 power_status_view_ = new ash::PowerStatusView( |
| 64 ash::internal::PowerStatusView::VIEW_DEFAULT, power_view_right_align); | 62 ash::PowerStatusView::VIEW_DEFAULT, power_view_right_align); |
| 65 AddChildView(power_status_view_); | 63 AddChildView(power_status_view_); |
| 66 OnPowerStatusChanged(); | 64 OnPowerStatusChanged(); |
| 67 } | 65 } |
| 68 } | 66 } |
| 69 | 67 |
| 70 virtual ~SettingsDefaultView() { | 68 virtual ~SettingsDefaultView() { |
| 71 PowerStatus::Get()->RemoveObserver(this); | 69 PowerStatus::Get()->RemoveObserver(this); |
| 72 } | 70 } |
| 73 | 71 |
| 74 // Overridden from ash::internal::ActionableView. | 72 // Overridden from ash::ActionableView. |
| 75 virtual bool PerformAction(const ui::Event& event) OVERRIDE { | 73 virtual bool PerformAction(const ui::Event& event) OVERRIDE { |
| 76 if (login_status_ == user::LOGGED_IN_NONE || | 74 if (login_status_ == user::LOGGED_IN_NONE || |
| 77 login_status_ == user::LOGGED_IN_LOCKED) | 75 login_status_ == user::LOGGED_IN_LOCKED) |
| 78 return false; | 76 return false; |
| 79 | 77 |
| 80 ash::Shell::GetInstance()->system_tray_delegate()->ShowSettings(); | 78 ash::Shell::GetInstance()->system_tray_delegate()->ShowSettings(); |
| 81 return true; | 79 return true; |
| 82 } | 80 } |
| 83 | 81 |
| 84 // Overridden from views::View. | 82 // Overridden from views::View. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 110 base::string16 accessible_name = label_ ? | 108 base::string16 accessible_name = label_ ? |
| 111 label_->text() + base::ASCIIToUTF16(", ") + | 109 label_->text() + base::ASCIIToUTF16(", ") + |
| 112 PowerStatus::Get()->GetAccessibleNameString() : | 110 PowerStatus::Get()->GetAccessibleNameString() : |
| 113 PowerStatus::Get()->GetAccessibleNameString(); | 111 PowerStatus::Get()->GetAccessibleNameString(); |
| 114 SetAccessibleName(accessible_name); | 112 SetAccessibleName(accessible_name); |
| 115 } | 113 } |
| 116 | 114 |
| 117 private: | 115 private: |
| 118 user::LoginStatus login_status_; | 116 user::LoginStatus login_status_; |
| 119 views::Label* label_; | 117 views::Label* label_; |
| 120 ash::internal::PowerStatusView* power_status_view_; | 118 ash::PowerStatusView* power_status_view_; |
| 121 | 119 |
| 122 DISALLOW_COPY_AND_ASSIGN(SettingsDefaultView); | 120 DISALLOW_COPY_AND_ASSIGN(SettingsDefaultView); |
| 123 }; | 121 }; |
| 124 | 122 |
| 125 } // namespace tray | 123 } // namespace tray |
| 126 | 124 |
| 127 TraySettings::TraySettings(SystemTray* system_tray) | 125 TraySettings::TraySettings(SystemTray* system_tray) |
| 128 : SystemTrayItem(system_tray), | 126 : SystemTrayItem(system_tray), |
| 129 default_view_(NULL) { | 127 default_view_(NULL) { |
| 130 } | 128 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 160 void TraySettings::DestroyDefaultView() { | 158 void TraySettings::DestroyDefaultView() { |
| 161 default_view_ = NULL; | 159 default_view_ = NULL; |
| 162 } | 160 } |
| 163 | 161 |
| 164 void TraySettings::DestroyDetailedView() { | 162 void TraySettings::DestroyDetailedView() { |
| 165 } | 163 } |
| 166 | 164 |
| 167 void TraySettings::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 165 void TraySettings::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
| 168 } | 166 } |
| 169 | 167 |
| 170 } // namespace internal | |
| 171 } // namespace ash | 168 } // namespace ash |
| OLD | NEW |