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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_
6 #define CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_
8 #include "base/macros.h"
9 #include "components/history/core/browser/history_client.h"
10 #include "components/history/core/browser/top_sites_observer.h"
19 // This class implements history::HistoryClient to abstract operations that
20 // depend on Chrome environment.
21 class ChromeHistoryClient : public history::HistoryClient,
22 public history::TopSitesObserver {
24 explicit ChromeHistoryClient(BookmarkModel* bookmark_model,
26 history::TopSites* top_sites);
27 virtual ~ChromeHistoryClient();
29 // history::HistoryClient:
30 virtual void BlockUntilBookmarksLoaded() OVERRIDE;
31 virtual bool IsBookmarked(const GURL& url) OVERRIDE;
32 virtual void GetBookmarks(
33 std::vector<history::URLAndTitle>* bookmarks) OVERRIDE;
34 virtual void NotifyProfileError(sql::InitStatus init_status) OVERRIDE;
35 virtual bool ShouldReportDatabaseError() OVERRIDE;
38 virtual void Shutdown() OVERRIDE;
41 virtual void TopSitesLoaded(history::TopSites* top_sites) OVERRIDE;
42 virtual void TopSitesChanged(history::TopSites* top_sites) OVERRIDE;
45 // The BookmarkModel, this should outlive ChromeHistoryClient.
46 BookmarkModel* bookmark_model_;
48 // The TopSites object is owned by the Profile (see
49 // chrome/browser/profiles/profile_impl.h)
50 // and lazily constructed by the getter.
51 // ChromeHistoryClient is a KeyedService linked to the Profile lifetime by the
52 // ChromeHistoryClientFactory (which is a BrowserContextKeyedServiceFactory).
53 // Before the Profile is destroyed, all the KeyedService Shutdown methods are
54 // called, and the Profile is fully constructed before any of the KeyedService
55 // can be constructed. The TopSites does not use the HistoryService nor the
56 // HistoryClient during construction (it uses it later, but supports getting
58 history::TopSites* top_sites_;
60 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient);
63 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_