Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: chrome/browser/bookmarks/chrome_bookmark_client.cc

Issue 306293006: Introduce ChromeBookmarkClientFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@364865
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/bookmarks/chrome_bookmark_client.cc
diff --git a/chrome/browser/bookmarks/chrome_bookmark_client.cc b/chrome/browser/bookmarks/chrome_bookmark_client.cc
index b57fb06f3c37ae0563662a19d708b6557b4a880a..27845427a8d475faada11d190cbf5ef611e2deab 100644
--- a/chrome/browser/bookmarks/chrome_bookmark_client.cc
+++ b/chrome/browser/bookmarks/chrome_bookmark_client.cc
@@ -31,10 +31,18 @@ void NotifyHistoryOfRemovedURLs(Profile* profile,
} // namespace
-ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile, bool index_urls)
- : profile_(profile),
- model_(new BookmarkModel(this, index_urls)) {
+ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile)
+ : profile_(profile), model_(NULL) {
+}
+
+ChromeBookmarkClient::~ChromeBookmarkClient() {
+}
+
+void ChromeBookmarkClient::Init(BookmarkModel* model) {
+ DCHECK(!model_ && model);
+ model_ = model;
model_->AddObserver(this);
+
// Listen for changes to favicons so that we can update the favicon of the
// node appropriately.
registrar_.Add(this,
@@ -42,10 +50,13 @@ ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile, bool index_urls)
content::Source<Profile>(profile_));
}
-ChromeBookmarkClient::~ChromeBookmarkClient() {
- model_->RemoveObserver(this);
+void ChromeBookmarkClient::Shutdown() {
+ if (model_) {
+ registrar_.RemoveAll();
- registrar_.RemoveAll();
+ model_->RemoveObserver(this);
+ model_ = NULL;
+ }
}
bool ChromeBookmarkClient::PreferTouchIcon() {
@@ -131,10 +142,6 @@ void ChromeBookmarkClient::Observe(
}
}
-void ChromeBookmarkClient::Shutdown() {
- model_->Shutdown();
-}
-
void ChromeBookmarkClient::BookmarkModelChanged() {
}

Powered by Google App Engine
This is Rietveld 408576698