Index: chrome/browser/ntp_snippets/ntp_bookmark_helper.cc |
diff --git a/chrome/browser/ntp_snippets/ntp_bookmark_helper.cc b/chrome/browser/ntp_snippets/ntp_bookmark_helper.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e393e67d59c0ad80acf31a5e801182f4ce39bda4 |
--- /dev/null |
+++ b/chrome/browser/ntp_snippets/ntp_bookmark_helper.cc |
@@ -0,0 +1,41 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
Marc Treib
2016/07/29 09:54:56
Also here
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. |
+ |
+#include "chrome/browser/ntp_snippets/ntp_bookmark_helper.h" |
+ |
+#include "components/bookmarks/browser/bookmark_model.h" |
+#include "components/ntp_snippets/bookmarks/bookmark_last_visit_date_helper.h" |
+#include "content/public/browser/navigation_handle.h" |
+ |
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(ntp_snippets::NTPBookmarkHelper); |
+ |
+namespace ntp_snippets { |
+ |
+// static |
+void NTPBookmarkHelper::CreateForWebContentsWithBookmarkModel( |
+ content::WebContents* web_contents, |
+ BookmarkModel* bookmark_model) { |
+ DCHECK(web_contents); |
+ web_contents->SetUserData( |
+ UserDataKey(), new NTPBookmarkHelper(web_contents, bookmark_model)); |
+} |
+ |
+NTPBookmarkHelper::~NTPBookmarkHelper() {} |
+ |
+NTPBookmarkHelper::NTPBookmarkHelper( |
+ content::WebContents* web_contents, |
+ BookmarkModel* bookmark_model) |
+ : content::WebContentsObserver(web_contents), |
+ bookmark_model_(bookmark_model), |
+ navigation_observer_(new BookmarkLastVisitDateHelper) {} |
+ |
+void NTPBookmarkHelper::DidStartNavigation( |
+ content::NavigationHandle* navigation_handle) { |
+ if (!navigation_handle->IsInMainFrame() || navigation_handle->IsErrorPage()) |
+ return; |
+ navigation_observer_->OnURLVisitedInMainFrame(bookmark_model_, |
+ navigation_handle->GetURL()); |
+} |
+ |
+} // namespace ntp_snippets |