diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-30 07:12:57 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-30 07:12:57 +0000 |
commit | 479e392d87a50de9a8c6cd78b35e317a4abfe768 (patch) | |
tree | b4c90d41723c03076c103097a17ef8c889c44353 /chrome/browser/extensions/state_store_notification_observer.cc | |
parent | 85d3e142825217dab7fc64d8e0af445c01210cca (diff) | |
download | chromium_src-479e392d87a50de9a8c6cd78b35e317a4abfe768.zip chromium_src-479e392d87a50de9a8c6cd78b35e317a4abfe768.tar.gz chromium_src-479e392d87a50de9a8c6cd78b35e317a4abfe768.tar.bz2 |
Remove NOTIFICATION_SESSION_RESTORE_DONE from src/extensions
src/extensions should not listen for notifications from
src/chrome.
NOTIFICATION_SESSION_RESTORE_DONE is used by state_store.cc
to load per-extension state from a database at startup.
Refactor this so Chrome explicitly requests the StateStore
to initialize. Other embedders (like app_shell) don't need
this behavior.
BUG=392660
TEST=browser_tests *Extension*
Review URL: https://codereview.chromium.org/427003006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286429 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/state_store_notification_observer.cc')
-rw-r--r-- | chrome/browser/extensions/state_store_notification_observer.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chrome/browser/extensions/state_store_notification_observer.cc b/chrome/browser/extensions/state_store_notification_observer.cc new file mode 100644 index 0000000..0e5084c --- /dev/null +++ b/chrome/browser/extensions/state_store_notification_observer.cc @@ -0,0 +1,34 @@ +// Copyright 2014 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/extensions/state_store_notification_observer.h" + +#include "base/logging.h" +#include "chrome/browser/chrome_notification_types.h" +#include "content/public/browser/notification_service.h" +#include "extensions/browser/state_store.h" + +namespace extensions { + +StateStoreNotificationObserver::StateStoreNotificationObserver( + StateStore* state_store) + : state_store_(state_store) { + registrar_.Add(this, + chrome::NOTIFICATION_SESSION_RESTORE_DONE, + content::NotificationService::AllBrowserContextsAndSources()); +} + +StateStoreNotificationObserver::~StateStoreNotificationObserver() { +} + +void StateStoreNotificationObserver::Observe( + int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + DCHECK_EQ(type, chrome::NOTIFICATION_SESSION_RESTORE_DONE); + registrar_.RemoveAll(); + state_store_->RequestInitAfterDelay(); +} + +} // namespace extensions |