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

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: 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 dict->RemoveWithoutPathExpansion(url.spec(), NULL); 332 dict->RemoveWithoutPathExpansion(url.spec(), NULL);
325 } else { 333 } else {
326 dict->SetBooleanWithoutPathExpansion(url.spec(), 334 dict->SetBooleanWithoutPathExpansion(url.spec(),
327 behavior == MANUAL_ALLOW); 335 behavior == MANUAL_ALLOW);
328 } 336 }
329 } 337 }
330 338
331 UpdateManualURLs(); 339 UpdateManualURLs();
332 } 340 }
333 341
334 void ManagedUserService::SetElevatedForTesting(bool is_elevated) { 342 void ManagedUserService::SetElevated(bool is_elevated) {
335 is_elevated_ = is_elevated; 343 is_elevated_ = is_elevated;
336 } 344 }
337 345
338 void ManagedUserService::Init() { 346 void ManagedUserService::Init() {
339 if (!ProfileIsManaged()) 347 if (!ProfileIsManaged())
340 return; 348 return;
341 349
342 extensions::ExtensionSystem* extension_system = 350 extensions::ExtensionSystem* extension_system =
343 extensions::ExtensionSystem::Get(profile_); 351 extensions::ExtensionSystem::Get(profile_);
344 extensions::ManagementPolicy* management_policy = 352 extensions::ManagementPolicy* management_policy =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); 391 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs);
384 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); 392 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>());
385 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { 393 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
386 bool allow = false; 394 bool allow = false;
387 bool result = it.value().GetAsBoolean(&allow); 395 bool result = it.value().GetAsBoolean(&allow);
388 DCHECK(result); 396 DCHECK(result);
389 (*url_map)[GURL(it.key())] = allow; 397 (*url_map)[GURL(it.key())] = allow;
390 } 398 }
391 url_filter_context_.SetManualURLs(url_map.Pass()); 399 url_filter_context_.SetManualURLs(url_map.Pass());
392 } 400 }
OLDNEW
« no previous file with comments | « chrome/browser/managed_mode/managed_user_service.h ('k') | chrome/browser/managed_mode/managed_user_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698