Chromium Code Reviews| Index: chrome/browser/jumplist_win.cc |
| diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc |
| index 91c01207d86bfd9a255787bf6b1a0d9a4ba007dd..2331158120d45890b39ca408ec97887c158cc53d 100644 |
| --- a/chrome/browser/jumplist_win.cc |
| +++ b/chrome/browser/jumplist_win.cc |
| @@ -37,7 +37,9 @@ |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/url_constants.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_source.h" |
| +#include "content/public/browser/notification_types.h" |
| #include "googleurl/src/gurl.h" |
| #include "grit/chromium_strings.h" |
| #include "grit/generated_resources.h" |
| @@ -488,7 +490,9 @@ bool UpdateJumpList(const wchar_t* app_id, |
| JumpList::JumpList() |
| : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), |
| profile_(NULL), |
| - task_id_(CancelableTaskTracker::kBadTaskId) { |
| + task_id_(CancelableTaskTracker::kBadTaskId), |
| + initial_page_load_pending_(true), |
| + update_pending_(false) { |
| } |
| JumpList::~JumpList() { |
| @@ -534,6 +538,9 @@ bool JumpList::AddObserver(Profile* profile) { |
| // observers are detatched at that time. |
| registrar_->Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| content::Source<Profile>(profile_)); |
| + // Register for notification of when |
|
jeremy
2012/12/13 22:06:24
comment still truncated
|
| + registrar_->Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| + content::NotificationService::AllSources()); |
| } |
| tab_restore_service->AddObserver(this); |
| return true; |
| @@ -558,6 +565,18 @@ void JumpList::Observe(int type, |
| Terminate(); |
| break; |
| } |
| + case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { |
| + if (initial_page_load_pending_) { |
| + initial_page_load_pending_ = false; |
| + if (update_pending_) { |
| + update_pending_ = false; |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, |
| + base::Bind(&JumpList::RunUpdate, this)); |
| + } |
| + } |
| + break; |
| + } |
| default: |
| NOTREACHED() << "Unexpected notification type."; |
| } |
| @@ -695,9 +714,13 @@ void JumpList::StartLoadingFavicon() { |
| if (icon_urls_.empty()) { |
| // No more favicons are needed by the application JumpList. Schedule a |
| // RunUpdate call. |
| - BrowserThread::PostTask( |
| - BrowserThread::FILE, FROM_HERE, |
| - base::Bind(&JumpList::RunUpdate, this)); |
| + if (initial_page_load_pending_) { |
| + update_pending_ = true; |
| + } else { |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, |
| + base::Bind(&JumpList::RunUpdate, this)); |
| + } |
| return; |
| } |
| // Ask FaviconService if it has a favicon of a URL. |