| 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/common/system/status_area_widget.h" | 5 #include "ash/common/system/status_area_widget.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/shelf/wm_shelf.h" | 8 #include "ash/common/shelf/wm_shelf.h" |
| 9 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/common/system/overview/overview_button_tray.h" | 10 #include "ash/common/system/overview/overview_button_tray.h" |
| 11 #include "ash/common/system/status_area_widget_delegate.h" | 11 #include "ash/common/system/status_area_widget_delegate.h" |
| 12 #include "ash/common/system/tray/system_tray.h" | 12 #include "ash/common/system/tray/system_tray.h" |
| 13 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
| 14 #include "ash/common/system/web_notification/web_notification_tray.h" | 14 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 15 #include "ash/common/wm_lookup.h" | 15 #include "ash/common/wm_lookup.h" |
| 16 #include "ash/common/wm_root_window_controller.h" | 16 #include "ash/common/wm_root_window_controller.h" |
| 17 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 18 #include "ash/common/wm_window.h" | 18 #include "ash/common/wm_window.h" |
| 19 #include "base/i18n/time_formatting.h" | 19 #include "base/i18n/time_formatting.h" |
| 20 #include "ui/native_theme/native_theme_dark_aura.h" | 20 #include "ui/native_theme/native_theme_dark_aura.h" |
| 21 | 21 |
| 22 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 23 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" | 23 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" |
| 24 #include "ash/common/system/chromeos/palette/palette_tray.h" | 24 #include "ash/common/system/chromeos/palette/palette_tray.h" |
| 25 #include "ash/common/system/chromeos/palette/palette_utils.h" |
| 25 #include "ash/common/system/chromeos/session/logout_button_tray.h" | 26 #include "ash/common/system/chromeos/session/logout_button_tray.h" |
| 26 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" | 27 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 namespace ash { | 30 namespace ash { |
| 30 | 31 |
| 31 StatusAreaWidget::StatusAreaWidget(WmWindow* status_container, | 32 StatusAreaWidget::StatusAreaWidget(WmWindow* status_container, |
| 32 WmShelf* wm_shelf) | 33 WmShelf* wm_shelf) |
| 33 : status_area_widget_delegate_(new StatusAreaWidgetDelegate), | 34 : status_area_widget_delegate_(new StatusAreaWidgetDelegate), |
| 34 overview_button_tray_(nullptr), | 35 overview_button_tray_(nullptr), |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 194 } |
| 194 | 195 |
| 195 void StatusAreaWidget::SchedulePaint() { | 196 void StatusAreaWidget::SchedulePaint() { |
| 196 status_area_widget_delegate_->SchedulePaint(); | 197 status_area_widget_delegate_->SchedulePaint(); |
| 197 web_notification_tray_->SchedulePaint(); | 198 web_notification_tray_->SchedulePaint(); |
| 198 system_tray_->SchedulePaint(); | 199 system_tray_->SchedulePaint(); |
| 199 #if defined(OS_CHROMEOS) | 200 #if defined(OS_CHROMEOS) |
| 200 virtual_keyboard_tray_->SchedulePaint(); | 201 virtual_keyboard_tray_->SchedulePaint(); |
| 201 logout_button_tray_->SchedulePaint(); | 202 logout_button_tray_->SchedulePaint(); |
| 202 ime_menu_tray_->SchedulePaint(); | 203 ime_menu_tray_->SchedulePaint(); |
| 203 palette_tray_->SchedulePaint(); | 204 if (palette_tray_) |
| 205 palette_tray_->SchedulePaint(); |
| 204 #endif | 206 #endif |
| 205 overview_button_tray_->SchedulePaint(); | 207 overview_button_tray_->SchedulePaint(); |
| 206 } | 208 } |
| 207 | 209 |
| 208 const ui::NativeTheme* StatusAreaWidget::GetNativeTheme() const { | 210 const ui::NativeTheme* StatusAreaWidget::GetNativeTheme() const { |
| 209 return MaterialDesignController::IsShelfMaterial() | 211 return MaterialDesignController::IsShelfMaterial() |
| 210 ? ui::NativeThemeDarkAura::instance() | 212 ? ui::NativeThemeDarkAura::instance() |
| 211 : Widget::GetNativeTheme(); | 213 : Widget::GetNativeTheme(); |
| 212 } | 214 } |
| 213 | 215 |
| 214 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { | 216 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { |
| 215 Widget::OnNativeWidgetActivationChanged(active); | 217 Widget::OnNativeWidgetActivationChanged(active); |
| 216 if (active) | 218 if (active) |
| 217 status_area_widget_delegate_->SetPaneFocusAndFocusDefault(); | 219 status_area_widget_delegate_->SetPaneFocusAndFocusDefault(); |
| 218 } | 220 } |
| 219 | 221 |
| 220 void StatusAreaWidget::UpdateShelfItemBackground(int alpha) { | 222 void StatusAreaWidget::UpdateShelfItemBackground(int alpha) { |
| 221 web_notification_tray_->UpdateShelfItemBackground(alpha); | 223 web_notification_tray_->UpdateShelfItemBackground(alpha); |
| 222 system_tray_->UpdateShelfItemBackground(alpha); | 224 system_tray_->UpdateShelfItemBackground(alpha); |
| 223 #if defined(OS_CHROMEOS) | 225 #if defined(OS_CHROMEOS) |
| 224 virtual_keyboard_tray_->UpdateShelfItemBackground(alpha); | 226 virtual_keyboard_tray_->UpdateShelfItemBackground(alpha); |
| 225 logout_button_tray_->UpdateShelfItemBackground(alpha); | 227 logout_button_tray_->UpdateShelfItemBackground(alpha); |
| 226 ime_menu_tray_->UpdateShelfItemBackground(alpha); | 228 ime_menu_tray_->UpdateShelfItemBackground(alpha); |
| 227 palette_tray_->UpdateShelfItemBackground(alpha); | 229 if (palette_tray_) |
| 230 palette_tray_->UpdateShelfItemBackground(alpha); |
| 228 #endif | 231 #endif |
| 229 overview_button_tray_->UpdateShelfItemBackground(alpha); | 232 overview_button_tray_->UpdateShelfItemBackground(alpha); |
| 230 } | 233 } |
| 231 | 234 |
| 232 void StatusAreaWidget::AddSystemTray() { | 235 void StatusAreaWidget::AddSystemTray() { |
| 233 system_tray_ = new SystemTray(wm_shelf_); | 236 system_tray_ = new SystemTray(wm_shelf_); |
| 234 status_area_widget_delegate_->AddTray(system_tray_); | 237 status_area_widget_delegate_->AddTray(system_tray_); |
| 235 } | 238 } |
| 236 | 239 |
| 237 void StatusAreaWidget::AddWebNotificationTray() { | 240 void StatusAreaWidget::AddWebNotificationTray() { |
| 238 DCHECK(system_tray_); | 241 DCHECK(system_tray_); |
| 239 web_notification_tray_ = new WebNotificationTray( | 242 web_notification_tray_ = new WebNotificationTray( |
| 240 wm_shelf_, WmLookup::Get()->GetWindowForWidget(this), system_tray_); | 243 wm_shelf_, WmLookup::Get()->GetWindowForWidget(this), system_tray_); |
| 241 status_area_widget_delegate_->AddTray(web_notification_tray_); | 244 status_area_widget_delegate_->AddTray(web_notification_tray_); |
| 242 } | 245 } |
| 243 | 246 |
| 244 #if defined(OS_CHROMEOS) | 247 #if defined(OS_CHROMEOS) |
| 245 void StatusAreaWidget::AddLogoutButtonTray() { | 248 void StatusAreaWidget::AddLogoutButtonTray() { |
| 246 logout_button_tray_ = new LogoutButtonTray(wm_shelf_); | 249 logout_button_tray_ = new LogoutButtonTray(wm_shelf_); |
| 247 status_area_widget_delegate_->AddTray(logout_button_tray_); | 250 status_area_widget_delegate_->AddTray(logout_button_tray_); |
| 248 } | 251 } |
| 249 | 252 |
| 250 void StatusAreaWidget::AddPaletteTray() { | 253 void StatusAreaWidget::AddPaletteTray() { |
| 251 palette_tray_ = new PaletteTray(wm_shelf_); | 254 if (IsPaletteFeatureEnabled()) { |
| 252 status_area_widget_delegate_->AddTray(palette_tray_); | 255 palette_tray_ = new PaletteTray(wm_shelf_); |
| 256 status_area_widget_delegate_->AddTray(palette_tray_); |
| 257 } |
| 253 } | 258 } |
| 254 | 259 |
| 255 void StatusAreaWidget::AddVirtualKeyboardTray() { | 260 void StatusAreaWidget::AddVirtualKeyboardTray() { |
| 256 virtual_keyboard_tray_ = new VirtualKeyboardTray(wm_shelf_); | 261 virtual_keyboard_tray_ = new VirtualKeyboardTray(wm_shelf_); |
| 257 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_); | 262 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_); |
| 258 } | 263 } |
| 259 | 264 |
| 260 void StatusAreaWidget::AddImeMenuTray() { | 265 void StatusAreaWidget::AddImeMenuTray() { |
| 261 ime_menu_tray_ = new ImeMenuTray(wm_shelf_); | 266 ime_menu_tray_ = new ImeMenuTray(wm_shelf_); |
| 262 status_area_widget_delegate_->AddTray(ime_menu_tray_); | 267 status_area_widget_delegate_->AddTray(ime_menu_tray_); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 279 return false; | 284 return false; |
| 280 } | 285 } |
| 281 #endif | 286 #endif |
| 282 | 287 |
| 283 void StatusAreaWidget::AddOverviewButtonTray() { | 288 void StatusAreaWidget::AddOverviewButtonTray() { |
| 284 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); | 289 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); |
| 285 status_area_widget_delegate_->AddTray(overview_button_tray_); | 290 status_area_widget_delegate_->AddTray(overview_button_tray_); |
| 286 } | 291 } |
| 287 | 292 |
| 288 } // namespace ash | 293 } // namespace ash |
| OLD | NEW |