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/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_controller.h" |
9 #include "ash/common/shelf/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
11 #include "ash/common/shelf/wm_shelf_util.h" | 11 #include "ash/common/shelf/wm_shelf_util.h" |
12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" | 12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" |
13 #include "ash/common/system/chromeos/palette/palette_utils.h" | 13 #include "ash/common/system/chromeos/palette/palette_utils.h" |
14 #include "ash/common/system/tray/system_menu_button.h" | 14 #include "ash/common/system/tray/system_menu_button.h" |
15 #include "ash/common/system/tray/system_tray_controller.h" | 15 #include "ash/common/system/tray/system_tray_controller.h" |
16 #include "ash/common/system/tray/system_tray_delegate.h" | 16 #include "ash/common/system/tray/system_tray_delegate.h" |
17 #include "ash/common/system/tray/tray_bubble_wrapper.h" | 17 #include "ash/common/system/tray/tray_bubble_wrapper.h" |
18 #include "ash/common/system/tray/tray_constants.h" | 18 #include "ash/common/system/tray/tray_constants.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 // Margins between the title view and the edges around it (dp). | 57 // Margins between the title view and the edges around it (dp). |
58 constexpr int kPaddingBetweenTitleAndLeftEdge = 12; | 58 constexpr int kPaddingBetweenTitleAndLeftEdge = 12; |
59 constexpr int kPaddingBetweenTitleAndSeparator = 3; | 59 constexpr int kPaddingBetweenTitleAndSeparator = 3; |
60 | 60 |
61 // Color of the separator. | 61 // Color of the separator. |
62 const SkColor kPaletteSeparatorColor = SkColorSetARGB(0x1E, 0x00, 0x00, 0x00); | 62 const SkColor kPaletteSeparatorColor = SkColorSetARGB(0x1E, 0x00, 0x00, 0x00); |
63 | 63 |
64 // Returns true if we are in a user session that can show the stylus tools. | 64 // Returns true if we are in a user session that can show the stylus tools. |
65 bool IsInUserSession() { | 65 bool IsInUserSession() { |
66 SessionStateDelegate* session_state_delegate = | 66 SessionController* session_controller = WmShell::Get()->session_controller(); |
67 WmShell::Get()->GetSessionStateDelegate(); | 67 return !session_controller->IsUserSessionBlocked() && |
68 return !session_state_delegate->IsUserSessionBlocked() && | 68 session_controller->GetSessionState() == |
69 session_state_delegate->GetSessionState() == | |
70 session_manager::SessionState::ACTIVE && | 69 session_manager::SessionState::ACTIVE && |
71 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != | 70 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
72 LoginStatus::KIOSK_APP; | 71 LoginStatus::KIOSK_APP; |
73 } | 72 } |
74 | 73 |
75 class TitleView : public views::View, public views::ButtonListener { | 74 class TitleView : public views::View, public views::ButtonListener { |
76 public: | 75 public: |
77 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { | 76 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { |
78 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. | 77 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. |
79 // See crbug.com/614453. | 78 // See crbug.com/614453. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 SetInkDropMode(InkDropMode::ON); | 158 SetInkDropMode(InkDropMode::ON); |
160 | 159 |
161 SetLayoutManager(new views::FillLayout()); | 160 SetLayoutManager(new views::FillLayout()); |
162 icon_ = new views::ImageView(); | 161 icon_ = new views::ImageView(); |
163 UpdateTrayIcon(); | 162 UpdateTrayIcon(); |
164 | 163 |
165 tray_container()->SetMargin(kTrayIconMainAxisInset, kTrayIconCrossAxisInset); | 164 tray_container()->SetMargin(kTrayIconMainAxisInset, kTrayIconCrossAxisInset); |
166 tray_container()->AddChildView(icon_); | 165 tray_container()->AddChildView(icon_); |
167 | 166 |
168 Shell::GetInstance()->AddShellObserver(this); | 167 Shell::GetInstance()->AddShellObserver(this); |
169 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); | 168 WmShell::Get()->session_controller()->AddSessionStateObserver(this); |
170 ui::InputDeviceManager::GetInstance()->AddObserver(this); | 169 ui::InputDeviceManager::GetInstance()->AddObserver(this); |
171 } | 170 } |
172 | 171 |
173 PaletteTray::~PaletteTray() { | 172 PaletteTray::~PaletteTray() { |
174 if (bubble_) | 173 if (bubble_) |
175 bubble_->bubble_view()->reset_delegate(); | 174 bubble_->bubble_view()->reset_delegate(); |
176 | 175 |
177 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); | 176 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); |
178 Shell::GetInstance()->RemoveShellObserver(this); | 177 Shell::GetInstance()->RemoveShellObserver(this); |
179 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this); | 178 WmShell::Get()->session_controller()->RemoveSessionStateObserver(this); |
180 } | 179 } |
181 | 180 |
182 bool PaletteTray::PerformAction(const ui::Event& event) { | 181 bool PaletteTray::PerformAction(const ui::Event& event) { |
183 if (bubble_) { | 182 if (bubble_) { |
184 if (num_actions_in_bubble_ == 0) | 183 if (num_actions_in_bubble_ == 0) |
185 RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION); | 184 RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION); |
186 HidePalette(); | 185 HidePalette(); |
187 return true; | 186 return true; |
188 } | 187 } |
189 | 188 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 UpdateIconVisibility(); | 423 UpdateIconVisibility(); |
425 } | 424 } |
426 } | 425 } |
427 | 426 |
428 void PaletteTray::UpdateIconVisibility() { | 427 void PaletteTray::UpdateIconVisibility() { |
429 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && | 428 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && |
430 IsInUserSession()); | 429 IsInUserSession()); |
431 } | 430 } |
432 | 431 |
433 } // namespace ash | 432 } // namespace ash |
OLD | NEW |