Index: chrome/browser/chromeos/login/owner_settings_service.cc |
diff --git a/chrome/browser/chromeos/login/owner_settings_service.cc b/chrome/browser/chromeos/login/owner_settings_service.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9d9263a9e235497e879a87bbc610caa579b2b1c3 |
--- /dev/null |
+++ b/chrome/browser/chromeos/login/owner_settings_service.cc |
@@ -0,0 +1,63 @@ |
+// 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/login/owner_settings_service.h" |
+ |
+#include <string> |
+ |
+#include "base/bind.h" |
+#include "chrome/browser/chromeos/login/owner_settings_service_factory.h" |
+#include "chrome/browser/chromeos/login/user.h" |
+#include "chrome/browser/chromeos/login/user_manager.h" |
+#include "chrome/browser/chromeos/settings/device_settings_service.h" |
+#include "chrome/browser/net/nss_context.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/resource_context.h" |
+#include "crypto/scoped_nss_types.h" |
+ |
+using content::BrowserThread; |
+ |
+namespace chromeos { |
+ |
+OwnerSettingsBaseService::OwnerSettingsBaseService() {} |
+OwnerSettingsBaseService::~OwnerSettingsBaseService() {} |
+void OwnerSettingsBaseService::ReloadOwnerKey() {} |
+ |
+OwnerSettingsService::OwnerSettingsService(Profile* profile) |
+ : profile_(profile) { |
+ // ReloadOwnerKey() is called after delay because at the time of |
+ // 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.
|
+ BrowserThread::PostTask(BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&OwnerSettingsService::ReloadOwnerKey, |
+ base::Unretained(this))); |
+} |
+ |
+OwnerSettingsService::~OwnerSettingsService() { |
+} |
+ |
+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
|
+ if (!UserManager::IsInitialized()) |
+ return; |
+ const User* user = UserManager::Get()->GetUserByProfile(profile_); |
+ if (!user) |
+ return; |
+ std::string username = user->email(); |
+ content::ResourceContext* context = profile_->GetResourceContext(); |
+ if (context && user) { |
+ BrowserThread::PostTaskAndReplyWithResult( |
+ BrowserThread::IO, |
+ FROM_HERE, |
+ base::Bind(&GetPublicNSSKeySlotForResourceContext, context), |
+ base::Bind(&DeviceSettingsService::InitOwner, |
+ base::Unretained(DeviceSettingsService::Get()), |
+ username)); |
+ } else { |
+ crypto::ScopedPK11Slot slot; |
+ DeviceSettingsService::Get()->InitOwner(username, slot.Pass()); |
+ } |
+} |
+ |
+} // namespace chromeos |