Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / history / chrome_history_client.cc
index ea979be..aab15ff 100644 (file)
@@ -7,6 +7,7 @@
 #include "base/logging.h"
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/history/history_notifications.h"
+#include "chrome/browser/history/history_service.h"
 #include "chrome/browser/history/top_sites.h"
 #include "chrome/browser/ui/profile_error_dialog.h"
 #include "chrome/common/chrome_version_info.h"
@@ -20,6 +21,7 @@ ChromeHistoryClient::ChromeHistoryClient(BookmarkModel* bookmark_model,
                                          history::TopSites* top_sites)
     : bookmark_model_(bookmark_model),
       profile_(profile),
+      history_service_(nullptr),
       top_sites_(top_sites) {
   DCHECK(bookmark_model_);
   if (top_sites_)
@@ -31,6 +33,12 @@ ChromeHistoryClient::~ChromeHistoryClient() {
     top_sites_->RemoveObserver(this);
 }
 
+void ChromeHistoryClient::SetHistoryService(HistoryService* history_service) {
+  DCHECK(history_service);
+  history_service_ = history_service;
+  history_service_->AddObserver(this);
+}
+
 void ChromeHistoryClient::BlockUntilBookmarksLoaded() {
   bookmark_model_->BlockTillLoaded();
 }
@@ -79,6 +87,10 @@ void ChromeHistoryClient::Shutdown() {
   // shutdown (HistoryService::Cleanup to complete). In such a scenario history
   // sees an incorrect view of bookmarks, but it's better than a deadlock.
   bookmark_model_->Shutdown();
+  if (history_service_) {
+    history_service_->RemoveObserver(this);
+    history_service_ = nullptr;
+  }
 }
 
 void ChromeHistoryClient::TopSitesLoaded(history::TopSites* top_sites) {