| 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_state_delegate.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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 void PaletteTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { | 281 void PaletteTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { |
| 282 if (bubble_->bubble_view() == bubble_view) | 282 if (bubble_->bubble_view() == bubble_view) |
| 283 HidePalette(); | 283 HidePalette(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void PaletteTray::OnTouchscreenDeviceConfigurationChanged() { | 286 void PaletteTray::OnTouchscreenDeviceConfigurationChanged() { |
| 287 UpdateIconVisibility(); | 287 UpdateIconVisibility(); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) { | 290 void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) { |
| 291 PaletteDelegate* palette_delegate = WmShell::Get()->palette_delegate(); | 291 PaletteDelegate* palette_delegate = Shell::GetInstance()->palette_delegate(); |
| 292 | 292 |
| 293 // Don't do anything if the palette should not be shown or if the user has | 293 // Don't do anything if the palette should not be shown or if the user has |
| 294 // disabled it all-together. | 294 // disabled it all-together. |
| 295 if (!IsInUserSession() || !palette_delegate->ShouldShowPalette()) | 295 if (!IsInUserSession() || !palette_delegate->ShouldShowPalette()) |
| 296 return; | 296 return; |
| 297 | 297 |
| 298 // Auto show/hide the palette if allowed by the user. | 298 // Auto show/hide the palette if allowed by the user. |
| 299 if (palette_delegate->ShouldAutoOpenPalette()) { | 299 if (palette_delegate->ShouldAutoOpenPalette()) { |
| 300 if (stylus_state == ui::StylusState::REMOVED && !bubble_) { | 300 if (stylus_state == ui::StylusState::REMOVED && !bubble_) { |
| 301 is_bubble_auto_opened_ = true; | 301 is_bubble_auto_opened_ = true; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 TrayBackgroundView::SetShelfAlignment(alignment); | 394 TrayBackgroundView::SetShelfAlignment(alignment); |
| 395 } | 395 } |
| 396 | 396 |
| 397 void PaletteTray::AnchorUpdated() { | 397 void PaletteTray::AnchorUpdated() { |
| 398 if (bubble_) | 398 if (bubble_) |
| 399 bubble_->bubble_view()->UpdateBubble(); | 399 bubble_->bubble_view()->UpdateBubble(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void PaletteTray::Initialize() { | 402 void PaletteTray::Initialize() { |
| 403 PaletteDelegate* delegate = WmShell::Get()->palette_delegate(); | 403 PaletteDelegate* delegate = Shell::GetInstance()->palette_delegate(); |
| 404 // |delegate| can be null in tests. | 404 // |delegate| can be null in tests. |
| 405 if (!delegate) | 405 if (!delegate) |
| 406 return; | 406 return; |
| 407 | 407 |
| 408 // OnPaletteEnabledPrefChanged will get called with the initial pref value, | 408 // OnPaletteEnabledPrefChanged will get called with the initial pref value, |
| 409 // which will take care of showing the palette. | 409 // which will take care of showing the palette. |
| 410 palette_enabled_subscription_ = delegate->AddPaletteEnableListener(base::Bind( | 410 palette_enabled_subscription_ = delegate->AddPaletteEnableListener(base::Bind( |
| 411 &PaletteTray::OnPaletteEnabledPrefChanged, weak_factory_.GetWeakPtr())); | 411 &PaletteTray::OnPaletteEnabledPrefChanged, weak_factory_.GetWeakPtr())); |
| 412 } | 412 } |
| 413 | 413 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 428 UpdateIconVisibility(); | 428 UpdateIconVisibility(); |
| 429 } | 429 } |
| 430 } | 430 } |
| 431 | 431 |
| 432 void PaletteTray::UpdateIconVisibility() { | 432 void PaletteTray::UpdateIconVisibility() { |
| 433 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && | 433 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && |
| 434 IsInUserSession()); | 434 IsInUserSession()); |
| 435 } | 435 } |
| 436 | 436 |
| 437 } // namespace ash | 437 } // namespace ash |
| OLD | NEW |