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

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

Issue 12208068: Add a set passphrase dialog for managed user accounts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix year in new files. 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/sequenced_task_runner.h" 8 #include "base/sequenced_task_runner.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 Init(); 90 Init();
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(PrefServiceSyncable* prefs) { 109 void ManagedUserService::RegisterUserPrefs(PrefServiceSyncable* prefs) {
102 prefs->RegisterDictionaryPref(prefs::kManagedModeManualHosts, 110 prefs->RegisterDictionaryPref(prefs::kManagedModeManualHosts,
103 PrefServiceSyncable::UNSYNCABLE_PREF); 111 PrefServiceSyncable::UNSYNCABLE_PREF);
104 prefs->RegisterDictionaryPref(prefs::kManagedModeManualURLs, 112 prefs->RegisterDictionaryPref(prefs::kManagedModeManualURLs,
105 PrefServiceSyncable::UNSYNCABLE_PREF); 113 PrefServiceSyncable::UNSYNCABLE_PREF);
106 prefs->RegisterIntegerPref(prefs::kDefaultManagedModeFilteringBehavior, 114 prefs->RegisterIntegerPref(prefs::kDefaultManagedModeFilteringBehavior,
107 ManagedModeURLFilter::BLOCK, 115 ManagedModeURLFilter::BLOCK,
108 PrefServiceSyncable::UNSYNCABLE_PREF); 116 PrefServiceSyncable::UNSYNCABLE_PREF);
117 prefs->RegisterStringPref(prefs::kManagedModeLocalPassphrase,
118 "",
119 PrefServiceSyncable::UNSYNCABLE_PREF);
120 prefs->RegisterStringPref(prefs::kManagedModeLocalSalt,
121 "",
122 PrefServiceSyncable::UNSYNCABLE_PREF);
109 } 123 }
110 124
111 scoped_refptr<const ManagedModeURLFilter> 125 scoped_refptr<const ManagedModeURLFilter>
112 ManagedUserService::GetURLFilterForIOThread() { 126 ManagedUserService::GetURLFilterForIOThread() {
113 return url_filter_context_.io_url_filter(); 127 return url_filter_context_.io_url_filter();
114 } 128 }
115 129
116 ManagedModeURLFilter* ManagedUserService::GetURLFilterForUIThread() { 130 ManagedModeURLFilter* ManagedUserService::GetURLFilterForUIThread() {
117 return url_filter_context_.ui_url_filter(); 131 return url_filter_context_.ui_url_filter();
118 } 132 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 dict->RemoveWithoutPathExpansion(url.spec(), NULL); 314 dict->RemoveWithoutPathExpansion(url.spec(), NULL);
301 } else { 315 } else {
302 dict->SetBooleanWithoutPathExpansion(url.spec(), 316 dict->SetBooleanWithoutPathExpansion(url.spec(),
303 behavior == MANUAL_ALLOW); 317 behavior == MANUAL_ALLOW);
304 } 318 }
305 } 319 }
306 320
307 UpdateManualURLs(); 321 UpdateManualURLs();
308 } 322 }
309 323
310 void ManagedUserService::SetElevatedForTesting(bool is_elevated) { 324 void ManagedUserService::SetElevated(bool is_elevated) {
311 is_elevated_ = is_elevated; 325 is_elevated_ = is_elevated;
312 } 326 }
313 327
314 void ManagedUserService::Init() { 328 void ManagedUserService::Init() {
315 if (!ProfileIsManaged()) 329 if (!ProfileIsManaged())
316 return; 330 return;
317 331
318 extensions::ExtensionSystem* extension_system = 332 extensions::ExtensionSystem* extension_system =
319 extensions::ExtensionSystem::Get(profile_); 333 extensions::ExtensionSystem::Get(profile_);
320 extensions::ManagementPolicy* management_policy = 334 extensions::ManagementPolicy* management_policy =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); 373 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs);
360 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>());
361 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { 375 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
362 bool allow = false; 376 bool allow = false;
363 bool result = it.value().GetAsBoolean(&allow); 377 bool result = it.value().GetAsBoolean(&allow);
364 DCHECK(result); 378 DCHECK(result);
365 (*url_map)[GURL(it.key())] = allow; 379 (*url_map)[GURL(it.key())] = allow;
366 } 380 }
367 url_filter_context_.SetManualURLs(url_map.Pass()); 381 url_filter_context_.SetManualURLs(url_map.Pass());
368 } 382 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698