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

Side by Side Diff: chrome/browser/jumplist_win.cc

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra inclusion from testing_profile.h Created 5 years, 11 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/jumplist_win.h" 5 #include "chrome/browser/jumplist_win.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/prefs/pref_change_registrar.h" 13 #include "base/prefs/pref_change_registrar.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chrome_notification_types.h" 18 #include "chrome/browser/chrome_notification_types.h"
19 #include "chrome/browser/favicon/favicon_service.h" 19 #include "chrome/browser/favicon/favicon_service.h"
20 #include "chrome/browser/favicon/favicon_service_factory.h" 20 #include "chrome/browser/favicon/favicon_service_factory.h"
21 #include "chrome/browser/history/history_service.h" 21 #include "chrome/browser/history/history_service.h"
22 #include "chrome/browser/history/top_sites.h" 22 #include "chrome/browser/history/top_sites.h"
23 #include "chrome/browser/history/top_sites_factory.h"
23 #include "chrome/browser/metrics/jumplist_metrics_win.h" 24 #include "chrome/browser/metrics/jumplist_metrics_win.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_info_cache.h" 26 #include "chrome/browser/profiles/profile_info_cache.h"
26 #include "chrome/browser/profiles/profile_manager.h" 27 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/sessions/tab_restore_service.h" 28 #include "chrome/browser/sessions/tab_restore_service.h"
28 #include "chrome/browser/sessions/tab_restore_service_factory.h" 29 #include "chrome/browser/sessions/tab_restore_service_factory.h"
29 #include "chrome/browser/shell_integration.h" 30 #include "chrome/browser/shell_integration.h"
30 #include "chrome/common/chrome_constants.h" 31 #include "chrome/common/chrome_constants.h"
31 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // from the observer list. 243 // from the observer list.
243 TabRestoreService* tab_restore_service = 244 TabRestoreService* tab_restore_service =
244 TabRestoreServiceFactory::GetForProfile(profile_); 245 TabRestoreServiceFactory::GetForProfile(profile_);
245 if (!tab_restore_service) 246 if (!tab_restore_service)
246 return; 247 return;
247 248
248 app_id_ = ShellIntegration::GetChromiumModelIdForProfile(profile_->GetPath()); 249 app_id_ = ShellIntegration::GetChromiumModelIdForProfile(profile_->GetPath());
249 icon_dir_ = profile_->GetPath().Append(chrome::kJumpListIconDirname); 250 icon_dir_ = profile_->GetPath().Append(chrome::kJumpListIconDirname);
250 use_profiles_category_ = HasProfilesJumplistExperiment(); 251 use_profiles_category_ = HasProfilesJumplistExperiment();
251 252
252 history::TopSites* top_sites = profile_->GetTopSites(); 253 scoped_refptr<history::TopSites> top_sites =
254 TopSitesFactory::GetForProfile(profile_);
253 if (top_sites) { 255 if (top_sites) {
254 // TopSites updates itself after a delay. This is especially noticable when 256 // TopSites updates itself after a delay. This is especially noticable when
255 // your profile is empty. Ask TopSites to update itself when jumplist is 257 // your profile is empty. Ask TopSites to update itself when jumplist is
256 // initialized. 258 // initialized.
257 top_sites->SyncWithHistory(); 259 top_sites->SyncWithHistory();
258 registrar_.reset(new content::NotificationRegistrar); 260 registrar_.reset(new content::NotificationRegistrar);
259 // Register as TopSitesObserver so that we can update ourselves when the 261 // Register as TopSitesObserver so that we can update ourselves when the
260 // TopSites changes. 262 // TopSites changes.
261 top_sites->AddObserver(this); 263 top_sites->AddObserver(this);
262 // Register for notification when profile is destroyed to ensure that all 264 // Register for notification when profile is destroyed to ensure that all
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 306 }
305 } 307 }
306 308
307 void JumpList::Terminate() { 309 void JumpList::Terminate() {
308 CancelPendingUpdate(); 310 CancelPendingUpdate();
309 if (profile_) { 311 if (profile_) {
310 TabRestoreService* tab_restore_service = 312 TabRestoreService* tab_restore_service =
311 TabRestoreServiceFactory::GetForProfile(profile_); 313 TabRestoreServiceFactory::GetForProfile(profile_);
312 if (tab_restore_service) 314 if (tab_restore_service)
313 tab_restore_service->RemoveObserver(this); 315 tab_restore_service->RemoveObserver(this);
314 history::TopSites* top_sites = profile_->GetTopSites(); 316 scoped_refptr<history::TopSites> top_sites =
317 TopSitesFactory::GetForProfile(profile_);
315 if (top_sites) 318 if (top_sites)
316 top_sites->RemoveObserver(this); 319 top_sites->RemoveObserver(this);
317 registrar_.reset(); 320 registrar_.reset();
318 pref_change_registrar_.reset(); 321 pref_change_registrar_.reset();
319 } 322 }
320 profile_ = NULL; 323 profile_ = NULL;
321 } 324 }
322 325
323 void JumpList::OnMostVisitedURLsAvailable( 326 void JumpList::OnMostVisitedURLsAvailable(
324 const history::MostVisitedURLList& data) { 327 const history::MostVisitedURLList& data) {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 607
605 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { 608 void JumpList::TopSitesLoaded(history::TopSites* top_sites) {
606 } 609 }
607 610
608 void JumpList::TopSitesChanged(history::TopSites* top_sites) { 611 void JumpList::TopSitesChanged(history::TopSites* top_sites) {
609 top_sites->GetMostVisitedURLs( 612 top_sites->GetMostVisitedURLs(
610 base::Bind(&JumpList::OnMostVisitedURLsAvailable, 613 base::Bind(&JumpList::OnMostVisitedURLsAvailable,
611 weak_ptr_factory_.GetWeakPtr()), 614 weak_ptr_factory_.GetWeakPtr()),
612 false); 615 false);
613 } 616 }
OLDNEW
« no previous file with comments | « chrome/browser/history/top_sites_impl_unittest.cc ('k') | chrome/browser/profiles/off_the_record_profile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698