| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ui/message_center/views/notification_header_view.h" | 5 #include "ui/message_center/views/notification_header_view.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
| 10 #include "ui/gfx/color_palette.h" | 10 #include "ui/gfx/color_palette.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 app_icon_view_->SetImage(img); | 140 app_icon_view_->SetImage(img); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void NotificationHeaderView::SetAppName(const base::string16& name) { | 143 void NotificationHeaderView::SetAppName(const base::string16& name) { |
| 144 app_name_view_->SetText(name); | 144 app_name_view_->SetText(name); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void NotificationHeaderView::SetProgress(int progress) { | 147 void NotificationHeaderView::SetProgress(int progress) { |
| 148 summary_text_view_->SetText(l10n_util::GetStringFUTF16Int( | 148 summary_text_view_->SetText(l10n_util::GetStringFUTF16Int( |
| 149 IDS_MESSAGE_CENTER_NOTIFICATION_PROGRESS_PERCENTAGE, progress)); | 149 IDS_MESSAGE_CENTER_NOTIFICATION_PROGRESS_PERCENTAGE, progress)); |
| 150 has_summary_text_ = true; | 150 has_progress_ = true; |
| 151 UpdateSummaryTextVisibility(); | 151 UpdateSummaryTextVisibility(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void NotificationHeaderView::ClearProgress() { | 154 void NotificationHeaderView::ClearProgress() { |
| 155 has_summary_text_ = false; | 155 has_progress_ = false; |
| 156 UpdateSummaryTextVisibility(); | 156 UpdateSummaryTextVisibility(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void NotificationHeaderView::SetOverflowIndicator(int count) { |
| 160 if (count > 0) { |
| 161 summary_text_view_->SetText(l10n_util::GetStringFUTF16Int( |
| 162 IDS_MESSAGE_CENTER_LIST_NOTIFICATION_HEADER_OVERFLOW_INDICATOR, count)); |
| 163 has_overflow_indicator_ = true; |
| 164 } else { |
| 165 has_overflow_indicator_ = false; |
| 166 } |
| 167 UpdateSummaryTextVisibility(); |
| 168 } |
| 169 |
| 170 void NotificationHeaderView::ClearOverflowIndicator() { |
| 171 has_overflow_indicator_ = false; |
| 172 UpdateSummaryTextVisibility(); |
| 173 } |
| 174 |
| 159 void NotificationHeaderView::SetExpandButtonEnabled(bool enabled) { | 175 void NotificationHeaderView::SetExpandButtonEnabled(bool enabled) { |
| 160 expand_button_->SetVisible(enabled); | 176 expand_button_->SetVisible(enabled); |
| 161 } | 177 } |
| 162 | 178 |
| 163 void NotificationHeaderView::SetExpanded(bool expanded) { | 179 void NotificationHeaderView::SetExpanded(bool expanded) { |
| 164 expand_button_->SetImage( | 180 expand_button_->SetImage( |
| 165 views::Button::STATE_NORMAL, | 181 views::Button::STATE_NORMAL, |
| 166 gfx::CreateVectorIcon( | 182 gfx::CreateVectorIcon( |
| 167 expanded ? kNotificationExpandLessIcon : kNotificationExpandMoreIcon, | 183 expanded ? kNotificationExpandLessIcon : kNotificationExpandMoreIcon, |
| 168 kExpandIconSize, gfx::kChromeIconGrey)); | 184 kExpandIconSize, gfx::kChromeIconGrey)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 243 |
| 228 void NotificationHeaderView::UpdateControlButtonsVisibility() { | 244 void NotificationHeaderView::UpdateControlButtonsVisibility() { |
| 229 settings_button_->SetVisible(settings_button_enabled_ && | 245 settings_button_->SetVisible(settings_button_enabled_ && |
| 230 is_control_buttons_visible_); | 246 is_control_buttons_visible_); |
| 231 close_button_->SetVisible(close_button_enabled_ && | 247 close_button_->SetVisible(close_button_enabled_ && |
| 232 is_control_buttons_visible_); | 248 is_control_buttons_visible_); |
| 233 Layout(); | 249 Layout(); |
| 234 } | 250 } |
| 235 | 251 |
| 236 void NotificationHeaderView::UpdateSummaryTextVisibility() { | 252 void NotificationHeaderView::UpdateSummaryTextVisibility() { |
| 237 summary_text_divider_->SetVisible(has_summary_text_); | 253 const bool visible = has_progress_ || has_overflow_indicator_; |
| 238 summary_text_view_->SetVisible(has_summary_text_); | 254 summary_text_divider_->SetVisible(visible); |
| 255 summary_text_view_->SetVisible(visible); |
| 239 Layout(); | 256 Layout(); |
| 240 } | 257 } |
| 241 | 258 |
| 242 } // namespace message_center | 259 } // namespace message_center |
| OLD | NEW |