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/ash_switches.h" | |
| 8 #include "ash/common/material_design/material_design_controller.h" | |
| 9 #include "ash/common/shelf/shelf_constants.h" | 7 #include "ash/common/shelf/shelf_constants.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 8 #include "ash/common/shelf/wm_shelf.h" |
| 11 #include "ash/common/shelf/wm_shelf_util.h" | 9 #include "ash/common/shelf/wm_shelf_util.h" |
| 12 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| 13 #include "ash/common/system/chromeos/palette/palette_tool.h" | |
| 14 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" | 11 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" |
| 15 #include "ash/common/system/chromeos/palette/palette_utils.h" | 12 #include "ash/common/system/chromeos/palette/palette_utils.h" |
| 16 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
| 17 #include "ash/common/system/tray/tray_bubble_wrapper.h" | 14 #include "ash/common/system/tray/tray_bubble_wrapper.h" |
| 18 #include "ash/common/system/tray/tray_constants.h" | 15 #include "ash/common/system/tray/tray_constants.h" |
| 19 #include "ash/common/system/tray/tray_popup_header_button.h" | 16 #include "ash/common/system/tray/tray_popup_header_button.h" |
| 20 #include "ash/common/wm_lookup.h" | 17 #include "ash/common/wm_lookup.h" |
| 21 #include "ash/common/wm_root_window_controller.h" | 18 #include "ash/common/wm_root_window_controller.h" |
| 22 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 23 #include "ash/common/wm_window.h" | 20 #include "ash/common/wm_window.h" |
| 24 #include "base/command_line.h" | |
| 25 #include "base/sys_info.h" | |
| 26 #include "grit/ash_resources.h" | 21 #include "grit/ash_resources.h" |
| 27 #include "grit/ash_strings.h" | 22 #include "grit/ash_strings.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/gfx/paint_vector_icon.h" | 25 #include "ui/gfx/paint_vector_icon.h" |
| 31 #include "ui/views/controls/image_view.h" | 26 #include "ui/views/controls/image_view.h" |
| 32 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
| 33 #include "ui/views/controls/separator.h" | 28 #include "ui/views/controls/separator.h" |
| 34 #include "ui/views/layout/box_layout.h" | 29 #include "ui/views/layout/box_layout.h" |
| 35 #include "ui/views/layout/fill_layout.h" | 30 #include "ui/views/layout/fill_layout.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 53 const int kSeparatorInset = 10; | 48 const int kSeparatorInset = 10; |
| 54 | 49 |
| 55 views::Separator* separator = | 50 views::Separator* separator = |
| 56 new views::Separator(views::Separator::HORIZONTAL); | 51 new views::Separator(views::Separator::HORIZONTAL); |
| 57 separator->SetColor(ash::kBorderDarkColor); | 52 separator->SetColor(ash::kBorderDarkColor); |
| 58 separator->SetBorder( | 53 separator->SetBorder( |
| 59 views::Border::CreateEmptyBorder(kSeparatorInset, 0, kSeparatorInset, 0)); | 54 views::Border::CreateEmptyBorder(kSeparatorInset, 0, kSeparatorInset, 0)); |
| 60 return separator; | 55 return separator; |
| 61 } | 56 } |
| 62 | 57 |
| 63 // Creates the title-bar view. | 58 class TitleView : public views::View, public views::ButtonListener { |
| 64 views::View* CreateTitleView() { | 59 public: |
| 65 auto& rb = ui::ResourceBundle::GetSharedInstance(); | 60 TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { |
|
oshima
2016/08/10 20:22:44
explicit
jdufault
2016/08/11 18:55:18
Done.
| |
| 61 auto& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 66 | 62 |
| 67 auto* root = new views::View(); | 63 auto* box_layout = |
| 68 auto* box_layout = | 64 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| 69 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 65 SetLayoutManager(box_layout); |
| 70 root->SetLayoutManager(box_layout); | 66 SetBorder(views::Border::CreateEmptyBorder( |
| 71 root->SetBorder(views::Border::CreateEmptyBorder( | 67 0, ash::kTrayPopupPaddingHorizontal, 0, 0)); |
| 72 0, ash::kTrayPopupPaddingHorizontal, 0, 0)); | |
| 73 | 68 |
| 74 views::Label* text_label = | 69 views::Label* text_label = |
| 75 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_PALETTE_TITLE)); | 70 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_PALETTE_TITLE)); |
| 76 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 71 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 77 text_label->SetFontList(rb.GetFontList(ui::ResourceBundle::BoldFont)); | 72 text_label->SetFontList(rb.GetFontList(ui::ResourceBundle::BoldFont)); |
| 78 root->AddChildView(text_label); | 73 AddChildView(text_label); |
| 79 box_layout->SetFlexForView(text_label, 1); | 74 box_layout->SetFlexForView(text_label, 1); |
| 80 | 75 |
| 81 // TODO(jdufault): Use proper icons. | 76 help_button_ = new ash::TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_HELP, |
| 82 ash::TrayPopupHeaderButton* help_button = new ash::TrayPopupHeaderButton( | 77 IDS_ASH_STATUS_TRAY_HELP); |
| 83 nullptr, IDR_AURA_UBER_TRAY_SHUTDOWN, IDR_AURA_UBER_TRAY_SHUTDOWN, | 78 help_button_->SetTooltipText( |
| 84 IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, | 79 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SHUTDOWN)); |
| 85 IDS_ASH_STATUS_TRAY_SHUTDOWN); | 80 AddChildView(help_button_); |
| 86 help_button->SetTooltipText( | |
| 87 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SHUTDOWN)); | |
| 88 root->AddChildView(help_button); | |
| 89 | 81 |
| 90 root->AddChildView(CreateSeparator(views::Separator::VERTICAL)); | 82 AddChildView(CreateSeparator(views::Separator::VERTICAL)); |
| 91 | 83 |
| 92 // TODO(jdufault): Use proper icons. | 84 settings_button_ = new ash::TrayPopupHeaderButton( |
| 93 ash::TrayPopupHeaderButton* settings_button = new ash::TrayPopupHeaderButton( | 85 this, IDR_AURA_UBER_TRAY_SETTINGS, IDS_ASH_STATUS_TRAY_SETTINGS); |
| 94 nullptr, IDR_AURA_UBER_TRAY_SHUTDOWN, IDR_AURA_UBER_TRAY_SHUTDOWN, | 86 settings_button_->SetTooltipText( |
| 95 IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, | 87 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SETTINGS)); |
| 96 IDS_ASH_STATUS_TRAY_SHUTDOWN); | 88 AddChildView(settings_button_); |
| 97 settings_button->SetTooltipText( | 89 } |
| 98 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SHUTDOWN)); | |
| 99 root->AddChildView(settings_button); | |
| 100 | 90 |
| 101 return root; | 91 ~TitleView() override {} |
| 102 } | 92 |
| 93 private: | |
| 94 // views::ButtonListener: | |
| 95 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | |
| 96 if (sender == settings_button_) { | |
| 97 WmShell::Get()->system_tray_delegate()->ShowPaletteSettings(); | |
| 98 palette_tray_->HidePalette(); | |
| 99 } else if (sender == help_button_) { | |
| 100 WmShell::Get()->system_tray_delegate()->ShowPaletteHelp(); | |
| 101 palette_tray_->HidePalette(); | |
| 102 } else { | |
| 103 NOTREACHED(); | |
| 104 } | |
| 105 } | |
| 106 | |
| 107 // Unowned pointers to button views so we can determine which button was | |
| 108 // clicked. | |
| 109 ash::TrayPopupHeaderButton* settings_button_; | |
| 110 ash::TrayPopupHeaderButton* help_button_; | |
| 111 PaletteTray* palette_tray_; | |
| 112 | |
| 113 DISALLOW_COPY_AND_ASSIGN(TitleView); | |
| 114 }; | |
| 103 | 115 |
| 104 } // namespace | 116 } // namespace |
| 105 | 117 |
| 106 PaletteTray::PaletteTray(WmShelf* wm_shelf) | 118 PaletteTray::PaletteTray(WmShelf* wm_shelf) |
| 107 : TrayBackgroundView(wm_shelf), | 119 : TrayBackgroundView(wm_shelf), |
| 108 palette_tool_manager_(new PaletteToolManager(this)) { | 120 palette_tool_manager_(new PaletteToolManager(this)) { |
| 109 PaletteTool::RegisterToolInstances(palette_tool_manager_.get()); | 121 PaletteTool::RegisterToolInstances(palette_tool_manager_.get()); |
| 110 | 122 |
| 111 SetContentsBackground(); | 123 SetContentsBackground(); |
| 112 | 124 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 DCHECK(tray_container()); | 163 DCHECK(tray_container()); |
| 152 | 164 |
| 153 // Create view, customize it. | 165 // Create view, customize it. |
| 154 views::TrayBubbleView* bubble_view = | 166 views::TrayBubbleView* bubble_view = |
| 155 views::TrayBubbleView::Create(tray_container(), this, &init_params); | 167 views::TrayBubbleView::Create(tray_container(), this, &init_params); |
| 156 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 168 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
| 157 bubble_view->UseCompactMargins(); | 169 bubble_view->UseCompactMargins(); |
| 158 bubble_view->set_margins(gfx::Insets(bubble_view->margins().top(), 0, 0, 0)); | 170 bubble_view->set_margins(gfx::Insets(bubble_view->margins().top(), 0, 0, 0)); |
| 159 | 171 |
| 160 // Add child views. | 172 // Add child views. |
| 161 bubble_view->AddChildView(CreateTitleView()); | 173 bubble_view->AddChildView(new TitleView(this)); |
| 162 bubble_view->AddChildView(CreateSeparator(views::Separator::HORIZONTAL)); | 174 bubble_view->AddChildView(CreateSeparator(views::Separator::HORIZONTAL)); |
| 163 AddToolsToView(bubble_view); | 175 AddToolsToView(bubble_view); |
| 164 | 176 |
| 165 // Show the bubble. | 177 // Show the bubble. |
| 166 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view)); | 178 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view)); |
| 167 | 179 |
| 168 SetDrawBackgroundAsActive(true); | 180 SetDrawBackgroundAsActive(true); |
| 169 | 181 |
| 170 return true; | 182 return true; |
| 171 } | 183 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 WmShell::Get()->GetSessionStateDelegate(); | 316 WmShell::Get()->GetSessionStateDelegate(); |
| 305 | 317 |
| 306 SetVisible(!session_state_delegate->IsScreenLocked() && | 318 SetVisible(!session_state_delegate->IsScreenLocked() && |
| 307 session_state_delegate->GetSessionState() == | 319 session_state_delegate->GetSessionState() == |
| 308 SessionStateDelegate::SESSION_STATE_ACTIVE && | 320 SessionStateDelegate::SESSION_STATE_ACTIVE && |
| 309 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != | 321 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
| 310 LoginStatus::KIOSK_APP); | 322 LoginStatus::KIOSK_APP); |
| 311 } | 323 } |
| 312 | 324 |
| 313 } // namespace ash | 325 } // namespace ash |
| OLD | NEW |