Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1637)

Unified Diff: chrome/browser/ntp_snippets/ntp_bookmark_helper.cc

Issue 2184263005: Add a tab helper to record the last visit date for each bookmark. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698