| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_NTP_SNIPPETS_BOOKMARK_LAST_VISIT_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_NTP_SNIPPETS_BOOKMARK_LAST_VISIT_UPDATER_H_ |
| 6 #define CHROME_BROWSER_NTP_SNIPPETS_BOOKMARK_LAST_VISIT_UPDATER_H_ | 6 #define CHROME_BROWSER_NTP_SNIPPETS_BOOKMARK_LAST_VISIT_UPDATER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "components/bookmarks/browser/bookmark_model_observer.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "content/public/browser/web_contents_user_data.h" | 14 #include "content/public/browser/web_contents_user_data.h" |
| 13 | 15 |
| 14 namespace bookmarks { | 16 namespace bookmarks { |
| 15 class BookmarkModel; | 17 class BookmarkModel; |
| 18 class BookmarkNode; |
| 16 } // namespace bookmarks | 19 } // namespace bookmarks |
| 17 | 20 |
| 18 namespace content { | 21 namespace content { |
| 19 class NavigationHandle; | 22 class NavigationHandle; |
| 20 class WebContents; | 23 class WebContents; |
| 21 } // namespace content | 24 } // namespace content |
| 22 | 25 |
| 23 // A bridge class between platform-specific content::WebContentsObserver and the | 26 // A bridge class between platform-specific content::WebContentsObserver and the |
| 24 // generic function ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame(). | 27 // generic function ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame(). |
| 25 class BookmarkLastVisitUpdater | 28 class BookmarkLastVisitUpdater |
| 26 : public content::WebContentsObserver, | 29 : public content::WebContentsObserver, |
| 27 public content::WebContentsUserData<BookmarkLastVisitUpdater> { | 30 public content::WebContentsUserData<BookmarkLastVisitUpdater>, |
| 31 public bookmarks::BookmarkModelObserver { |
| 28 public: | 32 public: |
| 29 ~BookmarkLastVisitUpdater() override; | 33 ~BookmarkLastVisitUpdater() override; |
| 30 | 34 |
| 31 static void CreateForWebContentsWithBookmarkModel( | 35 static void CreateForWebContentsWithBookmarkModel( |
| 32 content::WebContents* web_contents, | 36 content::WebContents* web_contents, |
| 33 bookmarks::BookmarkModel* bookmark_model); | 37 bookmarks::BookmarkModel* bookmark_model); |
| 34 | 38 |
| 39 // BookmarkModelObserver overrides |
| 40 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, |
| 41 bool ids_reassigned) override {} |
| 42 void BookmarkNodeMoved(bookmarks::BookmarkModel* model, |
| 43 const bookmarks::BookmarkNode* old_parent, |
| 44 int old_index, |
| 45 const bookmarks::BookmarkNode* new_parent, |
| 46 int new_index) override {} |
| 47 void BookmarkNodeAdded(bookmarks::BookmarkModel* model, |
| 48 const bookmarks::BookmarkNode* parent, |
| 49 int index) override; |
| 50 void BookmarkNodeRemoved( |
| 51 bookmarks::BookmarkModel* model, |
| 52 const bookmarks::BookmarkNode* parent, |
| 53 int old_index, |
| 54 const bookmarks::BookmarkNode* node, |
| 55 const std::set<GURL>& no_longer_bookmarked) override {} |
| 56 void BookmarkNodeChanged(bookmarks::BookmarkModel* model, |
| 57 const bookmarks::BookmarkNode* node) override {} |
| 58 void BookmarkNodeChildrenReordered( |
| 59 bookmarks::BookmarkModel* model, |
| 60 const bookmarks::BookmarkNode* node) override {} |
| 61 void BookmarkAllUserNodesRemoved( |
| 62 bookmarks::BookmarkModel* model, |
| 63 const std::set<GURL>& removed_urls) override {} |
| 64 void BookmarkNodeFaviconChanged( |
| 65 bookmarks::BookmarkModel* model, |
| 66 const bookmarks::BookmarkNode* node) override {} |
| 67 |
| 35 private: | 68 private: |
| 36 friend class content::WebContentsUserData<BookmarkLastVisitUpdater>; | 69 friend class content::WebContentsUserData<BookmarkLastVisitUpdater>; |
| 37 | 70 |
| 38 BookmarkLastVisitUpdater(content::WebContents* web_contents, | 71 BookmarkLastVisitUpdater(content::WebContents* web_contents, |
| 39 bookmarks::BookmarkModel* bookmark_model); | 72 bookmarks::BookmarkModel* bookmark_model); |
| 40 | 73 |
| 41 // Overridden from content::WebContentsObserver: | 74 // Overridden from content::WebContentsObserver: |
| 42 void DidStartNavigation( | 75 void DidStartNavigation( |
| 43 content::NavigationHandle* navigation_handle) override; | 76 content::NavigationHandle* navigation_handle) override; |
| 44 | 77 |
| 45 bookmarks::BookmarkModel* bookmark_model_; | 78 bookmarks::BookmarkModel* bookmark_model_; |
| 79 content::WebContents* web_contents_; |
| 80 |
| 81 GURL current_navigation_url_; |
| 46 | 82 |
| 47 DISALLOW_COPY_AND_ASSIGN(BookmarkLastVisitUpdater); | 83 DISALLOW_COPY_AND_ASSIGN(BookmarkLastVisitUpdater); |
| 48 }; | 84 }; |
| 49 | 85 |
| 50 #endif // CHROME_BROWSER_NTP_SNIPPETS_BOOKMARK_LAST_VISIT_UPDATER_H_ | 86 #endif // CHROME_BROWSER_NTP_SNIPPETS_BOOKMARK_LAST_VISIT_UPDATER_H_ |
| OLD | NEW |