Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2785)

Unified Diff: ash/system/tray/hover_highlight_view.cc

Issue 2865533002: Reset HoverHighlightView state before re-populating (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/hover_highlight_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/hover_highlight_view.cc
diff --git a/ash/system/tray/hover_highlight_view.cc b/ash/system/tray/hover_highlight_view.cc
index 9df8b65220fa81c92ba89ccc264a8bcfec8ff6d5..5fb9079e4f2a8e5b4ba5b570cc0755e03ef41fbe 100644
--- a/ash/system/tray/hover_highlight_view.cc
+++ b/ash/system/tray/hover_highlight_view.cc
@@ -31,6 +31,7 @@ HoverHighlightView::~HoverHighlightView() {}
void HoverHighlightView::AddRightIcon(const gfx::ImageSkia& image,
int icon_size) {
+ DCHECK(is_populated_);
DCHECK(!right_view_);
views::ImageView* right_icon = TrayPopupUtils::CreateMainImageView();
@@ -39,6 +40,7 @@ void HoverHighlightView::AddRightIcon(const gfx::ImageSkia& image,
}
void HoverHighlightView::AddRightView(views::View* view) {
+ DCHECK(is_populated_);
DCHECK(!right_view_);
right_view_ = view;
@@ -48,6 +50,7 @@ void HoverHighlightView::AddRightView(views::View* view) {
}
void HoverHighlightView::SetRightViewVisible(bool visible) {
+ DCHECK(is_populated_);
if (!right_view_)
return;
@@ -56,6 +59,7 @@ void HoverHighlightView::SetRightViewVisible(bool visible) {
}
void HoverHighlightView::SetSubText(const base::string16& sub_text) {
+ DCHECK(is_populated_);
DCHECK(text_label_);
DCHECK(!sub_text.empty());
@@ -103,6 +107,9 @@ void HoverHighlightView::DoAddIconAndLabels(
const base::string16& text,
TrayPopupItemStyle::FontStyle font_style,
const base::string16& sub_text) {
+ DCHECK(!is_populated_);
+ is_populated_ = true;
+
SetLayoutManager(new views::FillLayout);
tri_view_ = TrayPopupUtils::CreateDefaultRowView();
AddChildView(tri_view_);
@@ -128,6 +135,9 @@ void HoverHighlightView::DoAddIconAndLabels(
}
void HoverHighlightView::AddLabelRow(const base::string16& text) {
+ DCHECK(!is_populated_);
+ is_populated_ = true;
+
SetLayoutManager(new views::FillLayout);
tri_view_ = TrayPopupUtils::CreateDefaultRowView();
AddChildView(tri_view_);
@@ -156,6 +166,16 @@ void HoverHighlightView::SetAccessiblityState(
NotifyAccessibilityEvent(ui::AX_EVENT_CHECKED_STATE_CHANGED, true);
}
+void HoverHighlightView::Reset() {
+ RemoveAllChildViews(true);
+ text_label_ = nullptr;
+ sub_text_label_ = nullptr;
+ left_icon_ = nullptr;
+ right_view_ = nullptr;
+ tri_view_ = nullptr;
+ is_populated_ = false;
+}
+
bool HoverHighlightView::PerformAction(const ui::Event& event) {
if (!listener_)
return false;
« no previous file with comments | « ash/system/tray/hover_highlight_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698