| Index: chrome/browser/ui/webui/history_ui.cc
|
| diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc
|
| index a4340a168f66e130e67e15178e3e703e4405b218..6e459f7e9bad478da16b26b0c6a1f48e3702f59f 100644
|
| --- a/chrome/browser/ui/webui/history_ui.cc
|
| +++ b/chrome/browser/ui/webui/history_ui.cc
|
| @@ -42,8 +42,6 @@
|
| #include "components/history/core/browser/history_types.h"
|
| #include "components/search/search.h"
|
| #include "components/sync_driver/device_info.h"
|
| -#include "content/public/browser/notification_details.h"
|
| -#include "content/public/browser/notification_source.h"
|
| #include "content/public/browser/url_data_source.h"
|
| #include "content/public/browser/web_ui.h"
|
| #include "content/public/browser/web_ui_data_source.h"
|
| @@ -405,6 +403,7 @@ bool BrowsingHistoryHandler::HistoryEntry::SortByTimeDescending(
|
|
|
| BrowsingHistoryHandler::BrowsingHistoryHandler()
|
| : has_pending_delete_request_(false),
|
| + history_service_observer_(this),
|
| weak_factory_(this) {
|
| }
|
|
|
| @@ -420,8 +419,10 @@ void BrowsingHistoryHandler::RegisterMessages() {
|
| profile, new FaviconSource(profile, FaviconSource::ANY));
|
|
|
| // Get notifications when history is cleared.
|
| - registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
|
| - content::Source<Profile>(profile->GetOriginalProfile()));
|
| + HistoryService* hs =
|
| + HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
|
| + if (hs)
|
| + history_service_observer_.Add(hs);
|
|
|
| web_ui()->RegisterMessageCallback("queryHistory",
|
| base::Bind(&BrowsingHistoryHandler::HandleQueryHistory,
|
| @@ -982,26 +983,19 @@ static bool DeletionsDiffer(const history::URLRows& deleted_rows,
|
| return false;
|
| }
|
|
|
| -void BrowsingHistoryHandler::Observe(
|
| - int type,
|
| - const content::NotificationSource& source,
|
| - const content::NotificationDetails& details) {
|
| - if (type != chrome::NOTIFICATION_HISTORY_URLS_DELETED) {
|
| - NOTREACHED();
|
| - return;
|
| - }
|
| - history::URLsDeletedDetails* deletedDetails =
|
| - content::Details<history::URLsDeletedDetails>(details).ptr();
|
| - if (deletedDetails->all_history ||
|
| - DeletionsDiffer(deletedDetails->rows, urls_to_be_deleted_))
|
| - web_ui()->CallJavascriptFunction("historyDeleted");
|
| -}
|
| -
|
| std::string BrowsingHistoryHandler::GetAcceptLanguages() const {
|
| Profile* profile = Profile::FromWebUI(web_ui());
|
| return profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
|
| }
|
|
|
| +void BrowsingHistoryHandler::OnURLsDeleted(
|
| + HistoryService* history_service,
|
| + const history::URLsDeletedDetails& deleted_details) {
|
| + if (deleted_details.all_history ||
|
| + DeletionsDiffer(deleted_details.rows, urls_to_be_deleted_))
|
| + web_ui()->CallJavascriptFunction("historyDeleted");
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| //
|
| // HistoryUI
|
|
|