| 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/history/chrome_history_client.h" | 5 #include "chrome/browser/history/chrome_history_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/history/history_notifications.h" | 9 #include "chrome/browser/history/history_notifications.h" |
| 10 #include "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // it can release the signal history is waiting on, allowing history to | 86 // it can release the signal history is waiting on, allowing history to |
| 87 // shutdown (HistoryService::Cleanup to complete). In such a scenario history | 87 // shutdown (HistoryService::Cleanup to complete). In such a scenario history |
| 88 // sees an incorrect view of bookmarks, but it's better than a deadlock. | 88 // sees an incorrect view of bookmarks, but it's better than a deadlock. |
| 89 bookmark_model_->Shutdown(); | 89 bookmark_model_->Shutdown(); |
| 90 if (history_service_) { | 90 if (history_service_) { |
| 91 history_service_->RemoveObserver(this); | 91 history_service_->RemoveObserver(this); |
| 92 history_service_ = nullptr; | 92 history_service_ = nullptr; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 // TODO(sdefresne): port client listening for NOTIFICATION_HISTORY_URL_VISITED | |
| 97 // to use the HistoryService::Observer pattern instead and remove this method | |
| 98 // when this is complete, http://crbug.com/42178 | |
| 99 void ChromeHistoryClient::OnURLVisited(HistoryService* history_service, | |
| 100 ui::PageTransition transition, | |
| 101 const history::URLRow& row, | |
| 102 const history::RedirectList& redirects, | |
| 103 base::Time visit_time) { | |
| 104 DCHECK(history_service == history_service_); | |
| 105 scoped_ptr<history::URLVisitedDetails> details( | |
| 106 new history::URLVisitedDetails); | |
| 107 details->transition = transition; | |
| 108 details->row = row; | |
| 109 details->redirects = redirects; | |
| 110 details->visit_time = visit_time; | |
| 111 content::NotificationService::current()->Notify( | |
| 112 chrome::NOTIFICATION_HISTORY_URL_VISITED, | |
| 113 content::Source<Profile>(profile_), | |
| 114 content::Details<history::HistoryDetails>(details.get())); | |
| 115 } | |
| 116 | |
| 117 void ChromeHistoryClient::TopSitesLoaded(history::TopSites* top_sites) { | 96 void ChromeHistoryClient::TopSitesLoaded(history::TopSites* top_sites) { |
| 118 content::NotificationService::current()->Notify( | 97 content::NotificationService::current()->Notify( |
| 119 chrome::NOTIFICATION_TOP_SITES_LOADED, | 98 chrome::NOTIFICATION_TOP_SITES_LOADED, |
| 120 content::Source<Profile>(profile_), | 99 content::Source<Profile>(profile_), |
| 121 content::Details<history::TopSites>(top_sites)); | 100 content::Details<history::TopSites>(top_sites)); |
| 122 } | 101 } |
| 123 | 102 |
| 124 void ChromeHistoryClient::TopSitesChanged(history::TopSites* top_sites) { | 103 void ChromeHistoryClient::TopSitesChanged(history::TopSites* top_sites) { |
| 125 content::NotificationService::current()->Notify( | 104 content::NotificationService::current()->Notify( |
| 126 chrome::NOTIFICATION_TOP_SITES_CHANGED, | 105 chrome::NOTIFICATION_TOP_SITES_CHANGED, |
| 127 content::Source<history::TopSites>(top_sites), | 106 content::Source<history::TopSites>(top_sites), |
| 128 content::NotificationService::NoDetails()); | 107 content::NotificationService::NoDetails()); |
| 129 } | 108 } |
| OLD | NEW |