Commit 81d62c8b authored by Wen Fan's avatar Wen Fan Committed by Chromium LUCI CQ

NTP: Correct the add shortcut button status when no custom link

Update page most visited info when there is no custom link

When you Toggle Most visited sites
(InstantService::ToggleMostVisitedOrCustomLinks), the change will not
be notified to the page if there is no custom link.

The add shortcut button status will not be correct.

Bug: 1161688
Change-Id: Ia18355afc4686aa881d5c0c57b8a7e8bb97925de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2612334
Commit-Queue: Esmael Elmoslimany <aee@chromium.org>
Reviewed-by: default avatarEsmael Elmoslimany <aee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842658}
parent d6ae375d
...@@ -1088,6 +1088,7 @@ Waihung Fu <fufranci@amazon.com> ...@@ -1088,6 +1088,7 @@ Waihung Fu <fufranci@amazon.com>
Wojciech Bielawski <wojciech.bielawski@gmail.com> Wojciech Bielawski <wojciech.bielawski@gmail.com>
Wanming Lin <wanming.lin@intel.com> Wanming Lin <wanming.lin@intel.com>
Wei Li <wei.c.li@intel.com> Wei Li <wei.c.li@intel.com>
Wen Fan <fanwen1@huawei.com>
Wenxiang Qian <leonwxqian@gmail.com> Wenxiang Qian <leonwxqian@gmail.com>
WenSheng He <wensheng.he@samsung.com> WenSheng He <wensheng.he@samsung.com>
Wesley Lancel <wesleylancel@gmail.com> Wesley Lancel <wesleylancel@gmail.com>
......
...@@ -375,7 +375,10 @@ bool InstantService::ToggleMostVisitedOrCustomLinks() { ...@@ -375,7 +375,10 @@ bool InstantService::ToggleMostVisitedOrCustomLinks() {
// user has never customized their shortcuts. // user has never customized their shortcuts.
// //
// For more details, see custom_links_mananger.h and most_visited_sites.h. // For more details, see custom_links_mananger.h and most_visited_sites.h.
if (!was_initialized && !most_visited_sites_->IsCustomLinksInitialized()) { if ((!was_initialized && !most_visited_sites_->IsCustomLinksInitialized()) ||
// Ensure that the add shortcut button status is correct when there is no
// custom link.
most_visited_sites_->GetCustomLinkNum() == 0) {
NotifyAboutMostVisitedInfo(); NotifyAboutMostVisitedInfo();
} }
......
...@@ -392,6 +392,10 @@ void MostVisitedSites::UndoCustomLinkAction() { ...@@ -392,6 +392,10 @@ void MostVisitedSites::UndoCustomLinkAction() {
BuildCurrentTiles(); BuildCurrentTiles();
} }
size_t MostVisitedSites::GetCustomLinkNum() {
return custom_links_->GetLinks().size();
}
void MostVisitedSites::AddOrRemoveBlockedUrl(const GURL& url, bool add_url) { void MostVisitedSites::AddOrRemoveBlockedUrl(const GURL& url, bool add_url) {
if (add_url) { if (add_url) {
base::RecordAction(base::UserMetricsAction("Suggestions.Site.Removed")); base::RecordAction(base::UserMetricsAction("Suggestions.Site.Removed"));
......
...@@ -215,6 +215,8 @@ class MostVisitedSites : public history::TopSitesObserver, ...@@ -215,6 +215,8 @@ class MostVisitedSites : public history::TopSitesObserver,
// must be enabled. // must be enabled.
void UndoCustomLinkAction(); void UndoCustomLinkAction();
size_t GetCustomLinkNum();
void AddOrRemoveBlockedUrl(const GURL& url, bool add_url); void AddOrRemoveBlockedUrl(const GURL& url, bool add_url);
void ClearBlockedUrls(); void ClearBlockedUrls();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment