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 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 ChromeHistoryClient::~ChromeHistoryClient() { | 31 ChromeHistoryClient::~ChromeHistoryClient() { |
32 if (top_sites_) | 32 if (top_sites_) |
33 top_sites_->RemoveObserver(this); | 33 top_sites_->RemoveObserver(this); |
34 } | 34 } |
35 | 35 |
36 void ChromeHistoryClient::SetHistoryService(HistoryService* history_service) { | 36 void ChromeHistoryClient::SetHistoryService(HistoryService* history_service) { |
37 DCHECK(history_service); | 37 DCHECK(history_service); |
38 history_service_ = history_service; | 38 history_service_ = history_service; |
39 history_service_->AddHistoryServiceObserver(this); | 39 history_service_->AddObserver(this); |
40 } | 40 } |
41 | 41 |
42 void ChromeHistoryClient::BlockUntilBookmarksLoaded() { | 42 void ChromeHistoryClient::BlockUntilBookmarksLoaded() { |
43 bookmark_model_->BlockTillLoaded(); | 43 bookmark_model_->BlockTillLoaded(); |
44 } | 44 } |
45 | 45 |
46 bool ChromeHistoryClient::IsBookmarked(const GURL& url) { | 46 bool ChromeHistoryClient::IsBookmarked(const GURL& url) { |
47 return bookmark_model_->IsBookmarked(url); | 47 return bookmark_model_->IsBookmarked(url); |
48 } | 48 } |
49 | 49 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void ChromeHistoryClient::Shutdown() { | 81 void ChromeHistoryClient::Shutdown() { |
82 // It's possible that bookmarks haven't loaded and history is waiting for | 82 // It's possible that bookmarks haven't loaded and history is waiting for |
83 // bookmarks to complete loading. In such a situation history can't shutdown | 83 // bookmarks to complete loading. In such a situation history can't shutdown |
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_->RemoveHistoryServiceObserver(this); | 91 history_service_->RemoveObserver(this); |
92 } | 92 } |
93 | 93 |
94 // TODO(sdefresne): port client listening for NOTIFICATION_HISTORY_URL_VISITED | 94 // TODO(sdefresne): port client listening for NOTIFICATION_HISTORY_URL_VISITED |
95 // to use the HistoryService::Observer pattern instead and remove this method | 95 // to use the HistoryService::Observer pattern instead and remove this method |
96 // when this is complete, http://crbug.com/42178 | 96 // when this is complete, http://crbug.com/42178 |
97 void ChromeHistoryClient::OnURLVisited(ui::PageTransition transition, | 97 void ChromeHistoryClient::OnURLVisited(ui::PageTransition transition, |
98 const history::URLRow& row, | 98 const history::URLRow& row, |
99 const history::RedirectList& redirects, | 99 const history::RedirectList& redirects, |
100 base::Time visit_time) { | 100 base::Time visit_time) { |
101 scoped_ptr<history::URLVisitedDetails> details( | 101 scoped_ptr<history::URLVisitedDetails> details( |
(...skipping 14 matching lines...) Expand all Loading... |
116 content::Source<Profile>(profile_), | 116 content::Source<Profile>(profile_), |
117 content::Details<history::TopSites>(top_sites)); | 117 content::Details<history::TopSites>(top_sites)); |
118 } | 118 } |
119 | 119 |
120 void ChromeHistoryClient::TopSitesChanged(history::TopSites* top_sites) { | 120 void ChromeHistoryClient::TopSitesChanged(history::TopSites* top_sites) { |
121 content::NotificationService::current()->Notify( | 121 content::NotificationService::current()->Notify( |
122 chrome::NOTIFICATION_TOP_SITES_CHANGED, | 122 chrome::NOTIFICATION_TOP_SITES_CHANGED, |
123 content::Source<history::TopSites>(top_sites), | 123 content::Source<history::TopSites>(top_sites), |
124 content::NotificationService::NoDetails()); | 124 content::NotificationService::NoDetails()); |
125 } | 125 } |
OLD | NEW |