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