Index: chrome/browser/history/top_sites_factory.cc |
diff --git a/chrome/browser/history/top_sites_factory.cc b/chrome/browser/history/top_sites_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cd48814ac433933de73dce2f09385e59648d58e0 |
--- /dev/null |
+++ b/chrome/browser/history/top_sites_factory.cc |
@@ -0,0 +1,47 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
sdefresne
2015/01/08 10:41:01
nit: you'll only land this is 2015, so please use
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/history/top_sites_factory.h" |
+ |
+#include "chrome/browser/history/top_sites_impl.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/common/chrome_constants.h" |
+#include "components/keyed_service/content/browser_context_dependency_manager.h" |
+ |
+using namespace history; |
sdefresne
2015/01/08 10:41:01
nit: we prefer not to use "using namespace" unless
Bernhard Bauer
2015/01/08 10:45:14
Good catch! The Google C++ style guide is actually
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
|
+ |
+// static |
+scoped_refptr<history::TopSites> TopSitesFactory::GetForProfile( |
+ Profile* profile) { |
+ return static_cast<history::TopSites*>( |
+ GetInstance()->GetServiceForBrowserContext(profile, true).get()); |
+} |
+ |
+// static |
+scoped_refptr<history::TopSites> TopSitesFactory::GetForProfileIfExists( |
+ Profile* profile) { |
+ return static_cast<history::TopSites*>( |
+ GetInstance()->GetServiceForBrowserContext(profile, false).get()); |
+} |
+ |
+// static |
+TopSitesFactory* TopSitesFactory::GetInstance() { |
+ return Singleton<TopSitesFactory>::get(); |
+} |
+ |
+scoped_refptr<RefcountedKeyedService> TopSitesFactory::BuildServiceInstanceFor( |
+ content::BrowserContext* profile) const { |
sdefresne
2015/01/08 10:41:01
nit: s/profile/context/
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
|
+ TopSitesImpl* top_sites = new TopSitesImpl(static_cast<Profile*>(profile)); |
+ top_sites->Init(profile->GetPath().Append(chrome::kTopSitesFilename)); |
+ return make_scoped_refptr<history::TopSites>(top_sites); |
Bernhard Bauer
2015/01/08 10:22:05
Does a simple make_scoped_refptr() work? If it doe
Jitu( very slow this week)
2015/01/12 11:30:07
I think
return make_scoped_refptr(top_sites) work
Bernhard Bauer
2015/01/12 14:32:23
That would be a possible alternative, but what you
|
+} |
+ |
+TopSitesFactory::TopSitesFactory() |
+ : RefcountedBrowserContextKeyedServiceFactory( |
+ "TopSitesService", |
sdefresne
2015/01/08 10:41:01
nit: the value passed there is usually the name of
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
|
+ BrowserContextDependencyManager::GetInstance()) { |
+} |
+ |
+TopSitesFactory::~TopSitesFactory() { |
+} |