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

Side by Side Diff: chrome/browser/chromeos/ownership/owner_settings_service_factory.cc

Issue 570053002: Revert "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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" 5 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 8 #include "chrome/browser/chromeos/ownership/owner_settings_service.h"
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" 9 #include "chrome/browser/chromeos/profiles/profile_helper.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chromeos/chromeos_paths.h" 11 #include "chromeos/chromeos_paths.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h" 12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 #include "components/ownership/owner_key_util.h" 13 #include "components/ownership/owner_key_util.h"
14 #include "components/ownership/owner_key_util_impl.h" 14 #include "components/ownership/owner_key_util_impl.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 OwnerSettingsServiceChromeOSFactory::OwnerSettingsServiceChromeOSFactory() 18 OwnerSettingsServiceFactory::OwnerSettingsServiceFactory()
19 : BrowserContextKeyedServiceFactory( 19 : BrowserContextKeyedServiceFactory(
20 "OwnerSettingsService", 20 "OwnerSettingsService",
21 BrowserContextDependencyManager::GetInstance()) { 21 BrowserContextDependencyManager::GetInstance()) {
22 } 22 }
23 23
24 OwnerSettingsServiceChromeOSFactory::~OwnerSettingsServiceChromeOSFactory() { 24 OwnerSettingsServiceFactory::~OwnerSettingsServiceFactory() {
25 } 25 }
26 26
27 // static 27 // static
28 OwnerSettingsServiceChromeOS* 28 OwnerSettingsService* OwnerSettingsServiceFactory::GetForProfile(
29 OwnerSettingsServiceChromeOSFactory::GetForProfile(Profile* profile) { 29 Profile* profile) {
30 return static_cast<OwnerSettingsServiceChromeOS*>( 30 return static_cast<OwnerSettingsService*>(
31 GetInstance()->GetServiceForBrowserContext(profile, true)); 31 GetInstance()->GetServiceForBrowserContext(profile, true));
32 } 32 }
33 33
34 // static 34 // static
35 OwnerSettingsServiceChromeOSFactory* 35 OwnerSettingsServiceFactory* OwnerSettingsServiceFactory::GetInstance() {
36 OwnerSettingsServiceChromeOSFactory::GetInstance() { 36 return Singleton<OwnerSettingsServiceFactory>::get();
37 return Singleton<OwnerSettingsServiceChromeOSFactory>::get();
38 } 37 }
39 38
40 scoped_refptr<ownership::OwnerKeyUtil> 39 scoped_refptr<ownership::OwnerKeyUtil>
41 OwnerSettingsServiceChromeOSFactory::GetOwnerKeyUtil() { 40 OwnerSettingsServiceFactory::GetOwnerKeyUtil() {
42 if (owner_key_util_.get()) 41 if (owner_key_util_.get())
43 return owner_key_util_; 42 return owner_key_util_;
44 base::FilePath public_key_path; 43 base::FilePath public_key_path;
45 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &public_key_path)) 44 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &public_key_path))
46 return NULL; 45 return NULL;
47 owner_key_util_ = new ownership::OwnerKeyUtilImpl(public_key_path); 46 owner_key_util_ = new ownership::OwnerKeyUtilImpl(public_key_path);
48 return owner_key_util_; 47 return owner_key_util_;
49 } 48 }
50 49
51 void OwnerSettingsServiceChromeOSFactory::SetOwnerKeyUtilForTesting( 50 void OwnerSettingsServiceFactory::SetOwnerKeyUtilForTesting(
52 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util) { 51 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util) {
53 owner_key_util_ = owner_key_util; 52 owner_key_util_ = owner_key_util;
54 } 53 }
55 54
56 // static 55 // static
57 KeyedService* OwnerSettingsServiceChromeOSFactory::BuildInstanceFor( 56 KeyedService* OwnerSettingsServiceFactory::BuildInstanceFor(
58 content::BrowserContext* browser_context) { 57 content::BrowserContext* browser_context) {
59 Profile* profile = static_cast<Profile*>(browser_context); 58 Profile* profile = static_cast<Profile*>(browser_context);
60 if (profile->IsGuestSession() || ProfileHelper::IsSigninProfile(profile)) 59 if (profile->IsGuestSession() || ProfileHelper::IsSigninProfile(profile))
61 return NULL; 60 return NULL;
62 return new OwnerSettingsServiceChromeOS(profile, 61 return new OwnerSettingsService(profile, GetInstance()->GetOwnerKeyUtil());
63 GetInstance()->GetOwnerKeyUtil());
64 } 62 }
65 63
66 bool OwnerSettingsServiceChromeOSFactory::ServiceIsCreatedWithBrowserContext() 64 bool OwnerSettingsServiceFactory::ServiceIsCreatedWithBrowserContext() const {
67 const {
68 return true; 65 return true;
69 } 66 }
70 67
71 KeyedService* OwnerSettingsServiceChromeOSFactory::BuildServiceInstanceFor( 68 KeyedService* OwnerSettingsServiceFactory::BuildServiceInstanceFor(
72 content::BrowserContext* context) const { 69 content::BrowserContext* context) const {
73 return BuildInstanceFor(context); 70 return BuildInstanceFor(context);
74 } 71 }
75 72
76 } // namespace chromeos 73 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698