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

Side by Side Diff: chrome/browser/history/top_sites_factory.cc

Issue 1809603005: Create a --disable-top-sites flag for use by telemetry tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move flag check to factory Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/history/top_sites_factory.h" 5 #include "chrome/browser/history/top_sites_factory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "chrome/browser/history/history_service_factory.h" 14 #include "chrome/browser/history/history_service_factory.h"
14 #include "chrome/browser/history/history_utils.h" 15 #include "chrome/browser/history/history_utils.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/grit/chromium_strings.h" 17 #include "chrome/grit/chromium_strings.h"
17 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
18 #include "chrome/grit/locale_settings.h" 19 #include "chrome/grit/locale_settings.h"
19 #include "components/history/core/browser/history_constants.h" 20 #include "components/history/core/browser/history_constants.h"
20 #include "components/history/core/browser/top_sites_impl.h" 21 #include "components/history/core/browser/top_sites_impl.h"
21 #include "components/keyed_service/content/browser_context_dependency_manager.h" 22 #include "components/keyed_service/content/browser_context_dependency_manager.h"
22 #include "components/pref_registry/pref_registry_syncable.h" 23 #include "components/pref_registry/pref_registry_syncable.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "grit/theme_resources.h" 25 #include "grit/theme_resources.h"
25 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 namespace { 29 namespace {
29 30
31 const char kDisableTopSites[] = "disable-top-sites";
32
33 bool IsTopSitesDisabled() {
34 return base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableTopSites);
35 }
36
30 struct RawPrepopulatedPage { 37 struct RawPrepopulatedPage {
31 int url_id; // The resource for the page URL. 38 int url_id; // The resource for the page URL.
32 int title_id; // The resource for the page title. 39 int title_id; // The resource for the page title.
33 int favicon_id; // The raw data resource for the favicon. 40 int favicon_id; // The raw data resource for the favicon.
34 int thumbnail_id; // The raw data resource for the thumbnail. 41 int thumbnail_id; // The raw data resource for the thumbnail.
35 SkColor color; // The best color to highlight the page (should roughly 42 SkColor color; // The best color to highlight the page (should roughly
36 // match favicon). 43 // match favicon).
37 }; 44 };
38 45
39 #if !defined(OS_ANDROID) 46 #if !defined(OS_ANDROID)
(...skipping 29 matching lines...) Expand all
69 page.thumbnail_id, page.color)); 76 page.thumbnail_id, page.color));
70 } 77 }
71 #endif 78 #endif
72 } 79 }
73 80
74 } // namespace 81 } // namespace
75 82
76 // static 83 // static
77 scoped_refptr<history::TopSites> TopSitesFactory::GetForProfile( 84 scoped_refptr<history::TopSites> TopSitesFactory::GetForProfile(
78 Profile* profile) { 85 Profile* profile) {
86 if (IsTopSitesDisabled())
87 return nullptr;
79 return static_cast<history::TopSites*>( 88 return static_cast<history::TopSites*>(
80 GetInstance()->GetServiceForBrowserContext(profile, true).get()); 89 GetInstance()->GetServiceForBrowserContext(profile, true).get());
81 } 90 }
82 91
83 // static 92 // static
84 TopSitesFactory* TopSitesFactory::GetInstance() { 93 TopSitesFactory* TopSitesFactory::GetInstance() {
85 return base::Singleton<TopSitesFactory>::get(); 94 return base::Singleton<TopSitesFactory>::get();
86 } 95 }
87 96
88 // static 97 // static
(...skipping 29 matching lines...) Expand all
118 } 127 }
119 128
120 void TopSitesFactory::RegisterProfilePrefs( 129 void TopSitesFactory::RegisterProfilePrefs(
121 user_prefs::PrefRegistrySyncable* registry) { 130 user_prefs::PrefRegistrySyncable* registry) {
122 history::TopSitesImpl::RegisterPrefs(registry); 131 history::TopSitesImpl::RegisterPrefs(registry);
123 } 132 }
124 133
125 bool TopSitesFactory::ServiceIsNULLWhileTesting() const { 134 bool TopSitesFactory::ServiceIsNULLWhileTesting() const {
126 return true; 135 return true;
127 } 136 }
OLDNEW
« no previous file with comments | « chrome/browser/history/top_sites_factory.h ('k') | components/history/core/browser/top_sites_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698