Chromium Code Reviews| 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" |
| 21 #include "grit/ash_resources.h" | 23 #include "grit/ash_resources.h" |
| 22 #include "grit/ash_strings.h" | 24 #include "grit/ash_strings.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "ui/events/devices/stylus_state.h" | |
| 25 #include "ui/gfx/paint_vector_icon.h" | 28 #include "ui/gfx/paint_vector_icon.h" |
| 26 #include "ui/views/controls/image_view.h" | 29 #include "ui/views/controls/image_view.h" |
| 27 #include "ui/views/controls/label.h" | 30 #include "ui/views/controls/label.h" |
| 28 #include "ui/views/controls/separator.h" | 31 #include "ui/views/controls/separator.h" |
| 29 #include "ui/views/layout/box_layout.h" | 32 #include "ui/views/layout/box_layout.h" |
| 30 #include "ui/views/layout/fill_layout.h" | 33 #include "ui/views/layout/fill_layout.h" |
| 31 | 34 |
| 32 namespace ash { | 35 namespace ash { |
| 33 | 36 |
| 34 namespace { | 37 namespace { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 PaletteTray* palette_tray_; | 117 PaletteTray* palette_tray_; |
| 115 | 118 |
| 116 DISALLOW_COPY_AND_ASSIGN(TitleView); | 119 DISALLOW_COPY_AND_ASSIGN(TitleView); |
| 117 }; | 120 }; |
| 118 | 121 |
| 119 } // namespace | 122 } // namespace |
| 120 | 123 |
| 121 PaletteTray::PaletteTray(WmShelf* wm_shelf) | 124 PaletteTray::PaletteTray(WmShelf* wm_shelf) |
| 122 : TrayBackgroundView(wm_shelf), | 125 : TrayBackgroundView(wm_shelf), |
| 123 palette_tool_manager_(new PaletteToolManager(this)) { | 126 palette_tool_manager_(new PaletteToolManager(this)) { |
| 127 eject_controller_.reset(new EjectController( | |
| 128 base::Bind(&PaletteTray::OnStylusEject, base::Unretained(this)))); | |
| 129 | |
| 124 PaletteTool::RegisterToolInstances(palette_tool_manager_.get()); | 130 PaletteTool::RegisterToolInstances(palette_tool_manager_.get()); |
| 125 | 131 |
| 126 SetContentsBackground(); | 132 SetContentsBackground(); |
| 127 | 133 |
| 128 SetLayoutManager(new views::FillLayout()); | 134 SetLayoutManager(new views::FillLayout()); |
| 129 icon_ = new views::ImageView(); | 135 icon_ = new views::ImageView(); |
| 130 UpdateTrayIcon(); | 136 UpdateTrayIcon(); |
| 131 | 137 |
| 132 SetIconBorderForShelfAlignment(); | 138 SetIconBorderForShelfAlignment(); |
| 133 tray_container()->AddChildView(icon_); | 139 tray_container()->AddChildView(icon_); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 host->AddChildView(view.view); | 209 host->AddChildView(view.view); |
| 204 } | 210 } |
| 205 } | 211 } |
| 206 | 212 |
| 207 void PaletteTray::SessionStateChanged( | 213 void PaletteTray::SessionStateChanged( |
| 208 SessionStateDelegate::SessionState state) { | 214 SessionStateDelegate::SessionState state) { |
| 209 UpdateIconVisibility(); | 215 UpdateIconVisibility(); |
| 210 } | 216 } |
| 211 | 217 |
| 212 void PaletteTray::ClickedOutsideBubble() { | 218 void PaletteTray::ClickedOutsideBubble() { |
| 213 HidePalette(); | 219 bubble_.reset(); |
| 214 } | 220 } |
| 215 | 221 |
| 216 base::string16 PaletteTray::GetAccessibleNameForTray() { | 222 base::string16 PaletteTray::GetAccessibleNameForTray() { |
| 217 return l10n_util::GetStringUTF16(IDS_ASH_PALETTE_TITLE); | 223 return l10n_util::GetStringUTF16(IDS_ASH_PALETTE_TITLE); |
| 218 } | 224 } |
| 219 | 225 |
| 220 void PaletteTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { | 226 void PaletteTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { |
| 221 if (bubble_->bubble_view() == bubble_view) | 227 if (bubble_->bubble_view() == bubble_view) |
| 222 bubble_.reset(); | 228 bubble_.reset(); |
| 223 } | 229 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); | 314 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); |
| 309 } | 315 } |
| 310 } | 316 } |
| 311 | 317 |
| 312 void PaletteTray::UpdateTrayIcon() { | 318 void PaletteTray::UpdateTrayIcon() { |
| 313 gfx::VectorIconId icon = palette_tool_manager_->GetActiveTrayIcon( | 319 gfx::VectorIconId icon = palette_tool_manager_->GetActiveTrayIcon( |
| 314 palette_tool_manager_->GetActiveTool(ash::PaletteGroup::MODE)); | 320 palette_tool_manager_->GetActiveTool(ash::PaletteGroup::MODE)); |
| 315 icon_->SetImage(CreateVectorIcon(icon, kShelfIconSize, kShelfIconColor)); | 321 icon_->SetImage(CreateVectorIcon(icon, kShelfIconSize, kShelfIconColor)); |
| 316 } | 322 } |
| 317 | 323 |
| 324 void PaletteTray::OnStylusEject(ui::StylusState stylus_state) { | |
| 325 if (!WmShell::Get()->palette_delegate()->ShouldAutoOpenPalette()) | |
| 326 return; | |
| 327 | |
| 328 if (stylus_state == ui::StylusState::REMOVED && !bubble_) | |
| 329 OpenBubble(); | |
| 330 | |
| 331 if (stylus_state == ui::StylusState::INSERTED && bubble_) | |
|
oshima
2016/08/24 23:38:50
nit: else if?
You may keep it if you prefer this
jdufault
2016/08/24 23:54:07
Done.
| |
| 332 bubble_.reset(); | |
| 333 } | |
| 334 | |
| 318 void PaletteTray::UpdateIconVisibility() { | 335 void PaletteTray::UpdateIconVisibility() { |
| 319 if (!IsPaletteEnabled()) | 336 if (!IsPaletteEnabled()) |
| 320 return; | 337 return; |
| 321 | 338 |
| 322 SessionStateDelegate* session_state_delegate = | 339 SessionStateDelegate* session_state_delegate = |
| 323 WmShell::Get()->GetSessionStateDelegate(); | 340 WmShell::Get()->GetSessionStateDelegate(); |
| 324 | 341 |
| 325 SetVisible(!session_state_delegate->IsScreenLocked() && | 342 SetVisible(!session_state_delegate->IsScreenLocked() && |
| 326 session_state_delegate->GetSessionState() == | 343 session_state_delegate->GetSessionState() == |
| 327 SessionStateDelegate::SESSION_STATE_ACTIVE && | 344 SessionStateDelegate::SESSION_STATE_ACTIVE && |
| 328 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != | 345 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
| 329 LoginStatus::KIOSK_APP); | 346 LoginStatus::KIOSK_APP); |
| 330 } | 347 } |
| 331 | 348 |
| 332 } // namespace ash | 349 } // namespace ash |
| OLD | NEW |