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

Unified Diff: chrome/browser/managed_mode/managed_user_service.cc

Issue 13119011: Enable WebContents elevation for managed users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor duplicate code into GetScopedElevation function. Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/managed_mode/managed_user_service.cc
diff --git a/chrome/browser/managed_mode/managed_user_service.cc b/chrome/browser/managed_mode/managed_user_service.cc
index 765c324ab01155080625b07fd4c607548c888cb2..0cc29f541eb284b359016833f385d2b6c0e0dcca 100644
--- a/chrome/browser/managed_mode/managed_user_service.cc
+++ b/chrome/browser/managed_mode/managed_user_service.cc
@@ -104,9 +104,7 @@ void ManagedUserService::URLFilterContext::SetManualURLs(
io_url_filter_, base::Owned(url_map.release())));
}
-ManagedUserService::ManagedUserService(Profile* profile)
- : profile_(profile),
- is_elevated_(false) {
+ManagedUserService::ManagedUserService(Profile* profile) : profile_(profile) {
}
ManagedUserService::~ManagedUserService() {
@@ -116,15 +114,11 @@ bool ManagedUserService::ProfileIsManaged() const {
return profile_->GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
}
-bool ManagedUserService::IsElevated() const {
- return is_elevated_;
-}
-
bool ManagedUserService::IsElevatedForWebContents(
const content::WebContents* web_contents) const {
const ManagedModeNavigationObserver* observer =
ManagedModeNavigationObserver::FromWebContents(web_contents);
- return observer->is_elevated();
+ return observer ? observer->is_elevated() : false;
}
bool ManagedUserService::IsPassphraseEmpty() const {
@@ -132,17 +126,10 @@ bool ManagedUserService::IsPassphraseEmpty() const {
return pref_service->GetString(prefs::kManagedModeLocalPassphrase).empty();
}
-bool ManagedUserService::CanSkipPassphraseDialog() {
- // If the profile is already elevated or there is no passphrase set, no
- // authentication is needed.
- return IsElevated() || IsPassphraseEmpty();
-}
-
bool ManagedUserService::CanSkipPassphraseDialog(
const content::WebContents* web_contents) const {
- return IsElevated() ||
- IsElevatedForWebContents(web_contents) ||
- IsPassphraseEmpty();
+ return IsElevatedForWebContents(web_contents) ||
+ IsPassphraseEmpty();
}
void ManagedUserService::RequestAuthorization(
@@ -157,14 +144,6 @@ void ManagedUserService::RequestAuthorization(
new ManagedUserPassphraseDialog(web_contents, callback);
}
-void ManagedUserService::RequestAuthorizationUsingActiveWebContents(
- Browser* browser,
- const PassphraseCheckedCallback& callback) {
- RequestAuthorization(
- browser->tab_strip_model()->GetActiveWebContents(),
- callback);
-}
-
// static
void ManagedUserService::RegisterUserPrefs(PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(prefs::kManagedModeManualHosts,
@@ -290,6 +269,15 @@ void ManagedUserService::Observe(int type,
}
break;
}
+ case chrome::NOTIFICATION_EXTENSION_INSTALLED:
+ case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
+ // When an extension was installed or uninstalled, remove the temporary
+ // elevation.
+ const extensions::Extension* extension =
+ content::Details<extensions::Extension>(details).ptr();
+ RemoveElevationForExtension(extension->id());
+ break;
+ }
default:
NOTREACHED();
}
@@ -301,9 +289,6 @@ bool ManagedUserService::ExtensionManagementPolicyImpl(
if (!ProfileIsManaged())
return true;
- if (is_elevated_)
- return true;
-
if (elevated_for_extensions_.count(extension_id))
return true;
@@ -424,12 +409,6 @@ void ManagedUserService::GetManualExceptionsForHost(const std::string& host,
}
}
-// TODO(akuegel): Rename to SetElevatedForTesting when all callers are changed
-// to set elevation on the ManagedModeNavigationObserver.
-void ManagedUserService::SetElevated(bool is_elevated) {
- is_elevated_ = is_elevated;
-}
-
void ManagedUserService::AddElevationForExtension(
const std::string& extension_id) {
elevated_for_extensions_.insert(extension_id);
@@ -455,6 +434,10 @@ void ManagedUserService::Init() {
content::Source<Profile>(profile_));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<Profile>(profile_));
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
+ content::Source<Profile>(profile_));
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
+ content::Source<Profile>(profile_));
pref_change_registrar_.Init(profile_->GetPrefs());
pref_change_registrar_.Add(
prefs::kDefaultManagedModeFilteringBehavior,

Powered by Google App Engine
This is Rietveld 408576698