OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
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/ntp_bookmark_helper.h" | |
6 | |
7 #include "components/bookmarks/browser/bookmark_model.h" | |
8 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_date_helper.h" | |
9 #include "content/public/browser/navigation_handle.h" | |
10 | |
11 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ntp_snippets::NTPBookmarkHelper); | |
12 | |
13 namespace ntp_snippets { | |
14 | |
15 // static | |
16 void NTPBookmarkHelper::CreateForWebContentsWithBookmarkModel( | |
17 content::WebContents* web_contents, | |
18 BookmarkModel* bookmark_model) { | |
19 DCHECK(web_contents); | |
20 web_contents->SetUserData( | |
21 UserDataKey(), new NTPBookmarkHelper(web_contents, bookmark_model)); | |
22 } | |
23 | |
24 NTPBookmarkHelper::~NTPBookmarkHelper() {} | |
25 | |
26 NTPBookmarkHelper::NTPBookmarkHelper( | |
27 content::WebContents* web_contents, | |
28 BookmarkModel* bookmark_model) | |
29 : content::WebContentsObserver(web_contents), | |
30 bookmark_model_(bookmark_model), | |
31 navigation_observer_(new BookmarkLastVisitDateHelper) {} | |
32 | |
33 void NTPBookmarkHelper::DidStartNavigation( | |
34 content::NavigationHandle* navigation_handle) { | |
35 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsErrorPage()) | |
36 return; | |
37 navigation_observer_->OnURLVisitedInMainFrame(bookmark_model_, | |
38 navigation_handle->GetURL()); | |
39 } | |
40 | |
41 } // namespace ntp_snippets | |
OLD | NEW |