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 #ifndef CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ |
6 #define CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ | 6 #define CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "components/history/core/browser/history_client.h" | 9 #include "components/history/core/browser/history_client.h" |
10 #include "components/history/core/browser/history_service_observer.h" | 10 #include "components/history/core/browser/history_service_observer.h" |
11 #include "components/history/core/browser/top_sites_observer.h" | 11 #include "components/history/core/browser/top_sites_observer.h" |
12 | 12 |
13 class BookmarkModel; | 13 class BookmarkModel; |
14 class HistoryService; | 14 class HistoryService; |
15 class Profile; | 15 class Profile; |
16 | 16 |
17 namespace history { | 17 namespace history { |
18 class TopSites; | 18 class TopSites; |
19 } | 19 } |
20 | 20 |
21 // This class implements history::HistoryClient to abstract operations that | 21 // This class implements history::HistoryClient to abstract operations that |
22 // depend on Chrome environment. | 22 // depend on Chrome environment. |
23 class ChromeHistoryClient : public history::HistoryClient, | 23 class ChromeHistoryClient : public history::HistoryClient, |
24 public history::HistoryServiceObserver, | 24 public history::HistoryServiceObserver, |
25 public history::TopSitesObserver { | 25 public history::TopSitesObserver { |
26 public: | 26 public: |
27 explicit ChromeHistoryClient(BookmarkModel* bookmark_model, | 27 explicit ChromeHistoryClient(BookmarkModel* bookmark_model, |
28 Profile* profile, | 28 Profile* profile, |
29 history::TopSites* top_sites); | 29 history::TopSites* top_sites); |
30 virtual ~ChromeHistoryClient(); | 30 ~ChromeHistoryClient() override; |
31 | 31 |
32 // TODO(sdefresne): once NOTIFICATION_HISTORY_URL* notifications are no | 32 // TODO(sdefresne): once NOTIFICATION_HISTORY_URL* notifications are no |
33 // longer used, remove this reference to the HistoryService from the | 33 // longer used, remove this reference to the HistoryService from the |
34 // ChromeHistoryClient, http://crbug.com/373326 | 34 // ChromeHistoryClient, http://crbug.com/373326 |
35 void SetHistoryService(HistoryService* history_service); | 35 void SetHistoryService(HistoryService* history_service); |
36 | 36 |
37 // history::HistoryClient: | 37 // history::HistoryClient: |
38 virtual void BlockUntilBookmarksLoaded() override; | 38 void BlockUntilBookmarksLoaded() override; |
39 virtual bool IsBookmarked(const GURL& url) override; | 39 bool IsBookmarked(const GURL& url) override; |
40 virtual void GetBookmarks( | 40 void GetBookmarks(std::vector<history::URLAndTitle>* bookmarks) override; |
41 std::vector<history::URLAndTitle>* bookmarks) override; | 41 void NotifyProfileError(sql::InitStatus init_status) override; |
42 virtual void NotifyProfileError(sql::InitStatus init_status) override; | 42 bool ShouldReportDatabaseError() override; |
43 virtual bool ShouldReportDatabaseError() override; | |
44 | 43 |
45 // KeyedService: | 44 // KeyedService: |
46 virtual void Shutdown() override; | 45 void Shutdown() override; |
47 | 46 |
48 // TopSitesObserver: | 47 // TopSitesObserver: |
49 virtual void TopSitesLoaded(history::TopSites* top_sites) override; | 48 void TopSitesLoaded(history::TopSites* top_sites) override; |
50 virtual void TopSitesChanged(history::TopSites* top_sites) override; | 49 void TopSitesChanged(history::TopSites* top_sites) override; |
51 | 50 |
52 private: | 51 private: |
53 // The BookmarkModel, this should outlive ChromeHistoryClient. | 52 // The BookmarkModel, this should outlive ChromeHistoryClient. |
54 BookmarkModel* bookmark_model_; | 53 BookmarkModel* bookmark_model_; |
55 Profile* profile_; | 54 Profile* profile_; |
56 HistoryService* history_service_; | 55 HistoryService* history_service_; |
57 // The TopSites object is owned by the Profile (see | 56 // The TopSites object is owned by the Profile (see |
58 // chrome/browser/profiles/profile_impl.h) | 57 // chrome/browser/profiles/profile_impl.h) |
59 // and lazily constructed by the getter. | 58 // and lazily constructed by the getter. |
60 // ChromeHistoryClient is a KeyedService linked to the Profile lifetime by the | 59 // ChromeHistoryClient is a KeyedService linked to the Profile lifetime by the |
61 // ChromeHistoryClientFactory (which is a BrowserContextKeyedServiceFactory). | 60 // ChromeHistoryClientFactory (which is a BrowserContextKeyedServiceFactory). |
62 // Before the Profile is destroyed, all the KeyedService Shutdown methods are | 61 // Before the Profile is destroyed, all the KeyedService Shutdown methods are |
63 // called, and the Profile is fully constructed before any of the KeyedService | 62 // called, and the Profile is fully constructed before any of the KeyedService |
64 // can be constructed. The TopSites does not use the HistoryService nor the | 63 // can be constructed. The TopSites does not use the HistoryService nor the |
65 // HistoryClient during construction (it uses it later, but supports getting | 64 // HistoryClient during construction (it uses it later, but supports getting |
66 // an NULL pointer). | 65 // an NULL pointer). |
67 history::TopSites* top_sites_; | 66 history::TopSites* top_sites_; |
68 | 67 |
69 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient); | 68 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient); |
70 }; | 69 }; |
71 | 70 |
72 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ | 71 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ |
OLD | NEW |