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

Unified Diff: chrome/browser/chromeos/login/owner_settings_service.cc

Issue 270663002: Implemented profile-aware owner key loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes. Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698