| 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());
|
| +}
|
|
|