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

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

Issue 12413028: Add elevation to the managed mode navigation observer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add deprecation comment. 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
« no previous file with comments | « chrome/browser/managed_mode/managed_user_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c27fdc7748ebafedf47e14e2b0026afba1afde7b..b484321079506ba867c9139637d95f4b26fa8f2c 100644
--- a/chrome/browser/managed_mode/managed_user_service.cc
+++ b/chrome/browser/managed_mode/managed_user_service.cc
@@ -9,6 +9,7 @@
#include "base/sequenced_task_runner.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
#include "chrome/browser/managed_mode/managed_mode_site_list.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
@@ -99,22 +100,42 @@ bool ManagedUserService::ProfileIsManaged() const {
return profile_->GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
}
+// Deprecated. Use IsElevatedForWebContents() instead.
Bernhard Bauer 2013/03/20 17:28:00 In the header please, that way people are more lik
Adrian Kuegel 2013/03/21 09:40:52 Done.
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();
+}
+
+bool ManagedUserService::IsPassphraseEmpty() const {
+ PrefService* pref_service = profile_->GetPrefs();
+ return pref_service->GetString(prefs::kManagedModeLocalPassphrase).empty();
+}
+
+// Deprecated. Use the CanSkipPassphraseDialog() method which requires a
+// WebContents parameter instead.
bool ManagedUserService::CanSkipPassphraseDialog() {
// If the profile is already elevated or there is no passphrase set, no
// authentication is needed.
- PrefService* pref_service = profile_->GetPrefs();
+ return IsElevated() || IsPassphraseEmpty();
+}
+
+bool ManagedUserService::CanSkipPassphraseDialog(
+ const content::WebContents* web_contents) const {
return IsElevated() ||
- pref_service->GetString(prefs::kManagedModeLocalPassphrase).empty();
+ IsElevatedForWebContents(web_contents) ||
+ IsPassphraseEmpty();
}
void ManagedUserService::RequestAuthorization(
content::WebContents* web_contents,
const PassphraseCheckedCallback& callback) {
- if (CanSkipPassphraseDialog()) {
+ if (CanSkipPassphraseDialog(web_contents)) {
callback.Run(true);
return;
}
@@ -373,6 +394,8 @@ void ManagedUserService::SetManualBehaviorForURLs(const std::vector<GURL>& urls,
UpdateManualURLs();
}
+// 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;
}
« no previous file with comments | « chrome/browser/managed_mode/managed_user_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698