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

Side by Side Diff: chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc

Issue 2842833003: Update SupportsUserData uses with unique_ptr. (Closed)
Patch Set: rebase Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ntp_snippets/bookmark_last_visit_updater.h" 5 #include "chrome/browser/ntp_snippets/bookmark_last_visit_updater.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "components/bookmarks/browser/bookmark_model.h" 8 #include "components/bookmarks/browser/bookmark_model.h"
8 #include "components/bookmarks/browser/bookmark_node.h" 9 #include "components/bookmarks/browser/bookmark_node.h"
9 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" 10 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h"
10 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/navigation_handle.h" 12 #include "content/public/browser/navigation_handle.h"
12 13
13 namespace { 14 namespace {
14 15
15 bool IsMobilePlatform() { 16 bool IsMobilePlatform() {
16 #if defined(OS_ANDROID) // There are no tab helpers on iOS. 17 #if defined(OS_ANDROID) // There are no tab helpers on iOS.
(...skipping 14 matching lines...) Expand all
31 // static 32 // static
32 void BookmarkLastVisitUpdater::MaybeCreateForWebContentsWithBookmarkModel( 33 void BookmarkLastVisitUpdater::MaybeCreateForWebContentsWithBookmarkModel(
33 content::WebContents* web_contents, 34 content::WebContents* web_contents,
34 bookmarks::BookmarkModel* bookmark_model) { 35 bookmarks::BookmarkModel* bookmark_model) {
35 // Do not create the helper for missing |bookmark_model| (in some unit-tests) 36 // Do not create the helper for missing |bookmark_model| (in some unit-tests)
36 // or for incognito profiles where tracking bookmark visits is not desired. 37 // or for incognito profiles where tracking bookmark visits is not desired.
37 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); 38 content::BrowserContext* browser_context = web_contents->GetBrowserContext();
38 if (!bookmark_model || browser_context->IsOffTheRecord()) { 39 if (!bookmark_model || browser_context->IsOffTheRecord()) {
39 return; 40 return;
40 } 41 }
41 web_contents->SetUserData(UserDataKey(), new BookmarkLastVisitUpdater( 42 web_contents->SetUserData(UserDataKey(),
42 web_contents, bookmark_model)); 43 base::WrapUnique(new BookmarkLastVisitUpdater(
44 web_contents, bookmark_model)));
43 } 45 }
44 46
45 BookmarkLastVisitUpdater::BookmarkLastVisitUpdater( 47 BookmarkLastVisitUpdater::BookmarkLastVisitUpdater(
46 content::WebContents* web_contents, 48 content::WebContents* web_contents,
47 bookmarks::BookmarkModel* bookmark_model) 49 bookmarks::BookmarkModel* bookmark_model)
48 : content::WebContentsObserver(web_contents), 50 : content::WebContentsObserver(web_contents),
49 bookmark_model_(bookmark_model), 51 bookmark_model_(bookmark_model),
50 web_contents_(web_contents) { 52 web_contents_(web_contents) {
51 DCHECK(bookmark_model_); 53 DCHECK(bookmark_model_);
52 bookmark_model_->AddObserver(this); 54 bookmark_model_->AddObserver(this);
(...skipping 28 matching lines...) Expand all
81 int index) { 83 int index) {
82 const GURL& new_bookmark_url = parent->GetChild(index)->url(); 84 const GURL& new_bookmark_url = parent->GetChild(index)->url();
83 85
84 if (new_bookmark_url == web_contents_->GetLastCommittedURL()) { 86 if (new_bookmark_url == web_contents_->GetLastCommittedURL()) {
85 // Consider in this TabHelper only bookmarks created from this tab (and not 87 // Consider in this TabHelper only bookmarks created from this tab (and not
86 // the ones created from other tabs or created through bookmark sync). 88 // the ones created from other tabs or created through bookmark sync).
87 ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame( 89 ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame(
88 bookmark_model_, new_bookmark_url, IsMobilePlatform()); 90 bookmark_model_, new_bookmark_url, IsMobilePlatform());
89 } 91 }
90 } 92 }
OLDNEW
« no previous file with comments | « chrome/browser/net/nss_context_chromeos.cc ('k') | chrome/browser/page_load_metrics/metrics_web_contents_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698