Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: chrome/browser/history/chrome_history_client.h

Issue 631253002: Refactor sending NOTIFICATION_HISTORY_URL_VISITED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/top_sites_observer.h" 11 #include "components/history/core/browser/top_sites_observer.h"
11 12
12 class BookmarkModel; 13 class BookmarkModel;
14 class HistoryService;
13 class Profile; 15 class Profile;
14 16
15 namespace history { 17 namespace history {
16 class TopSites; 18 class TopSites;
17 } 19 }
18 20
19 // This class implements history::HistoryClient to abstract operations that 21 // This class implements history::HistoryClient to abstract operations that
20 // depend on Chrome environment. 22 // depend on Chrome environment.
21 class ChromeHistoryClient : public history::HistoryClient, 23 class ChromeHistoryClient : public history::HistoryClient,
24 public history::HistoryServiceObserver,
22 public history::TopSitesObserver { 25 public history::TopSitesObserver {
23 public: 26 public:
24 explicit ChromeHistoryClient(BookmarkModel* bookmark_model, 27 explicit ChromeHistoryClient(BookmarkModel* bookmark_model,
25 Profile* profile, 28 Profile* profile,
26 history::TopSites* top_sites); 29 history::TopSites* top_sites);
27 virtual ~ChromeHistoryClient(); 30 virtual ~ChromeHistoryClient();
28 31
32 void SetHistoryService(HistoryService* history_service);
33
29 // history::HistoryClient: 34 // history::HistoryClient:
30 virtual void BlockUntilBookmarksLoaded() OVERRIDE; 35 virtual void BlockUntilBookmarksLoaded() OVERRIDE;
31 virtual bool IsBookmarked(const GURL& url) OVERRIDE; 36 virtual bool IsBookmarked(const GURL& url) OVERRIDE;
32 virtual void GetBookmarks( 37 virtual void GetBookmarks(
33 std::vector<history::URLAndTitle>* bookmarks) OVERRIDE; 38 std::vector<history::URLAndTitle>* bookmarks) OVERRIDE;
34 virtual void NotifyProfileError(sql::InitStatus init_status) OVERRIDE; 39 virtual void NotifyProfileError(sql::InitStatus init_status) OVERRIDE;
35 virtual bool ShouldReportDatabaseError() OVERRIDE; 40 virtual bool ShouldReportDatabaseError() OVERRIDE;
36 41
37 // KeyedService: 42 // KeyedService:
38 virtual void Shutdown() OVERRIDE; 43 virtual void Shutdown() OVERRIDE;
39 44
45 // HistoryServiceObserver:
46 virtual void OnURLVisited(ui::PageTransition transition,
47 const history::URLRow& row,
48 const history::RedirectList& redirects,
49 const base::Time& visit_time) OVERRIDE;
50
40 // TopSitesObserver: 51 // TopSitesObserver:
41 virtual void TopSitesLoaded(history::TopSites* top_sites) OVERRIDE; 52 virtual void TopSitesLoaded(history::TopSites* top_sites) OVERRIDE;
42 virtual void TopSitesChanged(history::TopSites* top_sites) OVERRIDE; 53 virtual void TopSitesChanged(history::TopSites* top_sites) OVERRIDE;
43 54
44 private: 55 private:
45 // The BookmarkModel, this should outlive ChromeHistoryClient. 56 // The BookmarkModel, this should outlive ChromeHistoryClient.
46 BookmarkModel* bookmark_model_; 57 BookmarkModel* bookmark_model_;
47 Profile* profile_; 58 Profile* profile_;
59 HistoryService* history_service_;
48 // The TopSites object is owned by the Profile (see 60 // The TopSites object is owned by the Profile (see
49 // chrome/browser/profiles/profile_impl.h) 61 // chrome/browser/profiles/profile_impl.h)
50 // and lazily constructed by the getter. 62 // and lazily constructed by the getter.
51 // ChromeHistoryClient is a KeyedService linked to the Profile lifetime by the 63 // ChromeHistoryClient is a KeyedService linked to the Profile lifetime by the
52 // ChromeHistoryClientFactory (which is a BrowserContextKeyedServiceFactory). 64 // ChromeHistoryClientFactory (which is a BrowserContextKeyedServiceFactory).
53 // Before the Profile is destroyed, all the KeyedService Shutdown methods are 65 // Before the Profile is destroyed, all the KeyedService Shutdown methods are
54 // called, and the Profile is fully constructed before any of the KeyedService 66 // 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 67 // can be constructed. The TopSites does not use the HistoryService nor the
56 // HistoryClient during construction (it uses it later, but supports getting 68 // HistoryClient during construction (it uses it later, but supports getting
57 // an NULL pointer). 69 // an NULL pointer).
58 history::TopSites* top_sites_; 70 history::TopSites* top_sites_;
59 71
60 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient); 72 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient);
61 }; 73 };
62 74
63 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ 75 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/chrome_history_client.cc » ('j') | chrome/browser/history/chrome_history_client.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698