summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/profiles/profile.h1
-rw-r--r--chrome/browser/profiles/profile_impl.cc4
-rw-r--r--chrome/browser/profiles/profile_impl.h1
-rw-r--r--chrome/browser/tabs/pinned_tab_service.h4
-rw-r--r--chrome/browser/tabs/pinned_tab_service_factory.cc32
-rw-r--r--chrome/browser/tabs/pinned_tab_service_factory.h35
-rw-r--r--chrome/chrome_browser.gypi2
7 files changed, 74 insertions, 5 deletions
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index 3bad14a..92d14ab 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -71,7 +71,6 @@ class NTPResourceCache;
class NavigationController;
class PasswordStore;
class PersonalDataManager;
-class PinnedTabService;
class PrefProxyConfigTracker;
class PrefService;
class ProfileSyncFactory;
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 2717989..4a71f99 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -65,7 +65,7 @@
#include "chrome/browser/status_icons/status_tray.h"
#include "chrome/browser/sync/profile_sync_factory_impl.h"
#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/tabs/pinned_tab_service.h"
+#include "chrome/browser/tabs/pinned_tab_service_factory.h"
#include "chrome/browser/transport_security_persister.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/find_bar/find_bar_state.h"
@@ -289,7 +289,7 @@ ProfileImpl::ProfileImpl(const FilePath& path)
ssl_config_service_manager_.reset(
SSLConfigServiceManager::CreateDefaultManager(GetPrefs(), local_state));
- pinned_tab_service_.reset(new PinnedTabService(this));
+ PinnedTabServiceFactory::GetForProfile(this);
// Initialize the BackgroundModeManager - this has to be done here before
// InitExtensions() is called because it relies on receiving notifications
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index b58ea94..460e9a66 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -245,7 +245,6 @@ class ProfileImpl : public Profile,
scoped_ptr<BackgroundModeManager> background_mode_manager_;
scoped_ptr<StatusTray> status_tray_;
scoped_refptr<PersonalDataManager> personal_data_manager_;
- scoped_ptr<PinnedTabService> pinned_tab_service_;
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
scoped_ptr<BrowserSignin> browser_signin_;
bool history_service_created_;
diff --git a/chrome/browser/tabs/pinned_tab_service.h b/chrome/browser/tabs/pinned_tab_service.h
index 8eff427..be802e9 100644
--- a/chrome/browser/tabs/pinned_tab_service.h
+++ b/chrome/browser/tabs/pinned_tab_service.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_TABS_PINNED_TAB_SERVICE_H_
#pragma once
+#include "chrome/browser/profiles/profile_keyed_service.h"
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
@@ -14,7 +15,8 @@ class Profile;
// PinnedTabService is responsible for updating preferences with the set of
// pinned tabs to restore at startup. PinnedTabService listens for the
// appropriate set of notifications to know it should update preferences.
-class PinnedTabService : public NotificationObserver {
+class PinnedTabService : public NotificationObserver,
+ public ProfileKeyedService {
public:
explicit PinnedTabService(Profile* profile);
diff --git a/chrome/browser/tabs/pinned_tab_service_factory.cc b/chrome/browser/tabs/pinned_tab_service_factory.cc
new file mode 100644
index 0000000..13789c6
--- /dev/null
+++ b/chrome/browser/tabs/pinned_tab_service_factory.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2011 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/tabs/pinned_tab_service_factory.h"
+
+#include "chrome/browser/tabs/pinned_tab_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_dependency_manager.h"
+
+// static
+PinnedTabService* PinnedTabServiceFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<PinnedTabService*>(
+ GetInstance()->GetServiceForProfile(profile));
+}
+
+PinnedTabServiceFactory* PinnedTabServiceFactory::GetInstance() {
+ return Singleton<PinnedTabServiceFactory>::get();
+}
+
+PinnedTabServiceFactory::PinnedTabServiceFactory()
+ : ProfileKeyedServiceFactory(ProfileDependencyManager::GetInstance()) {
+}
+
+PinnedTabServiceFactory::~PinnedTabServiceFactory() {
+}
+
+ProfileKeyedService* PinnedTabServiceFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+ return new PinnedTabService(profile);
+}
diff --git a/chrome/browser/tabs/pinned_tab_service_factory.h b/chrome/browser/tabs/pinned_tab_service_factory.h
new file mode 100644
index 0000000..353ba17
--- /dev/null
+++ b/chrome/browser/tabs/pinned_tab_service_factory.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2011 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_TABS_PINNED_TAB_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_TABS_PINNED_TAB_SERVICE_FACTORY_H_
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/profiles/profile_keyed_service_factory.h"
+
+class PinnedTabService;
+class Profile;
+
+// Singleton that owns all PinnedTabServices and associates them with Profiles.
+// Listens for the Profile's destruction notification and cleans up the
+// associated PinnedTabService.
+class PinnedTabServiceFactory : public ProfileKeyedServiceFactory {
+ public:
+ // Returns the PinnedTabService that tracks pinning changes for |profile|.
+ static PinnedTabService* GetForProfile(Profile* profile);
+
+ static PinnedTabServiceFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<PinnedTabServiceFactory>;
+
+ PinnedTabServiceFactory();
+ virtual ~PinnedTabServiceFactory();
+
+ // ProfileKeyedServiceFactory:
+ virtual ProfileKeyedService* BuildServiceInstanceFor(
+ Profile* profile) const OVERRIDE;
+};
+
+#endif // CHROME_BROWSER_TABS_PINNED_TAB_SERVICE_FACTORY_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 1b1493d..5490be5 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2007,6 +2007,8 @@
'browser/tabs/pinned_tab_codec.h',
'browser/tabs/pinned_tab_service.cc',
'browser/tabs/pinned_tab_service.h',
+ 'browser/tabs/pinned_tab_service_factory.cc',
+ 'browser/tabs/pinned_tab_service_factory.h',
'browser/tabs/tab_handler.h',
'browser/tabs/tab_finder.cc',
'browser/tabs/tab_finder.h',