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

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

Issue 1205603002: Remove dependency of HistoryServiceFactory on ChromeBookmarkClientFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_history_client
Patch Set: Fix unit_tests on android (only register as BookmarkModelObserver if HistoryService is initialized) Created 5 years, 6 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 <set>
9
10 #include "base/callback_forward.h"
11 #include "base/callback_list.h"
8 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
9 #include "components/history/core/browser/history_client.h" 15 #include "components/history/core/browser/history_client.h"
10 16
17 class GURL;
18
11 namespace bookmarks { 19 namespace bookmarks {
12 class BookmarkModel; 20 class BookmarkModel;
21 class BookmarkNode;
13 } 22 }
14 23
15 // This class implements history::HistoryClient to abstract operations that 24 // This class implements history::HistoryClient to abstract operations that
16 // depend on Chrome environment. 25 // depend on Chrome environment.
17 class ChromeHistoryClient : public history::HistoryClient { 26 class ChromeHistoryClient : public history::HistoryClient,
27 public bookmarks::BaseBookmarkModelObserver {
18 public: 28 public:
19 explicit ChromeHistoryClient(bookmarks::BookmarkModel* bookmark_model); 29 explicit ChromeHistoryClient(bookmarks::BookmarkModel* bookmark_model);
20 ~ChromeHistoryClient() override; 30 ~ChromeHistoryClient() override;
21 31
22 // history::HistoryClient implementation. 32 // history::HistoryClient implementation.
33 void OnHistoryServiceCreated(
34 history::HistoryService* history_service) override;
23 void Shutdown() override; 35 void Shutdown() override;
24 bool CanAddURL(const GURL& url) override; 36 bool CanAddURL(const GURL& url) override;
25 void NotifyProfileError(sql::InitStatus init_status) override; 37 void NotifyProfileError(sql::InitStatus init_status) override;
26 scoped_ptr<history::HistoryBackendClient> CreateBackendClient() override; 38 scoped_ptr<history::HistoryBackendClient> CreateBackendClient() override;
27 39
28 private: 40 private:
41 // bookmarks::BaseBookmarkModelObserver implementation.
42 void BookmarkModelChanged() override;
43
44 // bookmarks::BookmarkModelObserver implementation.
45 void BookmarkNodeRemoved(bookmarks::BookmarkModel* bookmark_model,
46 const bookmarks::BookmarkNode* parent,
47 int old_index,
48 const bookmarks::BookmarkNode* node,
49 const std::set<GURL>& removed_url) override;
50 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* bookmark_model,
51 const std::set<GURL>& removed_urls) override;
52
29 // BookmarkModel instance providing access to bookmarks. May be null during 53 // BookmarkModel instance providing access to bookmarks. May be null during
30 // testing but must outlive ChromeHistoryClient if non-null. 54 // testing but must outlive ChromeHistoryClient if non-null.
31 bookmarks::BookmarkModel* bookmark_model_; 55 bookmarks::BookmarkModel* bookmark_model_;
56 bool is_bookmark_model_observer_;
57
58 // Callback invoked when URLs are removed from BookmarkModel.
59 base::Callback<void(const std::set<GURL>&)> on_bookmarks_removed_;
60
61 // Subscription for notifications of changes to favicons.
62 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription>
63 favicon_changed_subscription_;
32 64
33 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient); 65 DISALLOW_COPY_AND_ASSIGN(ChromeHistoryClient);
34 }; 66 };
35 67
36 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_ 68 #endif // CHROME_BROWSER_HISTORY_CHROME_HISTORY_CLIENT_H_
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/chrome_bookmark_client.cc ('k') | chrome/browser/history/chrome_history_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698