summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 14:52:10 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 14:52:10 +0000
commit8fbdeb2c722073c80e2c99bd529d274dbe924645 (patch)
treea969b759c2c761e780209f826e6df4e22e9e37b0
parent6aa58922312836c4ee4ee5e7fa8a9dcd213af731 (diff)
downloadchromium_src-8fbdeb2c722073c80e2c99bd529d274dbe924645.zip
chromium_src-8fbdeb2c722073c80e2c99bd529d274dbe924645.tar.gz
chromium_src-8fbdeb2c722073c80e2c99bd529d274dbe924645.tar.bz2
Revert 179101 - It caused first-run issues.
Original CL description: bookmarks: Convert ProfileImpl to use BaseBookmarkModelObserver. That way we can remove the usage of chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, and just register it using BookmarkModel::AddObserver/RemoveObserver API. BUG=144783 R=sky@chromium.org,sail@chromium.org Review URL: https://chromiumcodereview.appspot.com/12077006 BUG=174590 TBR=sail@chromium.org,tapted@chromium.org,tfarina@chromium.org Review URL: https://codereview.chromium.org/12209055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181306 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/profiles/profile_impl.cc41
1 files changed, 8 insertions, 33 deletions
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 6615e8a..ddb9b5a 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -24,9 +24,6 @@
#include "chrome/browser/autocomplete/autocomplete_classifier.h"
#include "chrome/browser/background/background_contents_service_factory.h"
#include "chrome/browser/background/background_mode_manager.h"
-#include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
-#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/cookie_settings.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
@@ -234,34 +231,6 @@ std::string ExitTypeToSessionTypePrefValue(Profile::ExitType type) {
return std::string();
}
-class BookmarkModelLoadedObserver : public BaseBookmarkModelObserver {
- public:
- explicit BookmarkModelLoadedObserver(Profile* profile);
-
- private:
- virtual void BookmarkModelChanged() OVERRIDE;
- virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE;
-
- Profile* profile_;
-
- DISALLOW_COPY_AND_ASSIGN(BookmarkModelLoadedObserver);
-};
-
-BookmarkModelLoadedObserver::BookmarkModelLoadedObserver(Profile* profile)
- : profile_(profile) {
-}
-
-void BookmarkModelLoadedObserver::BookmarkModelChanged() {
-}
-
-void BookmarkModelLoadedObserver::Loaded(BookmarkModel* model,
- bool ids_reassigned) {
- // Causes lazy-load if sync is enabled.
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
- model->RemoveObserver(this);
- delete this;
-}
-
} // namespace
// static
@@ -477,8 +446,8 @@ void ProfileImpl::DoFinalInit(bool is_new_profile) {
#if !defined(OS_CHROMEOS)
// Listen for bookmark model load, to bootstrap the sync service.
// On CrOS sync service will be initialized after sign in.
- BookmarkModel* model = BookmarkModelFactory::GetForProfile(this);
- model->AddObserver(new BookmarkModelLoadedObserver(this));
+ registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
+ content::Source<Profile>(this));
#endif
PrefService* local_state = g_browser_process->local_state();
@@ -955,6 +924,12 @@ void ProfileImpl::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
+ case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED:
+ // Causes lazy-load if sync is enabled.
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(this);
+ registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
+ content::Source<Profile>(this));
+ break;
case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: {
const std::string& host =
*(content::Details<const std::string>(details).ptr());