Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
Marc Treib
2016/07/29 09:54:56
What year is it?!
Also no "(c)"
jkrcal
2016/07/29 12:42:41
Done.
| |
| 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_NTP_SNIPPETS_NTP_BOOKMARK_HELPER_H_ | |
| 6 #define CHROME_BROWSER_NTP_SNIPPETS_NTP_BOOKMARK_HELPER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "content/public/browser/web_contents_observer.h" | |
| 12 #include "content/public/browser/web_contents_user_data.h" | |
| 13 | |
| 14 namespace bookmarks { | |
| 15 class BookmarkModel; | |
| 16 } // namespace bookmarks | |
| 17 | |
| 18 namespace content { | |
| 19 class NavigationHandle; | |
|
Marc Treib
2016/07/29 09:54:56
nit: class WebContents
jkrcal
2016/07/29 12:42:41
Done. Out of curiosity: Do I need to redeclare it
Marc Treib
2016/07/29 14:36:42
Generally the rule is to include/forward-declare e
jkrcal
2016/07/29 15:34:06
Thanks.
| |
| 20 } // namespace content | |
| 21 | |
| 22 using bookmarks::BookmarkModel; | |
|
Marc Treib
2016/07/29 09:54:56
No using in headers please
jkrcal
2016/07/29 12:42:41
Done.
| |
| 23 | |
| 24 namespace ntp_snippets { | |
|
Marc Treib
2016/07/29 09:54:56
This shouldn't be in the ntp_snippets namespace; t
jkrcal
2016/07/29 12:42:41
Done.
| |
| 25 | |
| 26 class BookmarkNavigationObserver; | |
| 27 | |
| 28 // A bridge class between platform-specific content::WebContentsObserver and the | |
| 29 // abstract interface ntp_snippets::BookmarkNavigationObserver. | |
| 30 class NTPBookmarkHelper | |
|
tschumann
2016/07/29 10:18:43
nit: I have an issue with any class or library hav
jkrcal
2016/07/29 12:42:41
Done.
| |
| 31 : public content::WebContentsObserver, | |
| 32 public content::WebContentsUserData<NTPBookmarkHelper> { | |
| 33 public: | |
| 34 ~NTPBookmarkHelper() override; | |
| 35 | |
| 36 static void CreateForWebContentsWithBookmarkModel( | |
|
Marc Treib
2016/07/29 09:54:56
Is this a common pattern? What if there already is
blundell
2016/07/29 09:59:23
drive-by: Yes, this is the common pattern here. We
jkrcal
2016/07/29 12:42:41
Acknowledged.
| |
| 37 content::WebContents* web_contents, | |
| 38 BookmarkModel* bookmark_model); | |
| 39 | |
| 40 private: | |
| 41 explicit NTPBookmarkHelper( | |
| 42 content::WebContents* web_contents, | |
| 43 BookmarkModel* bookmark_model); | |
| 44 friend class content::WebContentsUserData<NTPBookmarkHelper>; | |
| 45 | |
| 46 // Overridden from content::WebContentsObserver: | |
| 47 void DidStartNavigation( | |
| 48 content::NavigationHandle* navigation_handle) override; | |
| 49 | |
| 50 BookmarkModel* bookmark_model_; | |
| 51 std::unique_ptr<ntp_snippets::BookmarkNavigationObserver> | |
| 52 navigation_observer_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(NTPBookmarkHelper); | |
| 55 }; | |
| 56 | |
| 57 } // namespace ntp_snippets | |
| 58 | |
| 59 #endif // CHROME_BROWSER_NTP_SNIPPETS_NTP_BOOKMARK_HELPER_H_ | |
| OLD | NEW |