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/system/palette/palette_tray.h" | 5 #include "ash/system/palette/palette_tray.h" |
6 | 6 |
7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
8 #include "ash/resources/grit/ash_resources.h" | 8 #include "ash/resources/grit/ash_resources.h" |
9 #include "ash/resources/vector_icons/vector_icons.h" | 9 #include "ash/resources/vector_icons/vector_icons.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ash/system/tray/system_tray_delegate.h" | 21 #include "ash/system/tray/system_tray_delegate.h" |
22 #include "ash/system/tray/tray_bubble_wrapper.h" | 22 #include "ash/system/tray/tray_bubble_wrapper.h" |
23 #include "ash/system/tray/tray_constants.h" | 23 #include "ash/system/tray/tray_constants.h" |
24 #include "ash/system/tray/tray_container.h" | 24 #include "ash/system/tray/tray_container.h" |
25 #include "ash/system/tray/tray_popup_header_button.h" | 25 #include "ash/system/tray/tray_popup_header_button.h" |
26 #include "ash/system/tray/tray_popup_item_style.h" | 26 #include "ash/system/tray/tray_popup_item_style.h" |
27 #include "ash/wm_window.h" | 27 #include "ash/wm_window.h" |
28 #include "base/metrics/histogram_macros.h" | 28 #include "base/metrics/histogram_macros.h" |
29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
30 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 31 #include "ui/display/display.h" |
31 #include "ui/events/devices/input_device_manager.h" | 32 #include "ui/events/devices/input_device_manager.h" |
32 #include "ui/events/devices/stylus_state.h" | 33 #include "ui/events/devices/stylus_state.h" |
33 #include "ui/gfx/color_palette.h" | 34 #include "ui/gfx/color_palette.h" |
34 #include "ui/gfx/paint_vector_icon.h" | 35 #include "ui/gfx/paint_vector_icon.h" |
35 #include "ui/views/controls/image_view.h" | 36 #include "ui/views/controls/image_view.h" |
36 #include "ui/views/controls/label.h" | 37 #include "ui/views/controls/label.h" |
37 #include "ui/views/controls/separator.h" | 38 #include "ui/views/controls/separator.h" |
38 #include "ui/views/layout/box_layout.h" | 39 #include "ui/views/layout/box_layout.h" |
39 #include "ui/views/layout/fill_layout.h" | 40 #include "ui/views/layout/fill_layout.h" |
40 | 41 |
(...skipping 22 matching lines...) Expand all Loading... |
63 // 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. |
64 bool IsInUserSession() { | 65 bool IsInUserSession() { |
65 SessionController* session_controller = Shell::Get()->session_controller(); | 66 SessionController* session_controller = Shell::Get()->session_controller(); |
66 return !session_controller->IsUserSessionBlocked() && | 67 return !session_controller->IsUserSessionBlocked() && |
67 session_controller->GetSessionState() == | 68 session_controller->GetSessionState() == |
68 session_manager::SessionState::ACTIVE && | 69 session_manager::SessionState::ACTIVE && |
69 Shell::Get()->system_tray_delegate()->GetUserLoginStatus() != | 70 Shell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
70 LoginStatus::KIOSK_APP; | 71 LoginStatus::KIOSK_APP; |
71 } | 72 } |
72 | 73 |
| 74 // Returns true if the |palette_tray| is on an internal display or on every |
| 75 // display if requested from the command line. |
| 76 bool ShouldShowOnDisplay(PaletteTray* palette_tray) { |
| 77 const display::Display& display = |
| 78 WmWindow::Get(palette_tray->GetWidget()->GetNativeWindow()) |
| 79 ->GetDisplayNearestWindow(); |
| 80 return display.IsInternal() || |
| 81 palette_utils::IsPaletteEnabledOnEveryDisplay(); |
| 82 } |
| 83 |
73 class TitleView : public views::View, public views::ButtonListener { | 84 class TitleView : public views::View, public views::ButtonListener { |
74 public: | 85 public: |
75 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { | 86 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { |
76 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. | 87 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. |
77 // See crbug.com/614453. | 88 // See crbug.com/614453. |
78 auto* box_layout = | 89 auto* box_layout = |
79 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 90 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
80 SetLayoutManager(box_layout); | 91 SetLayoutManager(box_layout); |
81 | 92 |
82 auto* title_label = | 93 auto* title_label = |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 if (!enabled) { | 404 if (!enabled) { |
394 SetVisible(false); | 405 SetVisible(false); |
395 palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE); | 406 palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE); |
396 } else { | 407 } else { |
397 UpdateIconVisibility(); | 408 UpdateIconVisibility(); |
398 } | 409 } |
399 } | 410 } |
400 | 411 |
401 void PaletteTray::UpdateIconVisibility() { | 412 void PaletteTray::UpdateIconVisibility() { |
402 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && | 413 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && |
403 IsInUserSession()); | 414 ShouldShowOnDisplay(this) && IsInUserSession()); |
404 } | 415 } |
405 | 416 |
406 } // namespace ash | 417 } // namespace ash |
OLD | NEW |