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

Side by Side 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 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/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 OwnerSettingsService::OwnerSettingsService(Profile* profile)
25 : profile_(profile), weak_factory_(this) {
26 // ReloadOwnerKey() is called after delay because at the time of
Nikita (slow) 2014/05/15 12:48:58 It seems that this is not actually a delay but jus
ygorshenin1 2014/05/16 12:09:37 Done.
27 // OwnerSettinsService construction ProfileIOData is not initialized.
28 BrowserThread::PostTask(BrowserThread::UI,
29 FROM_HERE,
30 base::Bind(&OwnerSettingsService::ReloadOwnerKey,
31 weak_factory_.GetWeakPtr()));
32 }
33
34 OwnerSettingsService::~OwnerSettingsService() {
35 }
36
37 void OwnerSettingsService::ReloadOwnerKey() {
38 if (!UserManager::IsInitialized())
39 return;
40 const User* user = UserManager::Get()->GetUserByProfile(profile_);
41 if (!user)
42 return;
43 std::string username = user->email();
Nikita (slow) 2014/05/15 12:48:58 nit: user_id
ygorshenin1 2014/05/16 12:09:37 Done.
44 if (username != OwnerSettingsServiceFactory::GetInstance()->GetUsername())
45 return;
46 content::ResourceContext* context = profile_->GetResourceContext();
47 if (context) {
48 BrowserThread::PostTaskAndReplyWithResult(
49 BrowserThread::IO,
50 FROM_HERE,
51 base::Bind(&GetPublicNSSKeySlotForResourceContext, context),
52 base::Bind(&DeviceSettingsService::InitOwner,
53 base::Unretained(DeviceSettingsService::Get()),
54 username));
55 } else {
56 crypto::ScopedPK11Slot slot;
Nikita (slow) 2014/05/15 12:48:58 nit: Can you please add comment describing the sit
ygorshenin1 2014/05/16 12:09:37 There shouldn't be such situations, so I've added
57 DeviceSettingsService::Get()->InitOwner(username, slot.Pass());
58 }
59 }
60
61 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698