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/material_design/material_design_controller.h" | |
| 7 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/shelf/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
| 9 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| 10 #include "ash/common/shelf/wm_shelf_util.h" | 11 #include "ash/common/shelf/wm_shelf_util.h" |
| 11 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" | 12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" |
| 12 #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" | |
| 13 #include "ash/common/system/tray/system_tray_controller.h" | 15 #include "ash/common/system/tray/system_tray_controller.h" |
| 14 #include "ash/common/system/tray/system_tray_delegate.h" | 16 #include "ash/common/system/tray/system_tray_delegate.h" |
| 15 #include "ash/common/system/tray/tray_bubble_wrapper.h" | 17 #include "ash/common/system/tray/tray_bubble_wrapper.h" |
| 16 #include "ash/common/system/tray/tray_constants.h" | 18 #include "ash/common/system/tray/tray_constants.h" |
| 17 #include "ash/common/system/tray/tray_popup_header_button.h" | 19 #include "ash/common/system/tray/tray_popup_header_button.h" |
| 20 #include "ash/common/system/tray/tray_popup_item_style.h" | |
| 18 #include "ash/common/wm_lookup.h" | 21 #include "ash/common/wm_lookup.h" |
| 19 #include "ash/common/wm_root_window_controller.h" | 22 #include "ash/common/wm_root_window_controller.h" |
| 20 #include "ash/common/wm_shell.h" | 23 #include "ash/common/wm_shell.h" |
| 21 #include "ash/common/wm_window.h" | 24 #include "ash/common/wm_window.h" |
| 22 #include "ash/public/cpp/shell_window_ids.h" | 25 #include "ash/public/cpp/shell_window_ids.h" |
| 23 #include "ash/resources/vector_icons/vector_icons.h" | 26 #include "ash/resources/vector_icons/vector_icons.h" |
| 24 #include "base/metrics/histogram_macros.h" | 27 #include "base/metrics/histogram_macros.h" |
| 25 #include "grit/ash_resources.h" | 28 #include "grit/ash_resources.h" |
| 26 #include "grit/ash_strings.h" | 29 #include "grit/ash_strings.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 bool IsInUserSession() { | 78 bool IsInUserSession() { |
| 76 SessionStateDelegate* session_state_delegate = | 79 SessionStateDelegate* session_state_delegate = |
| 77 WmShell::Get()->GetSessionStateDelegate(); | 80 WmShell::Get()->GetSessionStateDelegate(); |
| 78 return !session_state_delegate->IsUserSessionBlocked() && | 81 return !session_state_delegate->IsUserSessionBlocked() && |
| 79 session_state_delegate->GetSessionState() == | 82 session_state_delegate->GetSessionState() == |
| 80 session_manager::SessionState::ACTIVE && | 83 session_manager::SessionState::ACTIVE && |
| 81 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != | 84 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
| 82 LoginStatus::KIOSK_APP; | 85 LoginStatus::KIOSK_APP; |
| 83 } | 86 } |
| 84 | 87 |
| 85 // Returns the font used by the title view. | |
| 86 const gfx::FontList& GetTitleFont() { | |
| 87 // TODO(tdanderson|jdufault): Use TrayPopupItemStyle instead. | |
| 88 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( | |
| 89 2, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM); | |
| 90 } | |
| 91 | |
| 92 class TitleView : public views::View, public views::ButtonListener { | 88 class TitleView : public views::View, public views::ButtonListener { |
| 93 public: | 89 public: |
| 94 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { | 90 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { |
| 95 auto* box_layout = new views::BoxLayout( | 91 auto* box_layout = new views::BoxLayout( |
| 96 views::BoxLayout::kHorizontal, 0, kVerticalMarginAroundTitleView, | 92 views::BoxLayout::kHorizontal, 0, kVerticalMarginAroundTitleView, |
| 97 kHorizontalPaddingBetweenTitleEntries); | 93 kHorizontalPaddingBetweenTitleEntries); |
| 98 SetLayoutManager(box_layout); | 94 SetLayoutManager(box_layout); |
| 99 | 95 |
| 100 views::Label* text_label = | 96 views::Label* title_label = |
| 101 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); | 97 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); |
| 102 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 98 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 103 text_label->SetFontList(GetTitleFont()); | 99 TrayPopupItemStyle style(title_label->GetNativeTheme(), |
|
tdanderson
2016/11/16 20:44:16
Ditto to my previous comment, please introduce Upd
jdufault
2016/11/28 17:59:15
Done.
| |
| 104 AddChildView(text_label); | 100 TrayPopupItemStyle::FontStyle::TITLE); |
| 105 box_layout->SetFlexForView(text_label, 1); | 101 style.SetupLabel(title_label); |
| 102 AddChildView(title_label); | |
| 103 box_layout->SetFlexForView(title_label, 1); | |
|
tdanderson
2016/11/16 20:44:16
Please add a "TODO(tdanderson|jdufault): Use TriVi
jdufault
2016/11/28 17:59:15
Added TODO; I'll try to come back to this after no
| |
| 104 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | |
| 105 help_button_ = | |
| 106 new SystemMenuButton(this, SystemMenuButton::InkDropStyle::FLOOD_FILL, | |
|
tdanderson
2016/11/16 20:44:16
Since the help and settings button don't have a ve
jdufault
2016/11/28 17:59:15
Done.
| |
| 107 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP); | |
| 108 settings_button_ = new SystemMenuButton( | |
| 109 this, SystemMenuButton::InkDropStyle::FLOOD_FILL, | |
| 110 kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_SETTINGS); | |
| 111 } else { | |
| 112 gfx::ImageSkia help_icon = | |
| 113 gfx::CreateVectorIcon(kSystemMenuHelpIcon, kMenuIconColor); | |
| 114 gfx::ImageSkia settings_icon = | |
| 115 gfx::CreateVectorIcon(kSystemMenuSettingsIcon, kMenuIconColor); | |
| 106 | 116 |
| 107 gfx::ImageSkia settings_icon = | 117 auto* help_button = new ash::TrayPopupHeaderButton( |
| 108 gfx::CreateVectorIcon(kSystemMenuSettingsIcon, kMenuIconColor); | 118 this, help_icon, IDS_ASH_STATUS_TRAY_HELP); |
| 109 gfx::ImageSkia help_icon = | 119 help_button->SetTooltipText( |
| 110 gfx::CreateVectorIcon(kSystemMenuHelpIcon, kMenuIconColor); | 120 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HELP)); |
| 121 help_button_ = help_button; | |
| 111 | 122 |
| 112 help_button_ = new ash::TrayPopupHeaderButton(this, help_icon, | 123 auto* settings_button = new ash::TrayPopupHeaderButton( |
| 113 IDS_ASH_STATUS_TRAY_HELP); | 124 this, settings_icon, IDS_ASH_STATUS_TRAY_SETTINGS); |
| 114 help_button_->SetTooltipText( | 125 settings_button->SetTooltipText( |
| 115 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HELP)); | 126 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SETTINGS)); |
| 127 settings_button_ = settings_button; | |
| 128 } | |
| 129 | |
| 116 AddChildView(help_button_); | 130 AddChildView(help_button_); |
| 117 | |
| 118 settings_button_ = new ash::TrayPopupHeaderButton( | |
| 119 this, settings_icon, IDS_ASH_STATUS_TRAY_SETTINGS); | |
| 120 settings_button_->SetTooltipText( | |
| 121 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SETTINGS)); | |
| 122 AddChildView(settings_button_); | 131 AddChildView(settings_button_); |
| 123 } | 132 } |
| 124 | 133 |
| 125 ~TitleView() override {} | 134 ~TitleView() override {} |
| 126 | 135 |
| 127 private: | 136 private: |
| 128 // views::ButtonListener: | 137 // views::ButtonListener: |
| 129 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 138 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 130 if (sender == settings_button_) { | 139 if (sender == settings_button_) { |
| 131 palette_tray_->RecordPaletteOptionsUsage( | 140 palette_tray_->RecordPaletteOptionsUsage( |
| 132 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON); | 141 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON); |
| 133 WmShell::Get()->system_tray_controller()->ShowPaletteSettings(); | 142 WmShell::Get()->system_tray_controller()->ShowPaletteSettings(); |
| 134 palette_tray_->HidePalette(); | 143 palette_tray_->HidePalette(); |
| 135 } else if (sender == help_button_) { | 144 } else if (sender == help_button_) { |
| 136 palette_tray_->RecordPaletteOptionsUsage( | 145 palette_tray_->RecordPaletteOptionsUsage( |
| 137 PaletteTrayOptions::PALETTE_HELP_BUTTON); | 146 PaletteTrayOptions::PALETTE_HELP_BUTTON); |
| 138 WmShell::Get()->system_tray_controller()->ShowPaletteHelp(); | 147 WmShell::Get()->system_tray_controller()->ShowPaletteHelp(); |
| 139 palette_tray_->HidePalette(); | 148 palette_tray_->HidePalette(); |
| 140 } else { | 149 } else { |
| 141 NOTREACHED(); | 150 NOTREACHED(); |
| 142 } | 151 } |
| 143 } | 152 } |
| 144 | 153 |
| 145 // Unowned pointers to button views so we can determine which button was | 154 // Unowned pointers to button views so we can determine which button was |
| 146 // clicked. | 155 // clicked. |
| 147 ash::TrayPopupHeaderButton* settings_button_; | 156 views::View* settings_button_; |
| 148 ash::TrayPopupHeaderButton* help_button_; | 157 views::View* help_button_; |
| 149 PaletteTray* palette_tray_; | 158 PaletteTray* palette_tray_; |
| 150 | 159 |
| 151 DISALLOW_COPY_AND_ASSIGN(TitleView); | 160 DISALLOW_COPY_AND_ASSIGN(TitleView); |
| 152 }; | 161 }; |
| 153 | 162 |
| 154 } // namespace | 163 } // namespace |
| 155 | 164 |
| 156 PaletteTray::PaletteTray(WmShelf* wm_shelf) | 165 PaletteTray::PaletteTray(WmShelf* wm_shelf) |
| 157 : TrayBackgroundView(wm_shelf), | 166 : TrayBackgroundView(wm_shelf), |
| 158 palette_tool_manager_(new PaletteToolManager(this)), | 167 palette_tool_manager_(new PaletteToolManager(this)), |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 } else { | 472 } else { |
| 464 UpdateIconVisibility(); | 473 UpdateIconVisibility(); |
| 465 } | 474 } |
| 466 } | 475 } |
| 467 | 476 |
| 468 void PaletteTray::UpdateIconVisibility() { | 477 void PaletteTray::UpdateIconVisibility() { |
| 469 SetVisible(IsInUserSession()); | 478 SetVisible(IsInUserSession()); |
| 470 } | 479 } |
| 471 | 480 |
| 472 } // namespace ash | 481 } // namespace ash |
| OLD | NEW |