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_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_ |
6 #define CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/macros.h" |
9 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 9 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
10 #include "components/bookmarks/browser/bookmark_client.h" | 10 #include "components/bookmarks/browser/bookmark_client.h" |
11 #include "components/keyed_service/core/keyed_service.h" | |
12 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
14 | 13 |
15 class BookmarkModel; | 14 class BookmarkModel; |
16 class Profile; | 15 class Profile; |
17 | 16 |
18 class ChromeBookmarkClient : public BookmarkClient, | 17 class ChromeBookmarkClient : public BookmarkClient, |
19 public content::NotificationObserver, | 18 public content::NotificationObserver, |
20 public KeyedService, | |
21 public BaseBookmarkModelObserver { | 19 public BaseBookmarkModelObserver { |
22 public: | 20 public: |
23 // |index_urls| says whether URLs should be stored in the BookmarkIndex | 21 explicit ChromeBookmarkClient(Profile* profile); |
24 // in addition to bookmark titles. | |
25 ChromeBookmarkClient(Profile* profile, bool index_urls); | |
26 virtual ~ChromeBookmarkClient(); | 22 virtual ~ChromeBookmarkClient(); |
27 | 23 |
28 // Returns the BookmarkModel that corresponds to this ChromeBookmarkClient. | 24 void Init(BookmarkModel* model); |
29 BookmarkModel* model() { return model_.get(); } | 25 |
26 // KeyedService: | |
27 virtual void Shutdown() OVERRIDE; | |
30 | 28 |
31 // BookmarkClient: | 29 // BookmarkClient: |
32 virtual bool PreferTouchIcon() OVERRIDE; | 30 virtual bool PreferTouchIcon() OVERRIDE; |
33 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForURL( | 31 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForURL( |
34 const GURL& page_url, | 32 const GURL& page_url, |
35 int icon_types, | 33 int icon_types, |
36 int desired_size_in_dip, | 34 int desired_size_in_dip, |
37 const favicon_base::FaviconImageCallback& callback, | 35 const favicon_base::FaviconImageCallback& callback, |
38 base::CancelableTaskTracker* tracker) OVERRIDE; | 36 base::CancelableTaskTracker* tracker) OVERRIDE; |
39 virtual bool SupportsTypedCountForNodes() OVERRIDE; | 37 virtual bool SupportsTypedCountForNodes() OVERRIDE; |
40 virtual void GetTypedCountForNodes( | 38 virtual void GetTypedCountForNodes( |
41 const NodeSet& nodes, | 39 const NodeSet& nodes, |
42 NodeTypedCountPairs* node_typed_count_pairs) OVERRIDE; | 40 NodeTypedCountPairs* node_typed_count_pairs) OVERRIDE; |
43 virtual bool IsPermanentNodeVisible(int node_type) OVERRIDE; | 41 virtual bool IsPermanentNodeVisible(int node_type) OVERRIDE; |
44 virtual void RecordAction(const base::UserMetricsAction& action) OVERRIDE; | 42 virtual void RecordAction(const base::UserMetricsAction& action) OVERRIDE; |
45 | 43 |
46 // content::NotificationObserver: | 44 // content::NotificationObserver: |
47 virtual void Observe(int type, | 45 virtual void Observe(int type, |
48 const content::NotificationSource& source, | 46 const content::NotificationSource& source, |
49 const content::NotificationDetails& details) OVERRIDE; | 47 const content::NotificationDetails& details) OVERRIDE; |
50 | 48 |
51 // KeyedService: | |
52 virtual void Shutdown() OVERRIDE; | |
53 | |
54 private: | 49 private: |
55 // BaseBookmarkModelObserver: | 50 // BaseBookmarkModelObserver: |
56 virtual void BookmarkModelChanged() OVERRIDE; | 51 virtual void BookmarkModelChanged() OVERRIDE; |
57 virtual void BookmarkNodeRemoved(BookmarkModel* model, | 52 virtual void BookmarkNodeRemoved(BookmarkModel* model, |
58 const BookmarkNode* parent, | 53 const BookmarkNode* parent, |
59 int old_index, | 54 int old_index, |
60 const BookmarkNode* node, | 55 const BookmarkNode* node, |
61 const std::set<GURL>& removed_urls) OVERRIDE; | 56 const std::set<GURL>& removed_urls) OVERRIDE; |
62 virtual void BookmarkAllNodesRemoved( | 57 virtual void BookmarkAllNodesRemoved( |
63 BookmarkModel* model, | 58 BookmarkModel* model, |
64 const std::set<GURL>& removed_urls) OVERRIDE; | 59 const std::set<GURL>& removed_urls) OVERRIDE; |
65 | 60 |
66 Profile* profile_; | 61 Profile* profile_; |
67 | 62 |
68 content::NotificationRegistrar registrar_; | 63 content::NotificationRegistrar registrar_; |
69 | 64 |
70 scoped_ptr<BookmarkModel> model_; | 65 BookmarkModel* model_; |
blundell
2014/06/05 09:48:30
Document lifetime expectations.
sdefresne
2014/06/10 13:12:21
Done.
| |
71 | 66 |
72 DISALLOW_COPY_AND_ASSIGN(ChromeBookmarkClient); | 67 DISALLOW_COPY_AND_ASSIGN(ChromeBookmarkClient); |
73 }; | 68 }; |
74 | 69 |
75 #endif // CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_ | 70 #endif // CHROME_BROWSER_BOOKMARKS_CHROME_BOOKMARK_CLIENT_H_ |
OLD | NEW |