Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 5 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/favicon/favicon_changed_details.h" | 9 #include "chrome/browser/favicon/favicon_changed_details.h" |
| 10 #include "chrome/browser/favicon/favicon_service.h" | 10 #include "chrome/browser/favicon/favicon_service.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 void NotifyHistoryOfRemovedURLs(Profile* profile, | 24 void NotifyHistoryOfRemovedURLs(Profile* profile, |
| 25 const std::set<GURL>& removed_urls) { | 25 const std::set<GURL>& removed_urls) { |
| 26 HistoryService* history_service = | 26 HistoryService* history_service = |
| 27 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); | 27 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); |
| 28 if (history_service) | 28 if (history_service) |
| 29 history_service->URLsNoLongerBookmarked(removed_urls); | 29 history_service->URLsNoLongerBookmarked(removed_urls); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile, bool index_urls) | 34 ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile) |
| 35 : profile_(profile), | 35 : profile_(profile), model_(NULL) { |
| 36 model_(new BookmarkModel(this, index_urls)) { | 36 } |
| 37 | |
| 38 ChromeBookmarkClient::~ChromeBookmarkClient() { | |
| 39 } | |
| 40 | |
| 41 void ChromeBookmarkClient::Init(BookmarkModel* model) { | |
| 42 DCHECK(!model_ && model); | |
| 43 model_ = model; | |
| 37 model_->AddObserver(this); | 44 model_->AddObserver(this); |
| 45 | |
| 38 // Listen for changes to favicons so that we can update the favicon of the | 46 // Listen for changes to favicons so that we can update the favicon of the |
| 39 // node appropriately. | 47 // node appropriately. |
| 40 registrar_.Add(this, | 48 registrar_.Add(this, |
| 41 chrome::NOTIFICATION_FAVICON_CHANGED, | 49 chrome::NOTIFICATION_FAVICON_CHANGED, |
| 42 content::Source<Profile>(profile_)); | 50 content::Source<Profile>(profile_)); |
| 43 } | 51 } |
| 44 | 52 |
| 45 ChromeBookmarkClient::~ChromeBookmarkClient() { | 53 void ChromeBookmarkClient::Shutdown() { |
| 46 model_->RemoveObserver(this); | 54 if (model_) { |
| 55 registrar_.RemoveAll(); | |
| 47 | 56 |
| 48 registrar_.RemoveAll(); | 57 model_->RemoveObserver(this); |
| 58 model_ = NULL; | |
| 59 } | |
|
blundell
2014/06/05 09:48:30
You should call BookmarkClient::Shutdown() here.
sdefresne
2014/06/10 13:12:21
Done.
| |
| 49 } | 60 } |
| 50 | 61 |
| 51 bool ChromeBookmarkClient::PreferTouchIcon() { | 62 bool ChromeBookmarkClient::PreferTouchIcon() { |
| 52 #if !defined(OS_IOS) | 63 #if !defined(OS_IOS) |
| 53 return false; | 64 return false; |
| 54 #else | 65 #else |
| 55 return true; | 66 return true; |
| 56 #endif | 67 #endif |
| 57 } | 68 } |
| 58 | 69 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 model_->OnFaviconChanged(favicon_details->urls); | 135 model_->OnFaviconChanged(favicon_details->urls); |
| 125 break; | 136 break; |
| 126 } | 137 } |
| 127 | 138 |
| 128 default: | 139 default: |
| 129 NOTREACHED(); | 140 NOTREACHED(); |
| 130 break; | 141 break; |
| 131 } | 142 } |
| 132 } | 143 } |
| 133 | 144 |
| 134 void ChromeBookmarkClient::Shutdown() { | |
| 135 model_->Shutdown(); | |
| 136 } | |
| 137 | |
| 138 void ChromeBookmarkClient::BookmarkModelChanged() { | 145 void ChromeBookmarkClient::BookmarkModelChanged() { |
| 139 } | 146 } |
| 140 | 147 |
| 141 void ChromeBookmarkClient::BookmarkNodeRemoved( | 148 void ChromeBookmarkClient::BookmarkNodeRemoved( |
| 142 BookmarkModel* model, | 149 BookmarkModel* model, |
| 143 const BookmarkNode* parent, | 150 const BookmarkNode* parent, |
| 144 int old_index, | 151 int old_index, |
| 145 const BookmarkNode* node, | 152 const BookmarkNode* node, |
| 146 const std::set<GURL>& removed_urls) { | 153 const std::set<GURL>& removed_urls) { |
| 147 NotifyHistoryOfRemovedURLs(profile_, removed_urls); | 154 NotifyHistoryOfRemovedURLs(profile_, removed_urls); |
| 148 } | 155 } |
| 149 | 156 |
| 150 void ChromeBookmarkClient::BookmarkAllNodesRemoved( | 157 void ChromeBookmarkClient::BookmarkAllNodesRemoved( |
| 151 BookmarkModel* model, | 158 BookmarkModel* model, |
| 152 const std::set<GURL>& removed_urls) { | 159 const std::set<GURL>& removed_urls) { |
| 153 NotifyHistoryOfRemovedURLs(profile_, removed_urls); | 160 NotifyHistoryOfRemovedURLs(profile_, removed_urls); |
| 154 } | 161 } |
| OLD | NEW |