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

Unified Diff: chrome/browser/chromeos/ownership/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, rebase. 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/ownership/owner_settings_service.cc
diff --git a/chrome/browser/chromeos/ownership/owner_settings_service.cc b/chrome/browser/chromeos/ownership/owner_settings_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6eb70115a1434ca53a294532003c0fec3a117dfa
--- /dev/null
+++ b/chrome/browser/chromeos/ownership/owner_settings_service.cc
@@ -0,0 +1,61 @@
+// 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/ownership/owner_settings_service.h"
+
+#include <string>
+
+#include "base/bind.h"
+#include "chrome/browser/chromeos/login/users/user.h"
+#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/ownership/owner_settings_service_factory.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 {
+
+OwnerSettingsService::OwnerSettingsService(Profile* profile)
+ : profile_(profile), weak_factory_(this) {
+ // ReloadOwnerKey() is placed at the end of the MessageLoop because
+ // at the time of OwnerSettinsService construction ProfileIOData is
+ // not initialized.
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&OwnerSettingsService::ReloadOwnerKey,
+ weak_factory_.GetWeakPtr()));
+}
+
+OwnerSettingsService::~OwnerSettingsService() {
+}
+
+void OwnerSettingsService::ReloadOwnerKey() {
+ if (!UserManager::IsInitialized())
+ return;
+ const User* user = UserManager::Get()->GetUserByProfile(profile_);
+ if (!user)
+ return;
+ std::string user_id = user->email();
+ if (user_id != OwnerSettingsServiceFactory::GetInstance()->GetUsername())
+ return;
+ content::ResourceContext* context = profile_->GetResourceContext();
+ if (!context) {
+ NOTREACHED();
+ return;
+ }
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&GetPublicNSSKeySlotForResourceContext, context),
+ base::Bind(&DeviceSettingsService::InitOwner,
+ base::Unretained(DeviceSettingsService::Get()),
+ user_id));
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698