Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/login/owner_settings_service.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "chrome/browser/chromeos/login/owner_settings_service_factory.h" | |
| 11 #include "chrome/browser/chromeos/login/user.h" | |
| 12 #include "chrome/browser/chromeos/login/user_manager.h" | |
| 13 #include "chrome/browser/chromeos/settings/device_settings_service.h" | |
| 14 #include "chrome/browser/net/nss_context.h" | |
| 15 #include "chrome/browser/profiles/profile.h" | |
| 16 #include "content/public/browser/browser_thread.h" | |
| 17 #include "content/public/browser/resource_context.h" | |
| 18 #include "crypto/scoped_nss_types.h" | |
| 19 | |
| 20 using content::BrowserThread; | |
| 21 | |
| 22 namespace chromeos { | |
| 23 | |
| 24 OwnerSettingsBaseService::OwnerSettingsBaseService() {} | |
| 25 OwnerSettingsBaseService::~OwnerSettingsBaseService() {} | |
| 26 void OwnerSettingsBaseService::ReloadOwnerKey() {} | |
| 27 | |
| 28 OwnerSettingsService::OwnerSettingsService(Profile* profile) | |
| 29 : profile_(profile) { | |
| 30 // ReloadOwnerKey() is called after delay because at the time of | |
| 31 // OnwerSettinsService construction ProfileIOData is not initialized. | |
|
Mattias Nissler (ping if slow)
2014/05/14 16:00:36
fix spelling.
ygorshenin1
2014/05/15 08:39:56
Done.
| |
| 32 BrowserThread::PostTask(BrowserThread::UI, | |
| 33 FROM_HERE, | |
| 34 base::Bind(&OwnerSettingsService::ReloadOwnerKey, | |
| 35 base::Unretained(this))); | |
| 36 } | |
| 37 | |
| 38 OwnerSettingsService::~OwnerSettingsService() { | |
| 39 } | |
| 40 | |
| 41 void OwnerSettingsService::ReloadOwnerKey() { | |
|
Mattias Nissler (ping if slow)
2014/05/14 16:00:36
I don't see how you make sure this is only getting
ygorshenin1
2014/05/15 08:39:56
I don't know how to do that without moving OwnerKe
| |
| 42 if (!UserManager::IsInitialized()) | |
| 43 return; | |
| 44 const User* user = UserManager::Get()->GetUserByProfile(profile_); | |
| 45 if (!user) | |
| 46 return; | |
| 47 std::string username = user->email(); | |
| 48 content::ResourceContext* context = profile_->GetResourceContext(); | |
| 49 if (context && user) { | |
| 50 BrowserThread::PostTaskAndReplyWithResult( | |
| 51 BrowserThread::IO, | |
| 52 FROM_HERE, | |
| 53 base::Bind(&GetPublicNSSKeySlotForResourceContext, context), | |
| 54 base::Bind(&DeviceSettingsService::InitOwner, | |
| 55 base::Unretained(DeviceSettingsService::Get()), | |
| 56 username)); | |
| 57 } else { | |
| 58 crypto::ScopedPK11Slot slot; | |
| 59 DeviceSettingsService::Get()->InitOwner(username, slot.Pass()); | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 } // namespace chromeos | |
| OLD | NEW |