OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/palette/palette_tray.h" | 5 #include "ash/common/system/chromeos/palette/palette_tray.h" |
6 | 6 |
7 #include "ash/common/palette_delegate.h" | |
7 #include "ash/common/shelf/shelf_constants.h" | 8 #include "ash/common/shelf/shelf_constants.h" |
8 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
9 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
10 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
12 #include "ash/common/system/chromeos/palette/eject_controller.h" | |
11 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" | 13 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" |
12 #include "ash/common/system/chromeos/palette/palette_utils.h" | 14 #include "ash/common/system/chromeos/palette/palette_utils.h" |
13 #include "ash/common/system/tray/system_tray_delegate.h" | 15 #include "ash/common/system/tray/system_tray_delegate.h" |
14 #include "ash/common/system/tray/tray_bubble_wrapper.h" | 16 #include "ash/common/system/tray/tray_bubble_wrapper.h" |
15 #include "ash/common/system/tray/tray_constants.h" | 17 #include "ash/common/system/tray/tray_constants.h" |
16 #include "ash/common/system/tray/tray_popup_header_button.h" | 18 #include "ash/common/system/tray/tray_popup_header_button.h" |
17 #include "ash/common/wm_lookup.h" | 19 #include "ash/common/wm_lookup.h" |
18 #include "ash/common/wm_root_window_controller.h" | 20 #include "ash/common/wm_root_window_controller.h" |
19 #include "ash/common/wm_shell.h" | 21 #include "ash/common/wm_shell.h" |
20 #include "ash/common/wm_window.h" | 22 #include "ash/common/wm_window.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 PaletteTray* palette_tray_; | 113 PaletteTray* palette_tray_; |
112 | 114 |
113 DISALLOW_COPY_AND_ASSIGN(TitleView); | 115 DISALLOW_COPY_AND_ASSIGN(TitleView); |
114 }; | 116 }; |
115 | 117 |
116 } // namespace | 118 } // namespace |
117 | 119 |
118 PaletteTray::PaletteTray(WmShelf* wm_shelf) | 120 PaletteTray::PaletteTray(WmShelf* wm_shelf) |
119 : TrayBackgroundView(wm_shelf), | 121 : TrayBackgroundView(wm_shelf), |
120 palette_tool_manager_(new PaletteToolManager(this)) { | 122 palette_tool_manager_(new PaletteToolManager(this)) { |
123 eject_controller_.reset(new EjectController( | |
124 base::Bind(&PaletteTray::OnEject, base::Unretained(this)))); | |
125 | |
121 PaletteTool::RegisterToolInstances(palette_tool_manager_.get()); | 126 PaletteTool::RegisterToolInstances(palette_tool_manager_.get()); |
122 | 127 |
123 SetContentsBackground(); | 128 SetContentsBackground(); |
124 | 129 |
125 SetLayoutManager(new views::FillLayout()); | 130 SetLayoutManager(new views::FillLayout()); |
126 icon_ = new views::ImageView(); | 131 icon_ = new views::ImageView(); |
127 UpdateTrayIcon(); | 132 UpdateTrayIcon(); |
128 | 133 |
129 SetIconBorderForShelfAlignment(); | 134 SetIconBorderForShelfAlignment(); |
130 tray_container()->AddChildView(icon_); | 135 tray_container()->AddChildView(icon_); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 ->GetWindowForWidget(anchor_widget) | 263 ->GetWindowForWidget(anchor_widget) |
259 ->GetRootWindowController() | 264 ->GetRootWindowController() |
260 ->ConfigureWidgetInitParamsForContainer( | 265 ->ConfigureWidgetInitParamsForContainer( |
261 bubble_widget, kShellWindowId_SettingBubbleContainer, params); | 266 bubble_widget, kShellWindowId_SettingBubbleContainer, params); |
262 } | 267 } |
263 | 268 |
264 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 269 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
265 HideBubbleWithView(bubble_view); | 270 HideBubbleWithView(bubble_view); |
266 } | 271 } |
267 | 272 |
268 void PaletteTray::HidePalette() { | 273 void PaletteTray::HidePalette() { |
stevenjb
2016/08/15 20:18:25
The name of this is extra confusing, it should pro
jdufault
2016/08/15 21:55:04
There's already a HideBubble(...) from views::Tray
stevenjb
2016/08/15 22:41:29
Oh, so there is. I didn't realize that this was a
jdufault
2016/08/16 00:02:18
I've changed all HidePalette calls to just call bu
| |
269 bubble_.reset(); | 274 bubble_.reset(); |
270 } | 275 } |
271 | 276 |
272 void PaletteTray::OnActiveToolChanged() { | 277 void PaletteTray::OnActiveToolChanged() { |
273 UpdateTrayIcon(); | 278 UpdateTrayIcon(); |
274 } | 279 } |
275 | 280 |
276 WmWindow* PaletteTray::GetWindow() { | 281 WmWindow* PaletteTray::GetWindow() { |
277 return shelf()->GetWindow(); | 282 return shelf()->GetWindow(); |
278 } | 283 } |
(...skipping 22 matching lines...) Expand all Loading... | |
301 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); | 306 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); |
302 } | 307 } |
303 } | 308 } |
304 | 309 |
305 void PaletteTray::UpdateTrayIcon() { | 310 void PaletteTray::UpdateTrayIcon() { |
306 gfx::VectorIconId icon = palette_tool_manager_->GetActiveTrayIcon( | 311 gfx::VectorIconId icon = palette_tool_manager_->GetActiveTrayIcon( |
307 palette_tool_manager_->GetActiveTool(ash::PaletteGroup::MODE)); | 312 palette_tool_manager_->GetActiveTool(ash::PaletteGroup::MODE)); |
308 icon_->SetImage(CreateVectorIcon(icon, kShelfIconColor)); | 313 icon_->SetImage(CreateVectorIcon(icon, kShelfIconColor)); |
309 } | 314 } |
310 | 315 |
316 void PaletteTray::OnEject(bool eject) { | |
317 if (!WmShell::Get()->palette_delegate()->ShouldAutoOpenPalette()) | |
318 return; | |
319 | |
320 if (eject && !bubble_) | |
321 OpenBubble(); | |
322 | |
323 if (!eject && bubble_) | |
324 HidePalette(); | |
325 } | |
326 | |
311 void PaletteTray::UpdateIconVisibility() { | 327 void PaletteTray::UpdateIconVisibility() { |
312 if (!IsPaletteEnabled()) | 328 if (!IsPaletteEnabled()) |
313 return; | 329 return; |
314 | 330 |
315 SessionStateDelegate* session_state_delegate = | 331 SessionStateDelegate* session_state_delegate = |
316 WmShell::Get()->GetSessionStateDelegate(); | 332 WmShell::Get()->GetSessionStateDelegate(); |
317 | 333 |
318 SetVisible(!session_state_delegate->IsScreenLocked() && | 334 SetVisible(!session_state_delegate->IsScreenLocked() && |
319 session_state_delegate->GetSessionState() == | 335 session_state_delegate->GetSessionState() == |
320 SessionStateDelegate::SESSION_STATE_ACTIVE && | 336 SessionStateDelegate::SESSION_STATE_ACTIVE && |
321 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != | 337 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
322 LoginStatus::KIOSK_APP); | 338 LoginStatus::KIOSK_APP); |
323 } | 339 } |
324 | 340 |
325 } // namespace ash | 341 } // namespace ash |
OLD | NEW |