summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-30 07:12:57 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-30 07:12:57 +0000
commit479e392d87a50de9a8c6cd78b35e317a4abfe768 (patch)
treeb4c90d41723c03076c103097a17ef8c889c44353 /chrome/browser/extensions
parent85d3e142825217dab7fc64d8e0af445c01210cca (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/extensions/extension_system_impl.cc3
-rw-r--r--chrome/browser/extensions/extension_system_impl.h3
-rw-r--r--chrome/browser/extensions/state_store_notification_observer.cc34
-rw-r--r--chrome/browser/extensions/state_store_notification_observer.h38
4 files changed, 78 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_system_impl.cc b/chrome/browser/extensions/extension_system_impl.cc
index 1f8ada2..165d9e1 100644
--- a/chrome/browser/extensions/extension_system_impl.cc
+++ b/chrome/browser/extensions/extension_system_impl.cc
@@ -27,6 +27,7 @@
#include "chrome/browser/extensions/navigation_observer.h"
#include "chrome/browser/extensions/shared_module_service.h"
#include "chrome/browser/extensions/standard_management_policy_provider.h"
+#include "chrome/browser/extensions/state_store_notification_observer.h"
#include "chrome/browser/extensions/updater/manifest_fetch_data.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/profiles/profile.h"
@@ -115,6 +116,8 @@ void ExtensionSystemImpl::Shared::InitPrefs() {
profile_,
profile_->GetPath().AppendASCII(extensions::kStateStoreName),
true));
+ state_store_notification_observer_.reset(
+ new StateStoreNotificationObserver(state_store_.get()));
rules_store_.reset(new StateStore(
profile_,
diff --git a/chrome/browser/extensions/extension_system_impl.h b/chrome/browser/extensions/extension_system_impl.h
index 2694b5b..df32495 100644
--- a/chrome/browser/extensions/extension_system_impl.h
+++ b/chrome/browser/extensions/extension_system_impl.h
@@ -17,6 +17,7 @@ class ExtensionSystemSharedFactory;
class ExtensionWarningBadgeService;
class NavigationObserver;
class StandardManagementPolicyProvider;
+class StateStoreNotificationObserver;
// The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl.
// Implementation details: non-shared services are owned by
@@ -104,6 +105,8 @@ class ExtensionSystemImpl : public ExtensionSystem {
// The services that are shared between normal and incognito profiles.
scoped_ptr<StateStore> state_store_;
+ scoped_ptr<StateStoreNotificationObserver>
+ state_store_notification_observer_;
scoped_ptr<StateStore> rules_store_;
// LazyBackgroundTaskQueue is a dependency of
// MessageService and EventRouter.
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
diff --git a/chrome/browser/extensions/state_store_notification_observer.h b/chrome/browser/extensions/state_store_notification_observer.h
new file mode 100644
index 0000000..19a9965
--- /dev/null
+++ b/chrome/browser/extensions/state_store_notification_observer.h
@@ -0,0 +1,38 @@
+// 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.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_STATE_STORE_NOTIFICATION_OBSERVER_H_
+#define CHROME_BROWSER_EXTENSIONS_STATE_STORE_NOTIFICATION_OBSERVER_H_
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+namespace extensions {
+class StateStore;
+
+// Initializes the StateStore when session restore is complete, for example when
+// page load notifications are not sent ("Continue where I left off").
+// http://crbug.com/230481
+class StateStoreNotificationObserver : public content::NotificationObserver {
+ public:
+ explicit StateStoreNotificationObserver(StateStore* state_store);
+ virtual ~StateStoreNotificationObserver();
+
+ // content::NotificationObserver overrides:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ private:
+ StateStore* state_store_; // Not owned.
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(StateStoreNotificationObserver);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_STATE_STORE_NOTIFICATION_OBSERVER_H_