Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ntp_snippets/bookmark_last_visit_updater.h" | |
| 6 | |
| 7 #include "components/bookmarks/browser/bookmark_model.h" | |
|
Marc Treib
2016/08/02 13:37:11
This isn't strictly required, since you're not doi
Philipp Keck
2016/08/02 14:06:51
Done.
| |
| 8 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" | |
| 9 #include "content/public/browser/navigation_handle.h" | |
| 10 | |
| 11 DEFINE_WEB_CONTENTS_USER_DATA_KEY(BookmarkLastVisitUpdater); | |
| 12 | |
| 13 BookmarkLastVisitUpdater::~BookmarkLastVisitUpdater() {} | |
| 14 | |
| 15 // static | |
| 16 void BookmarkLastVisitUpdater::CreateForWebContentsWithBookmarkModel( | |
| 17 content::WebContents* web_contents, | |
| 18 bookmarks::BookmarkModel* bookmark_model) { | |
| 19 DCHECK(web_contents); | |
|
Marc Treib
2016/08/02 13:37:11
This is superfluous - if it were null, we'd crash
Philipp Keck
2016/08/02 14:06:51
Done.
| |
| 20 web_contents->SetUserData(UserDataKey(), new BookmarkLastVisitUpdater( | |
| 21 web_contents, bookmark_model)); | |
| 22 } | |
| 23 | |
| 24 BookmarkLastVisitUpdater::BookmarkLastVisitUpdater( | |
| 25 content::WebContents* web_contents, | |
| 26 bookmarks::BookmarkModel* bookmark_model) | |
| 27 : content::WebContentsObserver(web_contents), | |
| 28 bookmark_model_(bookmark_model) {} | |
| 29 | |
| 30 void BookmarkLastVisitUpdater::DidStartNavigation( | |
| 31 content::NavigationHandle* navigation_handle) { | |
| 32 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsErrorPage()) | |
| 33 return; | |
| 34 ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame( | |
| 35 bookmark_model_, navigation_handle->GetURL()); | |
| 36 } | |
| OLD | NEW |