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

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

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

Powered by Google App Engine
This is Rietveld 408576698