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

Side by Side Diff: chrome/browser/managed_mode/managed_user_service.cc

Issue 12218118: Add a passphrase dialog for managed user accounts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments and rebase to ToT. Created 7 years, 10 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/managed_mode/managed_user_service.h" 5 #include "chrome/browser/managed_mode/managed_user_service.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 is_elevated_(false) { 90 is_elevated_(false) {
91 } 91 }
92 92
93 ManagedUserService::~ManagedUserService() { 93 ManagedUserService::~ManagedUserService() {
94 } 94 }
95 95
96 bool ManagedUserService::ProfileIsManaged() const { 96 bool ManagedUserService::ProfileIsManaged() const {
97 return profile_->GetPrefs()->GetBoolean(prefs::kProfileIsManaged); 97 return profile_->GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
98 } 98 }
99 99
100 bool ManagedUserService::IsElevated() const {
101 PrefService* pref_service = profile_->GetPrefs();
102 // If there is no passphrase set, the profile is considered to be elevated.
103 if (pref_service->GetString(prefs::kManagedModeLocalPassphrase).empty())
104 return true;
105 return is_elevated_;
106 }
107
100 // static 108 // static
101 void ManagedUserService::RegisterUserPrefs(PrefRegistrySyncable* registry) { 109 void ManagedUserService::RegisterUserPrefs(PrefRegistrySyncable* registry) {
102 registry->RegisterDictionaryPref(prefs::kManagedModeManualHosts, 110 registry->RegisterDictionaryPref(prefs::kManagedModeManualHosts,
103 PrefRegistrySyncable::UNSYNCABLE_PREF); 111 PrefRegistrySyncable::UNSYNCABLE_PREF);
104 registry->RegisterDictionaryPref(prefs::kManagedModeManualURLs, 112 registry->RegisterDictionaryPref(prefs::kManagedModeManualURLs,
105 PrefRegistrySyncable::UNSYNCABLE_PREF); 113 PrefRegistrySyncable::UNSYNCABLE_PREF);
106 registry->RegisterIntegerPref(prefs::kDefaultManagedModeFilteringBehavior, 114 registry->RegisterIntegerPref(prefs::kDefaultManagedModeFilteringBehavior,
107 ManagedModeURLFilter::BLOCK, 115 ManagedModeURLFilter::BLOCK,
108 PrefRegistrySyncable::UNSYNCABLE_PREF); 116 PrefRegistrySyncable::UNSYNCABLE_PREF);
109 registry->RegisterStringPref(prefs::kManagedModeLocalPassphrase, 117 registry->RegisterStringPref(prefs::kManagedModeLocalPassphrase,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 dict->RemoveWithoutPathExpansion(url.spec(), NULL); 314 dict->RemoveWithoutPathExpansion(url.spec(), NULL);
307 } else { 315 } else {
308 dict->SetBooleanWithoutPathExpansion(url.spec(), 316 dict->SetBooleanWithoutPathExpansion(url.spec(),
309 behavior == MANUAL_ALLOW); 317 behavior == MANUAL_ALLOW);
310 } 318 }
311 } 319 }
312 320
313 UpdateManualURLs(); 321 UpdateManualURLs();
314 } 322 }
315 323
316 void ManagedUserService::SetElevatedForTesting(bool is_elevated) { 324 void ManagedUserService::SetElevated(bool is_elevated) {
317 is_elevated_ = is_elevated; 325 is_elevated_ = is_elevated;
318 } 326 }
319 327
320 void ManagedUserService::Init() { 328 void ManagedUserService::Init() {
321 if (!ProfileIsManaged()) 329 if (!ProfileIsManaged())
322 return; 330 return;
323 331
324 extensions::ExtensionSystem* extension_system = 332 extensions::ExtensionSystem* extension_system =
325 extensions::ExtensionSystem::Get(profile_); 333 extensions::ExtensionSystem::Get(profile_);
326 extensions::ManagementPolicy* management_policy = 334 extensions::ManagementPolicy* management_policy =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); 373 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs);
366 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); 374 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>());
367 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { 375 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
368 bool allow = false; 376 bool allow = false;
369 bool result = it.value().GetAsBoolean(&allow); 377 bool result = it.value().GetAsBoolean(&allow);
370 DCHECK(result); 378 DCHECK(result);
371 (*url_map)[GURL(it.key())] = allow; 379 (*url_map)[GURL(it.key())] = allow;
372 } 380 }
373 url_filter_context_.SetManualURLs(url_map.Pass()); 381 url_filter_context_.SetManualURLs(url_map.Pass());
374 } 382 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698