From 479e392d87a50de9a8c6cd78b35e317a4abfe768 Mon Sep 17 00:00:00 2001 From: "jamescook@chromium.org" Date: Wed, 30 Jul 2014 07:12:57 +0000 Subject: 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 --- .../state_store_notification_observer.cc | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 chrome/browser/extensions/state_store_notification_observer.cc (limited to 'chrome/browser/extensions/state_store_notification_observer.cc') 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 -- cgit v1.1