| Index: chrome/browser/history/chrome_history_client.cc
|
| diff --git a/chrome/browser/history/chrome_history_client.cc b/chrome/browser/history/chrome_history_client.cc
|
| index e21bcbd0dca34bbfad71f89dcc3528af7f940c1b..81c8b44205b4b00620bbab923e59b474c03f1c10 100644
|
| --- a/chrome/browser/history/chrome_history_client.cc
|
| +++ b/chrome/browser/history/chrome_history_client.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "chrome/browser/history/chrome_history_client.h"
|
|
|
| +#include "base/callback.h"
|
| +#include "base/bind.h"
|
| #include "chrome/browser/history/chrome_history_backend_client.h"
|
| #include "chrome/browser/history/history_utils.h"
|
| #include "chrome/browser/ui/profile_error_dialog.h"
|
| @@ -11,16 +13,33 @@
|
| #include "chrome/grit/chromium_strings.h"
|
| #include "chrome/grit/generated_resources.h"
|
| #include "components/bookmarks/browser/bookmark_model.h"
|
| +#include "components/history/core/browser/history_service.h"
|
|
|
| ChromeHistoryClient::ChromeHistoryClient(
|
| bookmarks::BookmarkModel* bookmark_model)
|
| : bookmark_model_(bookmark_model) {
|
| + if (bookmark_model_)
|
| + bookmark_model_->AddObserver(this);
|
| }
|
|
|
| ChromeHistoryClient::~ChromeHistoryClient() {
|
| }
|
|
|
| +void ChromeHistoryClient::Init(history::HistoryService* history_service) {
|
| + if (bookmark_model_) {
|
| + favicon_changed_subscription_ = history_service->AddFaviconChangedCallback(
|
| + base::Bind(&bookmarks::BookmarkModel::OnFaviconChanged,
|
| + base::Unretained(bookmark_model_)));
|
| + }
|
| + on_bookmarks_removed_ =
|
| + base::Bind(&history::HistoryService::URLsNoLongerBookmarked,
|
| + base::Unretained(history_service));
|
| +}
|
| +
|
| void ChromeHistoryClient::Shutdown() {
|
| + favicon_changed_subscription_.reset();
|
| + on_bookmarks_removed_ = base::Callback<void(const std::set<GURL>&)>();
|
| +
|
| // It's possible that bookmarks haven't loaded and history is waiting for
|
| // bookmarks to complete loading. In such a situation history can't shutdown
|
| // (meaning if we invoked HistoryService::Cleanup now, we would deadlock). To
|
| @@ -28,8 +47,10 @@ void ChromeHistoryClient::Shutdown() {
|
| // it can release the signal history is waiting on, allowing history to
|
| // shutdown (HistoryService::Cleanup to complete). In such a scenario history
|
| // sees an incorrect view of bookmarks, but it's better than a deadlock.
|
| - if (bookmark_model_)
|
| + if (bookmark_model_) {
|
| + bookmark_model_->RemoveObserver(this);
|
| bookmark_model_->Shutdown();
|
| + }
|
| }
|
|
|
| bool ChromeHistoryClient::CanAddURL(const GURL& url) {
|
| @@ -47,3 +68,20 @@ scoped_ptr<history::HistoryBackendClient>
|
| ChromeHistoryClient::CreateBackendClient() {
|
| return make_scoped_ptr(new ChromeHistoryBackendClient(bookmark_model_));
|
| }
|
| +
|
| +void ChromeHistoryClient::BookmarkNodeRemoved(
|
| + bookmarks::BookmarkModel* bookmark_model,
|
| + const bookmarks::BookmarkNode* parent,
|
| + int old_index,
|
| + const bookmarks::BookmarkNode* node,
|
| + const std::set<GURL>& removed_urls) {
|
| + if (!on_bookmarks_removed_.is_null())
|
| + on_bookmarks_removed_.Run(removed_urls);
|
| +}
|
| +
|
| +void ChromeHistoryClient::BookmarkAllUserNodesRemoved(
|
| + bookmarks::BookmarkModel* bookmark_model,
|
| + const std::set<GURL>& removed_urls) {
|
| + if (!on_bookmarks_removed_.is_null())
|
| + on_bookmarks_removed_.Run(removed_urls);
|
| +}
|
|
|