Chromium Code Reviews| 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/shelf/wm_shelf.h" | 8 #include "ash/common/shelf/wm_shelf.h" |
| 9 #include "ash/common/shelf/wm_shelf_observer.h" | |
| 8 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| 9 #include "ash/common/system/overview/overview_button_tray.h" | 11 #include "ash/common/system/overview/overview_button_tray.h" |
| 10 #include "ash/common/system/status_area_widget_delegate.h" | 12 #include "ash/common/system/status_area_widget_delegate.h" |
| 11 #include "ash/common/system/tray/system_tray.h" | 13 #include "ash/common/system/tray/system_tray.h" |
| 12 #include "ash/common/system/tray/system_tray_delegate.h" | 14 #include "ash/common/system/tray/system_tray_delegate.h" |
| 13 #include "ash/common/system/web_notification/web_notification_tray.h" | 15 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 14 #include "ash/common/wm_lookup.h" | 16 #include "ash/common/wm_lookup.h" |
| 15 #include "ash/common/wm_root_window_controller.h" | 17 #include "ash/common/wm_root_window_controller.h" |
| 16 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 17 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 #if defined(OS_CHROMEOS) | 162 #if defined(OS_CHROMEOS) |
| 161 virtual_keyboard_tray_->UpdateShelfItemBackground(alpha); | 163 virtual_keyboard_tray_->UpdateShelfItemBackground(alpha); |
| 162 logout_button_tray_->UpdateShelfItemBackground(alpha); | 164 logout_button_tray_->UpdateShelfItemBackground(alpha); |
| 163 ime_menu_tray_->UpdateShelfItemBackground(alpha); | 165 ime_menu_tray_->UpdateShelfItemBackground(alpha); |
| 164 palette_tray_->UpdateShelfItemBackground(alpha); | 166 palette_tray_->UpdateShelfItemBackground(alpha); |
| 165 #endif | 167 #endif |
| 166 overview_button_tray_->UpdateShelfItemBackground(alpha); | 168 overview_button_tray_->UpdateShelfItemBackground(alpha); |
| 167 } | 169 } |
| 168 | 170 |
| 169 void StatusAreaWidget::AddSystemTray() { | 171 void StatusAreaWidget::AddSystemTray() { |
| 170 system_tray_ = new SystemTray(wm_shelf_); | 172 system_tray_ = new SystemTray(wm_shelf_, this); |
| 171 status_area_widget_delegate_->AddTray(system_tray_); | 173 status_area_widget_delegate_->AddTray(system_tray_); |
| 172 } | 174 } |
| 173 | 175 |
| 174 void StatusAreaWidget::AddWebNotificationTray() { | 176 void StatusAreaWidget::AddWebNotificationTray() { |
| 175 DCHECK(system_tray_); | 177 DCHECK(system_tray_); |
| 176 web_notification_tray_ = new WebNotificationTray( | 178 web_notification_tray_ = new WebNotificationTray( |
| 177 wm_shelf_, WmLookup::Get()->GetWindowForWidget(this), system_tray_); | 179 wm_shelf_, WmLookup::Get()->GetWindowForWidget(this), system_tray_, this); |
| 178 status_area_widget_delegate_->AddTray(web_notification_tray_); | 180 status_area_widget_delegate_->AddTray(web_notification_tray_); |
| 179 } | 181 } |
| 180 | 182 |
| 181 #if defined(OS_CHROMEOS) | 183 #if defined(OS_CHROMEOS) |
| 182 void StatusAreaWidget::AddLogoutButtonTray() { | 184 void StatusAreaWidget::AddLogoutButtonTray() { |
| 183 logout_button_tray_ = new LogoutButtonTray(wm_shelf_); | 185 logout_button_tray_ = new LogoutButtonTray(wm_shelf_, this); |
| 184 status_area_widget_delegate_->AddTray(logout_button_tray_); | 186 status_area_widget_delegate_->AddTray(logout_button_tray_); |
| 185 } | 187 } |
| 186 | 188 |
| 187 void StatusAreaWidget::AddPaletteTray() { | 189 void StatusAreaWidget::AddPaletteTray() { |
| 188 palette_tray_ = new PaletteTray(wm_shelf_); | 190 palette_tray_ = new PaletteTray(wm_shelf_, this); |
| 189 status_area_widget_delegate_->AddTray(palette_tray_); | 191 status_area_widget_delegate_->AddTray(palette_tray_); |
| 190 } | 192 } |
| 191 | 193 |
| 192 void StatusAreaWidget::AddVirtualKeyboardTray() { | 194 void StatusAreaWidget::AddVirtualKeyboardTray() { |
| 193 virtual_keyboard_tray_ = new VirtualKeyboardTray(wm_shelf_); | 195 virtual_keyboard_tray_ = new VirtualKeyboardTray(wm_shelf_, this); |
| 194 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_); | 196 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_); |
| 195 } | 197 } |
| 196 | 198 |
| 197 void StatusAreaWidget::AddImeMenuTray() { | 199 void StatusAreaWidget::AddImeMenuTray() { |
| 198 ime_menu_tray_ = new ImeMenuTray(wm_shelf_); | 200 ime_menu_tray_ = new ImeMenuTray(wm_shelf_, this); |
| 199 status_area_widget_delegate_->AddTray(ime_menu_tray_); | 201 status_area_widget_delegate_->AddTray(ime_menu_tray_); |
| 200 } | 202 } |
| 201 #endif | 203 #endif |
| 202 | 204 |
| 203 void StatusAreaWidget::AddOverviewButtonTray() { | 205 void StatusAreaWidget::AddOverviewButtonTray() { |
| 204 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); | 206 overview_button_tray_ = new OverviewButtonTray(wm_shelf_, this); |
| 205 status_area_widget_delegate_->AddTray(overview_button_tray_); | 207 status_area_widget_delegate_->AddTray(overview_button_tray_); |
| 206 } | 208 } |
| 207 | 209 |
| 208 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { | 210 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { |
| 209 status_area_widget_delegate_->set_alignment(alignment); | 211 status_area_widget_delegate_->set_alignment(alignment); |
| 210 if (system_tray_) | 212 if (system_tray_) |
| 211 system_tray_->SetShelfAlignment(alignment); | 213 system_tray_->SetShelfAlignment(alignment); |
| 212 if (web_notification_tray_) | 214 if (web_notification_tray_) |
| 213 web_notification_tray_->SetShelfAlignment(alignment); | 215 web_notification_tray_->SetShelfAlignment(alignment); |
| 214 #if defined(OS_CHROMEOS) | 216 #if defined(OS_CHROMEOS) |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 235 if (web_notification_tray_) | 237 if (web_notification_tray_) |
| 236 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); | 238 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); |
| 237 #if defined(OS_CHROMEOS) | 239 #if defined(OS_CHROMEOS) |
| 238 if (logout_button_tray_) | 240 if (logout_button_tray_) |
| 239 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); | 241 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); |
| 240 #endif | 242 #endif |
| 241 if (overview_button_tray_) | 243 if (overview_button_tray_) |
| 242 overview_button_tray_->UpdateAfterLoginStatusChange(login_status); | 244 overview_button_tray_->UpdateAfterLoginStatusChange(login_status); |
| 243 } | 245 } |
| 244 | 246 |
| 247 void StatusAreaWidget::OnVisibilityChange(TrayBackgroundView* tray) { | |
| 248 if (ash::MaterialDesignController::IsShelfMaterial()) { | |
|
James Cook
2016/08/09 00:25:17
nit: early exit to avoid indenting below?
yiyix
2016/08/11 01:23:18
Done.
| |
| 249 #if defined(OS_CHROMEOS) | |
| 250 if (tray == virtual_keyboard_tray_) { | |
| 251 if (logout_button_tray_->visible()) { | |
| 252 tray->SetSeparatorVisibility(false); | |
|
varkha
2016/08/10 23:27:24
nit: collapse into a single method invocation, i.e
| |
| 253 } else { | |
| 254 tray->SetSeparatorVisibility(true); | |
| 255 } | |
|
James Cook
2016/08/09 00:25:17
nit: I would do something like:
const bool show_se
yiyix
2016/08/11 01:23:18
Done.
| |
| 256 | |
|
James Cook
2016/08/09 00:25:17
nit: no blank line
yiyix
2016/08/11 01:23:18
Done.
| |
| 257 } else if (tray == ime_menu_tray_) { | |
| 258 if (logout_button_tray_->visible() && | |
| 259 !virtual_keyboard_tray_->visible()) { | |
| 260 tray->SetSeparatorVisibility(false); | |
|
varkha
2016/08/10 23:27:24
nit: collapse into a single method invocation, i.e
yiyix
2016/08/11 01:23:18
This function is re-write with indices. I will kee
| |
| 261 } else { | |
| 262 tray->SetSeparatorVisibility(true); | |
| 263 } | |
| 264 } | |
|
James Cook
2016/08/09 00:25:17
Is there a way to do this based on getting the tra
yiyix
2016/08/11 01:23:18
I totally agree. I don't know anything about the l
| |
| 265 #endif | |
| 266 } | |
| 267 } | |
| 268 | |
| 245 } // namespace ash | 269 } // namespace ash |
| OLD | NEW |