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_controller.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" |
(...skipping 45 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 SessionController* session_controller = WmShell::Get()->session_controller(); | 66 SessionController* session_controller = Shell::Get()->session_controller(); |
67 return !session_controller->IsUserSessionBlocked() && | 67 return !session_controller->IsUserSessionBlocked() && |
68 session_controller->GetSessionState() == | 68 session_controller->GetSessionState() == |
69 session_manager::SessionState::ACTIVE && | 69 session_manager::SessionState::ACTIVE && |
70 Shell::Get()->system_tray_delegate()->GetUserLoginStatus() != | 70 Shell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
71 LoginStatus::KIOSK_APP; | 71 LoginStatus::KIOSK_APP; |
72 } | 72 } |
73 | 73 |
74 class TitleView : public views::View, public views::ButtonListener { | 74 class TitleView : public views::View, public views::ButtonListener { |
75 public: | 75 public: |
76 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { | 76 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 SetInkDropMode(InkDropMode::ON); | 158 SetInkDropMode(InkDropMode::ON); |
159 | 159 |
160 SetLayoutManager(new views::FillLayout()); | 160 SetLayoutManager(new views::FillLayout()); |
161 icon_ = new views::ImageView(); | 161 icon_ = new views::ImageView(); |
162 UpdateTrayIcon(); | 162 UpdateTrayIcon(); |
163 | 163 |
164 tray_container()->SetMargin(kTrayIconMainAxisInset, kTrayIconCrossAxisInset); | 164 tray_container()->SetMargin(kTrayIconMainAxisInset, kTrayIconCrossAxisInset); |
165 tray_container()->AddChildView(icon_); | 165 tray_container()->AddChildView(icon_); |
166 | 166 |
167 Shell::GetInstance()->AddShellObserver(this); | 167 Shell::GetInstance()->AddShellObserver(this); |
168 WmShell::Get()->session_controller()->AddSessionStateObserver(this); | 168 Shell::Get()->session_controller()->AddSessionStateObserver(this); |
169 ui::InputDeviceManager::GetInstance()->AddObserver(this); | 169 ui::InputDeviceManager::GetInstance()->AddObserver(this); |
170 } | 170 } |
171 | 171 |
172 PaletteTray::~PaletteTray() { | 172 PaletteTray::~PaletteTray() { |
173 if (bubble_) | 173 if (bubble_) |
174 bubble_->bubble_view()->reset_delegate(); | 174 bubble_->bubble_view()->reset_delegate(); |
175 | 175 |
176 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); | 176 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); |
177 Shell::GetInstance()->RemoveShellObserver(this); | 177 Shell::GetInstance()->RemoveShellObserver(this); |
178 WmShell::Get()->session_controller()->RemoveSessionStateObserver(this); | 178 Shell::Get()->session_controller()->RemoveSessionStateObserver(this); |
179 } | 179 } |
180 | 180 |
181 bool PaletteTray::PerformAction(const ui::Event& event) { | 181 bool PaletteTray::PerformAction(const ui::Event& event) { |
182 if (bubble_) { | 182 if (bubble_) { |
183 if (num_actions_in_bubble_ == 0) | 183 if (num_actions_in_bubble_ == 0) |
184 RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION); | 184 RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION); |
185 HidePalette(); | 185 HidePalette(); |
186 return true; | 186 return true; |
187 } | 187 } |
188 | 188 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 UpdateIconVisibility(); | 427 UpdateIconVisibility(); |
428 } | 428 } |
429 } | 429 } |
430 | 430 |
431 void PaletteTray::UpdateIconVisibility() { | 431 void PaletteTray::UpdateIconVisibility() { |
432 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && | 432 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && |
433 IsInUserSession()); | 433 IsInUserSession()); |
434 } | 434 } |
435 | 435 |
436 } // namespace ash | 436 } // namespace ash |
OLD | NEW |