OLD | NEW |
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return observer ? observer->is_elevated() : false; | 122 return observer ? observer->is_elevated() : false; |
123 } | 123 } |
124 | 124 |
125 bool ManagedUserService::IsPassphraseEmpty() const { | 125 bool ManagedUserService::IsPassphraseEmpty() const { |
126 PrefService* pref_service = profile_->GetPrefs(); | 126 PrefService* pref_service = profile_->GetPrefs(); |
127 return pref_service->GetString(prefs::kManagedModeLocalPassphrase).empty(); | 127 return pref_service->GetString(prefs::kManagedModeLocalPassphrase).empty(); |
128 } | 128 } |
129 | 129 |
130 bool ManagedUserService::CanSkipPassphraseDialog( | 130 bool ManagedUserService::CanSkipPassphraseDialog( |
131 const content::WebContents* web_contents) const { | 131 const content::WebContents* web_contents) const { |
| 132 #if defined(OS_CHROMEOS) |
| 133 NOTREACHED(); |
| 134 #endif |
132 return IsElevatedForWebContents(web_contents) || | 135 return IsElevatedForWebContents(web_contents) || |
133 IsPassphraseEmpty(); | 136 IsPassphraseEmpty(); |
134 } | 137 } |
135 | 138 |
136 void ManagedUserService::RequestAuthorization( | 139 void ManagedUserService::RequestAuthorization( |
137 content::WebContents* web_contents, | 140 content::WebContents* web_contents, |
138 const PassphraseCheckedCallback& callback) { | 141 const PassphraseCheckedCallback& callback) { |
| 142 #if defined(OS_CHROMEOS) |
| 143 NOTREACHED(); |
| 144 #endif |
| 145 |
139 if (CanSkipPassphraseDialog(web_contents)) { | 146 if (CanSkipPassphraseDialog(web_contents)) { |
140 callback.Run(true); | 147 callback.Run(true); |
141 return; | 148 return; |
142 } | 149 } |
143 | 150 |
144 // Is deleted automatically when the dialog is closed. | 151 // Is deleted automatically when the dialog is closed. |
145 new ManagedUserPassphraseDialog(web_contents, callback); | 152 new ManagedUserPassphraseDialog(web_contents, callback); |
146 } | 153 } |
147 | 154 |
148 // static | 155 // static |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); | 413 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); |
407 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 414 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
408 GURL url(it.key()); | 415 GURL url(it.key()); |
409 if (url.host() == host) | 416 if (url.host() == host) |
410 urls->push_back(url); | 417 urls->push_back(url); |
411 } | 418 } |
412 } | 419 } |
413 | 420 |
414 void ManagedUserService::AddElevationForExtension( | 421 void ManagedUserService::AddElevationForExtension( |
415 const std::string& extension_id) { | 422 const std::string& extension_id) { |
| 423 #if defined(OS_CHROMEOS) |
| 424 NOTREACHED(); |
| 425 #else |
416 elevated_for_extensions_.insert(extension_id); | 426 elevated_for_extensions_.insert(extension_id); |
| 427 #endif |
417 } | 428 } |
418 | 429 |
419 void ManagedUserService::RemoveElevationForExtension( | 430 void ManagedUserService::RemoveElevationForExtension( |
420 const std::string& extension_id) { | 431 const std::string& extension_id) { |
| 432 #if defined(OS_CHROMEOS) |
| 433 NOTREACHED(); |
| 434 #else |
421 elevated_for_extensions_.erase(extension_id); | 435 elevated_for_extensions_.erase(extension_id); |
| 436 #endif |
422 } | 437 } |
423 | 438 |
424 void ManagedUserService::Init() { | 439 void ManagedUserService::Init() { |
425 if (!ProfileIsManaged()) | 440 if (!ProfileIsManaged()) |
426 return; | 441 return; |
427 | 442 |
428 extensions::ExtensionSystem* extension_system = | 443 extensions::ExtensionSystem* extension_system = |
429 extensions::ExtensionSystem::Get(profile_); | 444 extensions::ExtensionSystem::Get(profile_); |
430 extensions::ManagementPolicy* management_policy = | 445 extensions::ManagementPolicy* management_policy = |
431 extension_system->management_policy(); | 446 extension_system->management_policy(); |
432 if (management_policy) | 447 if (management_policy) |
433 extension_system->management_policy()->RegisterProvider(this); | 448 extension_system->management_policy()->RegisterProvider(this); |
434 | 449 |
435 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 450 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
436 content::Source<Profile>(profile_)); | 451 content::Source<Profile>(profile_)); |
437 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 452 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
438 content::Source<Profile>(profile_)); | 453 content::Source<Profile>(profile_)); |
| 454 #if !defined(OS_CHROMEOS) |
439 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 455 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
440 content::Source<Profile>(profile_)); | 456 content::Source<Profile>(profile_)); |
441 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 457 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
442 content::Source<Profile>(profile_)); | 458 content::Source<Profile>(profile_)); |
| 459 #endif |
| 460 |
443 pref_change_registrar_.Init(profile_->GetPrefs()); | 461 pref_change_registrar_.Init(profile_->GetPrefs()); |
444 pref_change_registrar_.Add( | 462 pref_change_registrar_.Add( |
445 prefs::kDefaultManagedModeFilteringBehavior, | 463 prefs::kDefaultManagedModeFilteringBehavior, |
446 base::Bind( | 464 base::Bind( |
447 &ManagedUserService::OnDefaultFilteringBehaviorChanged, | 465 &ManagedUserService::OnDefaultFilteringBehaviorChanged, |
448 base::Unretained(this))); | 466 base::Unretained(this))); |
449 | 467 |
450 // TODO(bauerb): Setting the default value here does not currently trigger | 468 // TODO(bauerb): Setting the default value here does not currently trigger |
451 // the proper notification. Once that is fixed use SetDefaultPrefValue | 469 // the proper notification. Once that is fixed use SetDefaultPrefValue |
452 // instead. | 470 // instead. |
(...skipping 26 matching lines...) Expand all Loading... |
479 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); | 497 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); |
480 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); | 498 scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>()); |
481 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 499 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
482 bool allow = false; | 500 bool allow = false; |
483 bool result = it.value().GetAsBoolean(&allow); | 501 bool result = it.value().GetAsBoolean(&allow); |
484 DCHECK(result); | 502 DCHECK(result); |
485 (*url_map)[GURL(it.key())] = allow; | 503 (*url_map)[GURL(it.key())] = allow; |
486 } | 504 } |
487 url_filter_context_.SetManualURLs(url_map.Pass()); | 505 url_filter_context_.SetManualURLs(url_map.Pass()); |
488 } | 506 } |
OLD | NEW |