Skip to content

Commit 463bc84

Browse files
authored
Merge pull request #19689 from thirumurugan-git/fix-playlist-icon-issue
Playlist icon visibility issue fix
2 parents 13762a9 + aff189c commit 463bc84

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

browser/ui/views/playlist/playlist_action_icon_view.cc

+4-8
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ void PlaylistActionIconView::ShowPlaylistBubble() {
7272
}
7373

7474
DCHECK(saved_item_count || found_item_count > 1u);
75-
DCHECK_EQ(last_web_contents_, GetWebContents());
7675
PlaylistActionBubbleView::ShowBubble(browser_, this, playlist_tab_helper);
7776
}
7877

@@ -86,8 +85,7 @@ const gfx::VectorIcon& PlaylistActionIconView::GetVectorIcon() const {
8685
}
8786

8887
void PlaylistActionIconView::UpdateImpl() {
89-
if (auto old_contents = std::exchange(last_web_contents_, GetWebContents());
90-
old_contents == last_web_contents_) {
88+
if (!GetWebContents()) {
9189
return;
9290
}
9391

@@ -133,12 +131,10 @@ void PlaylistActionIconView::UpdateState(bool has_saved, bool found_items) {
133131
: found_items ? State::kFound
134132
: State::kNone;
135133
if (auto old_state = std::exchange(state_, target_state);
136-
old_state == target_state) {
137-
return;
134+
old_state != target_state) {
135+
DVLOG(2) << __FUNCTION__ << " " << static_cast<int>(target_state);
136+
UpdateIconImage();
138137
}
139-
140-
DVLOG(2) << __FUNCTION__ << " " << static_cast<int>(target_state);
141-
UpdateIconImage();
142138
UpdateVisibilityPerState();
143139
}
144140

browser/ui/views/playlist/playlist_action_icon_view.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class PlaylistActionIconView : public PageActionIconView,
4343
enum class State { kNone, kAdded, kFound };
4444

4545
playlist::PlaylistTabHelper* playlist_tab_helper() {
46-
return playlist::PlaylistTabHelper::FromWebContents(
47-
last_web_contents_.get());
46+
return playlist::PlaylistTabHelper::FromWebContents(GetWebContents());
4847
}
4948

5049
void UpdateState(bool has_saved, bool found_items);
@@ -63,8 +62,6 @@ class PlaylistActionIconView : public PageActionIconView,
6362

6463
State state_ = State::kNone;
6564

66-
raw_ptr<content::WebContents> last_web_contents_ = nullptr;
67-
6865
base::ScopedObservation<playlist::PlaylistTabHelper,
6966
playlist::PlaylistTabHelperObserver>
7067
playlist_tab_helper_observation_{this};

0 commit comments

Comments
 (0)