Index: chrome/browser/webdata/web_data_service_factory.cc |
diff --git a/chrome/browser/webdata/web_data_service_factory.cc b/chrome/browser/webdata/web_data_service_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..06da32c9b8db4abfd832833f44159fa9d32371ab |
--- /dev/null |
+++ b/chrome/browser/webdata/web_data_service_factory.cc |
@@ -0,0 +1,64 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/webdata/web_data_service_factory.h" |
+ |
+#include "base/file_path.h" |
+#include "chrome/browser/profiles/profile_dependency_manager.h" |
+#include "chrome/browser/webdata/web_data_service.h" |
+#include "chrome/common/chrome_constants.h" |
+ |
+WebDataServiceFactory::WebDataServiceFactory() |
+ : RefcountedProfileKeyedServiceFactory( |
+ "WebDataService", |
+ ProfileDependencyManager::GetInstance()) { |
+ // WebDataServiceFactory has no dependecies. |
+} |
+ |
+WebDataServiceFactory::~WebDataServiceFactory() {} |
+ |
+// static |
+scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfile( |
+ Profile* profile, Profile::ServiceAccessType access_type) { |
+ if (access_type == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) { |
+ NOTREACHED(); |
Peter Kasting
2012/03/30 20:31:13
Don't use NOTREACHED() like this -- it violates ou
GeorgeY
2012/04/02 21:57:43
I think it is one of the few places where it makes
Peter Kasting
2012/04/02 22:09:06
Sorry, I don't agree that this qualifies for an ex
GeorgeY
2012/04/02 22:49:02
OK. Removed NOTREACHED in first two places - the t
|
+ return NULL; |
+ } |
+ return static_cast<WebDataService*>( |
+ GetInstance()->GetServiceForProfile(profile, true).get()); |
+} |
+ |
+// static |
+scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists( |
+ Profile* profile, Profile::ServiceAccessType access_type) { |
+ if (access_type == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) { |
+ NOTREACHED(); |
+ return NULL; |
+ } |
+ return static_cast<WebDataService*>( |
+ GetInstance()->GetServiceForProfile(profile, false).get()); |
+} |
+ |
+// static |
+WebDataServiceFactory* WebDataServiceFactory::GetInstance() { |
+ return Singleton<WebDataServiceFactory>::get(); |
+} |
+ |
+bool WebDataServiceFactory::ServiceRedirectedInIncognito() { |
+ return false; |
+} |
+ |
+scoped_refptr<RefcountedProfileKeyedService> |
+WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const { |
+ DCHECK(profile); |
+ |
+ FilePath path = profile->GetPath(); |
+ path = path.Append(chrome::kWebDataFilename); |
+ |
+ scoped_refptr<WebDataService> wds(new WebDataService()); |
+ if (!wds->Init(profile->GetPath())) { |
+ NOTREACHED(); |
+ } |
+ return wds.get(); |
+} |