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