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

Unified Diff: chrome/browser/chromeos/ownership/owner_settings_service_factory.cc

Issue 565293003: Revert of Non-plafrom-specific part of an OwnerSettingsService is moved to components/ownership/*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/ownership/owner_settings_service_factory.cc
diff --git a/chrome/browser/chromeos/ownership/owner_settings_service_factory.cc b/chrome/browser/chromeos/ownership/owner_settings_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4f2e79d1491152e3e49790b684400ec923359241
--- /dev/null
+++ b/chrome/browser/chromeos/ownership/owner_settings_service_factory.cc
@@ -0,0 +1,73 @@
+// Copyright 2014 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/chromeos/ownership/owner_settings_service_factory.h"
+
+#include "base/path_service.h"
+#include "chrome/browser/chromeos/ownership/owner_settings_service.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chromeos/chromeos_paths.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "components/ownership/owner_key_util.h"
+#include "components/ownership/owner_key_util_impl.h"
+
+namespace chromeos {
+
+OwnerSettingsServiceFactory::OwnerSettingsServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "OwnerSettingsService",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+OwnerSettingsServiceFactory::~OwnerSettingsServiceFactory() {
+}
+
+// static
+OwnerSettingsService* OwnerSettingsServiceFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<OwnerSettingsService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+// static
+OwnerSettingsServiceFactory* OwnerSettingsServiceFactory::GetInstance() {
+ return Singleton<OwnerSettingsServiceFactory>::get();
+}
+
+scoped_refptr<ownership::OwnerKeyUtil>
+OwnerSettingsServiceFactory::GetOwnerKeyUtil() {
+ if (owner_key_util_.get())
+ return owner_key_util_;
+ base::FilePath public_key_path;
+ if (!PathService::Get(chromeos::FILE_OWNER_KEY, &public_key_path))
+ return NULL;
+ owner_key_util_ = new ownership::OwnerKeyUtilImpl(public_key_path);
+ return owner_key_util_;
+}
+
+void OwnerSettingsServiceFactory::SetOwnerKeyUtilForTesting(
+ const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util) {
+ owner_key_util_ = owner_key_util;
+}
+
+// static
+KeyedService* OwnerSettingsServiceFactory::BuildInstanceFor(
+ content::BrowserContext* browser_context) {
+ Profile* profile = static_cast<Profile*>(browser_context);
+ if (profile->IsGuestSession() || ProfileHelper::IsSigninProfile(profile))
+ return NULL;
+ return new OwnerSettingsService(profile, GetInstance()->GetOwnerKeyUtil());
+}
+
+bool OwnerSettingsServiceFactory::ServiceIsCreatedWithBrowserContext() const {
+ return true;
+}
+
+KeyedService* OwnerSettingsServiceFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ return BuildInstanceFor(context);
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698