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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/ownership/owner_settings_service.h"
6
7 #include <string>
8
9 #include "base/bind.h"
10 #include "chrome/browser/chromeos/login/users/user.h"
11 #include "chrome/browser/chromeos/login/users/user_manager.h"
12 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.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 OwnerSettingsService::OwnerSettingsService(Profile* profile)
25 : profile_(profile), weak_factory_(this) {
26 // ReloadOwnerKey() is placed at the end of the MessageLoop because
27 // at the time of OwnerSettinsService construction ProfileIOData is
28 // not initialized.
29 BrowserThread::PostTask(BrowserThread::UI,
30 FROM_HERE,
31 base::Bind(&OwnerSettingsService::ReloadOwnerKey,
32 weak_factory_.GetWeakPtr()));
33 }
34
35 OwnerSettingsService::~OwnerSettingsService() {
36 }
37
38 void OwnerSettingsService::ReloadOwnerKey() {
39 if (!UserManager::IsInitialized())
40 return;
41 const User* user = UserManager::Get()->GetUserByProfile(profile_);
42 if (!user)
43 return;
44 std::string user_id = user->email();
45 if (user_id != OwnerSettingsServiceFactory::GetInstance()->GetUsername())
46 return;
47 content::ResourceContext* context = profile_->GetResourceContext();
48 if (!context) {
49 NOTREACHED();
50 return;
51 }
52 BrowserThread::PostTaskAndReplyWithResult(
53 BrowserThread::IO,
54 FROM_HERE,
55 base::Bind(&GetPublicNSSKeySlotForResourceContext, context),
56 base::Bind(&DeviceSettingsService::InitOwner,
57 base::Unretained(DeviceSettingsService::Get()),
58 user_id));
59 }
60
61 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698