Index: chrome/browser/ntp_snippets/ntp_bookmark_helper.h |
diff --git a/chrome/browser/ntp_snippets/ntp_bookmark_helper.h b/chrome/browser/ntp_snippets/ntp_bookmark_helper.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..79704966dafe50699ea42112baaeedc69e9a72ce |
--- /dev/null |
+++ b/chrome/browser/ntp_snippets/ntp_bookmark_helper.h |
@@ -0,0 +1,59 @@ |
+// 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.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_NTP_SNIPPETS_NTP_BOOKMARK_HELPER_H_ |
+#define CHROME_BROWSER_NTP_SNIPPETS_NTP_BOOKMARK_HELPER_H_ |
+ |
+#include <memory> |
+ |
+#include "base/macros.h" |
+#include "content/public/browser/web_contents_observer.h" |
+#include "content/public/browser/web_contents_user_data.h" |
+ |
+namespace bookmarks { |
+class BookmarkModel; |
+} // namespace bookmarks |
+ |
+namespace content { |
+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.
|
+} // namespace content |
+ |
+using bookmarks::BookmarkModel; |
Marc Treib
2016/07/29 09:54:56
No using in headers please
jkrcal
2016/07/29 12:42:41
Done.
|
+ |
+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.
|
+ |
+class BookmarkNavigationObserver; |
+ |
+// A bridge class between platform-specific content::WebContentsObserver and the |
+// abstract interface ntp_snippets::BookmarkNavigationObserver. |
+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.
|
+ : public content::WebContentsObserver, |
+ public content::WebContentsUserData<NTPBookmarkHelper> { |
+ public: |
+ ~NTPBookmarkHelper() override; |
+ |
+ 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.
|
+ content::WebContents* web_contents, |
+ BookmarkModel* bookmark_model); |
+ |
+ private: |
+ explicit NTPBookmarkHelper( |
+ content::WebContents* web_contents, |
+ BookmarkModel* bookmark_model); |
+ friend class content::WebContentsUserData<NTPBookmarkHelper>; |
+ |
+ // Overridden from content::WebContentsObserver: |
+ void DidStartNavigation( |
+ content::NavigationHandle* navigation_handle) override; |
+ |
+ BookmarkModel* bookmark_model_; |
+ std::unique_ptr<ntp_snippets::BookmarkNavigationObserver> |
+ navigation_observer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NTPBookmarkHelper); |
+}; |
+ |
+} // namespace ntp_snippets |
+ |
+#endif // CHROME_BROWSER_NTP_SNIPPETS_NTP_BOOKMARK_HELPER_H_ |