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

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

Issue 2200113002: [New CL] 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: Remove unnecessary explicit Created 4 years, 4 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
« no previous file with comments | « chrome/browser/ntp_snippets/bookmark_last_visit_updater.h ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc
diff --git a/chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc b/chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc
new file mode 100644
index 0000000000000000000000000000000000000000..001e8e2073d47641aff0adf86872a0bf2f2085f2
--- /dev/null
+++ b/chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc
@@ -0,0 +1,34 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// 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/bookmark_last_visit_updater.h"
+
+#include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h"
+#include "content/public/browser/navigation_handle.h"
+
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(BookmarkLastVisitUpdater);
+
+BookmarkLastVisitUpdater::~BookmarkLastVisitUpdater() {}
+
+// static
+void BookmarkLastVisitUpdater::CreateForWebContentsWithBookmarkModel(
+ content::WebContents* web_contents,
+ bookmarks::BookmarkModel* bookmark_model) {
+ web_contents->SetUserData(UserDataKey(), new BookmarkLastVisitUpdater(
+ web_contents, bookmark_model));
+}
+
+BookmarkLastVisitUpdater::BookmarkLastVisitUpdater(
+ content::WebContents* web_contents,
+ bookmarks::BookmarkModel* bookmark_model)
+ : content::WebContentsObserver(web_contents),
+ bookmark_model_(bookmark_model) {}
+
+void BookmarkLastVisitUpdater::DidStartNavigation(
+ content::NavigationHandle* navigation_handle) {
+ if (!navigation_handle->IsInMainFrame() || navigation_handle->IsErrorPage())
+ return;
+ ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame(
+ bookmark_model_, navigation_handle->GetURL());
+}
« no previous file with comments | « chrome/browser/ntp_snippets/bookmark_last_visit_updater.h ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698