| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tray/tray_details_view.h" | 5 #include "ash/common/system/tray/tray_details_view.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/system/tray/fixed_sized_scroll_view.h" | 8 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
| 9 #include "ash/common/system/tray/system_tray.h" | 9 #include "ash/common/system/tray/system_tray.h" |
| 10 #include "ash/common/system/tray/system_tray_item.h" | 10 #include "ash/common/system/tray/system_tray_item.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ScrollBorder); | 60 DISALLOW_COPY_AND_ASSIGN(ScrollBorder); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) | 63 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) |
| 64 : owner_(owner), | 64 : owner_(owner), |
| 65 title_row_(nullptr), | 65 title_row_(nullptr), |
| 66 scroller_(nullptr), | 66 scroller_(nullptr), |
| 67 scroll_content_(nullptr), | 67 scroll_content_(nullptr), |
| 68 scroll_border_(nullptr), | 68 scroll_border_(nullptr), |
| 69 back_button_(nullptr), | 69 back_button_(nullptr) { |
| 70 settings_button_(nullptr) { | |
| 71 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 70 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 72 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | 71 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
| 73 } | 72 } |
| 74 | 73 |
| 75 TrayDetailsView::~TrayDetailsView() {} | 74 TrayDetailsView::~TrayDetailsView() {} |
| 76 | 75 |
| 77 void TrayDetailsView::OnViewClicked(views::View* sender) { | 76 void TrayDetailsView::OnViewClicked(views::View* sender) { |
| 78 if (!MaterialDesignController::IsSystemTrayMenuMaterial() && title_row_ && | 77 if (!MaterialDesignController::IsSystemTrayMenuMaterial() && title_row_ && |
| 79 sender == title_row_->content()) { | 78 sender == title_row_->content()) { |
| 80 TransitionToDefaultView(); | 79 TransitionToDefaultView(); |
| 81 return; | 80 return; |
| 82 } | 81 } |
| 83 | 82 |
| 84 HandleViewClicked(sender); | 83 HandleViewClicked(sender); |
| 85 } | 84 } |
| 86 | 85 |
| 87 void TrayDetailsView::ButtonPressed(views::Button* sender, | 86 void TrayDetailsView::ButtonPressed(views::Button* sender, |
| 88 const ui::Event& event) { | 87 const ui::Event& event) { |
| 89 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 88 if (MaterialDesignController::IsSystemTrayMenuMaterial() && |
| 90 if (sender == back_button_) { | 89 sender == back_button_) { |
| 91 TransitionToDefaultView(); | 90 TransitionToDefaultView(); |
| 92 return; | 91 return; |
| 93 } else if (sender == settings_button_) { | |
| 94 ShowSettings(); | |
| 95 return; | |
| 96 } | |
| 97 } | 92 } |
| 98 | 93 |
| 99 HandleButtonPressed(sender, event); | 94 HandleButtonPressed(sender, event); |
| 100 } | 95 } |
| 101 | 96 |
| 102 void TrayDetailsView::CreateTitleRow(int string_id) { | 97 void TrayDetailsView::CreateTitleRow(int string_id) { |
| 103 DCHECK(!title_row_); | 98 DCHECK(!title_row_); |
| 104 const int child_view_position = | 99 const int child_view_position = |
| 105 MaterialDesignController::IsSystemTrayMenuMaterial() ? 0 : child_count(); | 100 MaterialDesignController::IsSystemTrayMenuMaterial() ? 0 : child_count(); |
| 106 title_row_ = new SpecialPopupRow(); | 101 title_row_ = new SpecialPopupRow(); |
| 107 title_row_->SetTextLabel(string_id, this); | 102 title_row_->SetTextLabel(string_id, this); |
| 108 | 103 |
| 109 AddChildViewAt(title_row_, child_view_position); | 104 AddChildViewAt(title_row_, child_view_position); |
| 110 | 105 |
| 111 CreateExtraTitleRowButtons(); | 106 CreateExtraTitleRowButtons(); |
| 112 | 107 |
| 113 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 108 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 114 back_button_ = title_row_->AddBackButton(this); | 109 back_button_ = title_row_->AddBackButton(this); |
| 115 settings_button_ = title_row_->AddSettingsButton(this); | |
| 116 } | |
| 117 | 110 |
| 118 Layout(); | 111 Layout(); |
| 119 } | 112 } |
| 120 | 113 |
| 121 void TrayDetailsView::CreateScrollableList() { | 114 void TrayDetailsView::CreateScrollableList() { |
| 122 DCHECK(!scroller_); | 115 DCHECK(!scroller_); |
| 123 scroll_content_ = new views::View; | 116 scroll_content_ = new views::View; |
| 124 scroll_content_->SetLayoutManager( | 117 scroll_content_->SetLayoutManager( |
| 125 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); | 118 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); |
| 126 scroller_ = new FixedSizedScrollView; | 119 scroller_ = new FixedSizedScrollView; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 140 if (scroll_content_->has_children()) | 133 if (scroll_content_->has_children()) |
| 141 scroll_content_->AddChildView(new ScrollSeparator); | 134 scroll_content_->AddChildView(new ScrollSeparator); |
| 142 } | 135 } |
| 143 | 136 |
| 144 void TrayDetailsView::Reset() { | 137 void TrayDetailsView::Reset() { |
| 145 RemoveAllChildViews(true); | 138 RemoveAllChildViews(true); |
| 146 title_row_ = nullptr; | 139 title_row_ = nullptr; |
| 147 scroller_ = nullptr; | 140 scroller_ = nullptr; |
| 148 scroll_content_ = nullptr; | 141 scroll_content_ = nullptr; |
| 149 back_button_ = nullptr; | 142 back_button_ = nullptr; |
| 150 settings_button_ = nullptr; | |
| 151 } | 143 } |
| 152 | 144 |
| 153 void TrayDetailsView::HandleViewClicked(views::View* view) {} | 145 void TrayDetailsView::HandleViewClicked(views::View* view) {} |
| 154 | 146 |
| 155 void TrayDetailsView::HandleButtonPressed(views::Button* sender, | 147 void TrayDetailsView::HandleButtonPressed(views::Button* sender, |
| 156 const ui::Event& event) {} | 148 const ui::Event& event) {} |
| 157 | 149 |
| 158 void TrayDetailsView::CreateExtraTitleRowButtons() {} | 150 void TrayDetailsView::CreateExtraTitleRowButtons() {} |
| 159 | 151 |
| 160 void TrayDetailsView::ShowSettings() { | |
| 161 // TODO(tdanderson): Store login status as a member in TrayDetailsView | |
| 162 // instead of its derived classes. Use this to perform an early return | |
| 163 // if launching WebUI settings is not permitted, and provide a default | |
| 164 // implementation to ShowSettings(). | |
| 165 } | |
| 166 | |
| 167 void TrayDetailsView::TransitionToDefaultView() { | 152 void TrayDetailsView::TransitionToDefaultView() { |
| 168 // Cache pointer to owner in this function scope. TrayDetailsView will be | 153 // Cache pointer to owner in this function scope. TrayDetailsView will be |
| 169 // deleted after called ShowDefaultView. | 154 // deleted after called ShowDefaultView. |
| 170 SystemTrayItem* owner = owner_; | 155 SystemTrayItem* owner = owner_; |
| 171 if (title_row_ && title_row_->content() && title_row_->content()->HasFocus()) | 156 if (title_row_ && title_row_->content() && title_row_->content()->HasFocus()) |
| 172 owner->set_restore_focus(true); | 157 owner->set_restore_focus(true); |
| 173 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); | 158 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
| 174 owner->set_restore_focus(false); | 159 owner->set_restore_focus(false); |
| 175 } | 160 } |
| 176 | 161 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 if (index < child_count() - 1 && child_at(index + 1) != title_row_) | 194 if (index < child_count() - 1 && child_at(index + 1) != title_row_) |
| 210 scroll_border_->set_visible(true); | 195 scroll_border_->set_visible(true); |
| 211 else | 196 else |
| 212 scroll_border_->set_visible(false); | 197 scroll_border_->set_visible(false); |
| 213 } | 198 } |
| 214 | 199 |
| 215 views::View::OnPaintBorder(canvas); | 200 views::View::OnPaintBorder(canvas); |
| 216 } | 201 } |
| 217 | 202 |
| 218 } // namespace ash | 203 } // namespace ash |
| OLD | NEW |