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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // (meaning if we invoked HistoryService::Cleanup now, we would deadlock). To | 84 // (meaning if we invoked HistoryService::Cleanup now, we would deadlock). To |
85 // break the deadlock we tell BookmarkModel it's about to be deleted so that | 85 // break the deadlock we tell BookmarkModel it's about to be deleted so that |
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 } | 92 } |
93 | 93 |
94 // TODO(sdefresne): port client listening for NOTIFICATION_HISTORY_URL_VISITED | |
95 // to use the HistoryService::Observer pattern instead and remove this method | |
96 // when this is complete, http://crbug.com/42178 | |
97 void ChromeHistoryClient::OnURLVisited(HistoryService* history_service, | |
98 ui::PageTransition transition, | |
99 const history::URLRow& row, | |
100 const history::RedirectList& redirects, | |
101 base::Time visit_time) { | |
102 DCHECK(history_service == history_service_); | |
103 scoped_ptr<history::URLVisitedDetails> details( | |
104 new history::URLVisitedDetails); | |
105 details->transition = transition; | |
106 details->row = row; | |
107 details->redirects = redirects; | |
108 details->visit_time = visit_time; | |
109 content::NotificationService::current()->Notify( | |
110 chrome::NOTIFICATION_HISTORY_URL_VISITED, | |
111 content::Source<Profile>(profile_), | |
112 content::Details<history::HistoryDetails>(details.get())); | |
113 } | |
114 | |
115 void ChromeHistoryClient::TopSitesLoaded(history::TopSites* top_sites) { | 94 void ChromeHistoryClient::TopSitesLoaded(history::TopSites* top_sites) { |
116 content::NotificationService::current()->Notify( | 95 content::NotificationService::current()->Notify( |
117 chrome::NOTIFICATION_TOP_SITES_LOADED, | 96 chrome::NOTIFICATION_TOP_SITES_LOADED, |
118 content::Source<Profile>(profile_), | 97 content::Source<Profile>(profile_), |
119 content::Details<history::TopSites>(top_sites)); | 98 content::Details<history::TopSites>(top_sites)); |
120 } | 99 } |
121 | 100 |
122 void ChromeHistoryClient::TopSitesChanged(history::TopSites* top_sites) { | 101 void ChromeHistoryClient::TopSitesChanged(history::TopSites* top_sites) { |
123 content::NotificationService::current()->Notify( | 102 content::NotificationService::current()->Notify( |
124 chrome::NOTIFICATION_TOP_SITES_CHANGED, | 103 chrome::NOTIFICATION_TOP_SITES_CHANGED, |
125 content::Source<history::TopSites>(top_sites), | 104 content::Source<history::TopSites>(top_sites), |
126 content::NotificationService::NoDetails()); | 105 content::NotificationService::NoDetails()); |
127 } | 106 } |
OLD | NEW |