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

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

Issue 640063008: Revert of Implemented OwnerSettingsService::Set() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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_chromeos_fact ory.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_chromeos.h"
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" 9 #include "chrome/browser/chromeos/profiles/profile_helper.h"
10 #include "chrome/browser/chromeos/settings/device_settings_service.h"
11 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
12 #include "chromeos/chromeos_paths.h" 11 #include "chromeos/chromeos_paths.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h" 12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 #include "components/ownership/owner_key_util.h" 13 #include "components/ownership/owner_key_util.h"
15 #include "components/ownership/owner_key_util_impl.h" 14 #include "components/ownership/owner_key_util_impl.h"
16 15
17 namespace chromeos { 16 namespace chromeos {
18 17
19 namespace {
20
21 DeviceSettingsService* g_device_settings_service_for_testing_ = nullptr;
22
23 DeviceSettingsService* GetDeviceSettingsService() {
24 if (g_device_settings_service_for_testing_)
25 return g_device_settings_service_for_testing_;
26 return DeviceSettingsService::IsInitialized() ? DeviceSettingsService::Get()
27 : nullptr;
28 }
29
30 } // namespace
31
32 OwnerSettingsServiceChromeOSFactory::OwnerSettingsServiceChromeOSFactory() 18 OwnerSettingsServiceChromeOSFactory::OwnerSettingsServiceChromeOSFactory()
33 : BrowserContextKeyedServiceFactory( 19 : BrowserContextKeyedServiceFactory(
34 "OwnerSettingsService", 20 "OwnerSettingsService",
35 BrowserContextDependencyManager::GetInstance()) { 21 BrowserContextDependencyManager::GetInstance()) {
36 } 22 }
37 23
38 OwnerSettingsServiceChromeOSFactory::~OwnerSettingsServiceChromeOSFactory() { 24 OwnerSettingsServiceChromeOSFactory::~OwnerSettingsServiceChromeOSFactory() {
39 } 25 }
40 26
41 // static 27 // static
42 OwnerSettingsServiceChromeOS* 28 OwnerSettingsServiceChromeOS*
43 OwnerSettingsServiceChromeOSFactory::GetForProfile(Profile* profile) { 29 OwnerSettingsServiceChromeOSFactory::GetForProfile(Profile* profile) {
44 return static_cast<OwnerSettingsServiceChromeOS*>( 30 return static_cast<OwnerSettingsServiceChromeOS*>(
45 GetInstance()->GetServiceForBrowserContext(profile, true)); 31 GetInstance()->GetServiceForBrowserContext(profile, true));
46 } 32 }
47 33
48 // static 34 // static
49 OwnerSettingsServiceChromeOSFactory* 35 OwnerSettingsServiceChromeOSFactory*
50 OwnerSettingsServiceChromeOSFactory::GetInstance() { 36 OwnerSettingsServiceChromeOSFactory::GetInstance() {
51 return Singleton<OwnerSettingsServiceChromeOSFactory>::get(); 37 return Singleton<OwnerSettingsServiceChromeOSFactory>::get();
52 } 38 }
53 39
54 // static
55 void OwnerSettingsServiceChromeOSFactory::SetDeviceSettingsServiceForTesting(
56 DeviceSettingsService* device_settings_service) {
57 g_device_settings_service_for_testing_ = device_settings_service;
58 }
59
60 scoped_refptr<ownership::OwnerKeyUtil> 40 scoped_refptr<ownership::OwnerKeyUtil>
61 OwnerSettingsServiceChromeOSFactory::GetOwnerKeyUtil() { 41 OwnerSettingsServiceChromeOSFactory::GetOwnerKeyUtil() {
62 if (owner_key_util_.get()) 42 if (owner_key_util_.get())
63 return owner_key_util_; 43 return owner_key_util_;
64 base::FilePath public_key_path; 44 base::FilePath public_key_path;
65 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &public_key_path)) 45 if (!PathService::Get(chromeos::FILE_OWNER_KEY, &public_key_path))
66 return NULL; 46 return NULL;
67 owner_key_util_ = new ownership::OwnerKeyUtilImpl(public_key_path); 47 owner_key_util_ = new ownership::OwnerKeyUtilImpl(public_key_path);
68 return owner_key_util_; 48 return owner_key_util_;
69 } 49 }
70 50
71 void OwnerSettingsServiceChromeOSFactory::SetOwnerKeyUtilForTesting( 51 void OwnerSettingsServiceChromeOSFactory::SetOwnerKeyUtilForTesting(
72 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util) { 52 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util) {
73 owner_key_util_ = owner_key_util; 53 owner_key_util_ = owner_key_util;
74 } 54 }
75 55
76 // static 56 // static
77 KeyedService* OwnerSettingsServiceChromeOSFactory::BuildInstanceFor( 57 KeyedService* OwnerSettingsServiceChromeOSFactory::BuildInstanceFor(
78 content::BrowserContext* browser_context) { 58 content::BrowserContext* browser_context) {
79 Profile* profile = static_cast<Profile*>(browser_context); 59 Profile* profile = static_cast<Profile*>(browser_context);
80 if (profile->IsGuestSession() || ProfileHelper::IsSigninProfile(profile)) 60 if (profile->IsGuestSession() || ProfileHelper::IsSigninProfile(profile))
81 return NULL; 61 return NULL;
82 return new OwnerSettingsServiceChromeOS( 62 return new OwnerSettingsServiceChromeOS(profile,
83 GetDeviceSettingsService(), 63 GetInstance()->GetOwnerKeyUtil());
84 profile,
85 GetInstance()->GetOwnerKeyUtil());
86 } 64 }
87 65
88 bool OwnerSettingsServiceChromeOSFactory::ServiceIsCreatedWithBrowserContext() 66 bool OwnerSettingsServiceChromeOSFactory::ServiceIsCreatedWithBrowserContext()
89 const { 67 const {
90 return true; 68 return true;
91 } 69 }
92 70
93 KeyedService* OwnerSettingsServiceChromeOSFactory::BuildServiceInstanceFor( 71 KeyedService* OwnerSettingsServiceChromeOSFactory::BuildServiceInstanceFor(
94 content::BrowserContext* context) const { 72 content::BrowserContext* context) const {
95 return BuildInstanceFor(context); 73 return BuildInstanceFor(context);
96 } 74 }
97 75
98 } // namespace chromeos 76 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698