Chromium Code Reviews| Index: chrome/browser/jumplist_listener.cc |
| diff --git a/chrome/browser/jumplist_listener.cc b/chrome/browser/jumplist_listener.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dd7b83c0de6bbc278f3c226d83ebff4f12c2da72 |
| --- /dev/null |
| +++ b/chrome/browser/jumplist_listener.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/jumplist_listener.h" |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| +#include "base/callback_forward.h" |
| +#include "chrome/browser/jumplist_win.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/common/chrome_notification_types.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" |
| + |
| + |
|
sky
2012/12/18 20:52:38
Only one newline.
Cait (Slow)
2012/12/19 19:27:01
Done.
|
| +JumpListListener::JumpListListener(base::Closure callback) |
| + : callback_(callback), |
| + called_(false) { |
| + registrar_.reset(new content::NotificationRegistrar); |
| + // Register for notification of when initial page load is complete to ensure |
| + // that we wait until start-up is complete before calling the callback. |
| + registrar_->Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| + content::NotificationService::AllSources()); |
| +} |
| + |
| +JumpListListener::~JumpListListener() { |
| +} |
| + |
| +void JumpListListener::Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + switch (type) { |
| + case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { |
| + if (!called_) { |
| + called_ = true; |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::UI, FROM_HERE, callback_); |
|
sky
2012/12/18 20:52:38
Why the delay?
Cait (Slow)
2012/12/19 19:27:01
Done.
|
| + } |
| + break; |
| + } |
| + default: |
| + NOTREACHED() << "Unexpected notification type."; |
| + } |
| +} |