summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 16:50:58 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 16:50:58 +0000
commite000daf98b303e597bfd74ac961ec8c976519d7a (patch)
treeb83acbb6f2b33e2fae8c5a970bed73ceeffc3a52
parente5dd62f9ceaf7bccb3103546e4d123169c1fa55c (diff)
downloadchromium_src-e000daf98b303e597bfd74ac961ec8c976519d7a.zip
chromium_src-e000daf98b303e597bfd74ac961ec8c976519d7a.tar.gz
chromium_src-e000daf98b303e597bfd74ac961ec8c976519d7a.tar.bz2
Remove ManagedUserService::ProfileIsManaged() in favor of a method on Profile().
TBR=jochen@chromium.org BUG=244891 Review URL: https://chromiumcodereview.appspot.com/18526004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214760 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/external_provider_impl.cc7
-rw-r--r--chrome/browser/invalidation/ticl_invalidation_service.cc3
-rw-r--r--chrome/browser/managed_mode/managed_user_service.cc9
-rw-r--r--chrome/browser/managed_mode/managed_user_service.h12
-rw-r--r--chrome/browser/policy/cloud/user_policy_signin_service.cc8
-rw-r--r--chrome/browser/profiles/avatar_menu_model.cc19
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.cc4
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.h1
-rw-r--r--chrome/browser/profiles/profile.h3
-rw-r--r--chrome/browser/profiles/profile_impl.cc4
-rw-r--r--chrome/browser/profiles/profile_impl.h1
-rw-r--r--chrome/browser/profiles/profile_metrics.cc3
-rw-r--r--chrome/browser/sync/profile_sync_components_factory_impl.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service.cc12
-rw-r--r--chrome/browser/themes/theme_service.cc8
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_utils.cc8
-rw-r--r--chrome/browser/ui/browser_tab_contents.cc6
-rw-r--r--chrome/browser/ui/cocoa/browser/avatar_button_controller.mm3
-rw-r--r--chrome/browser/ui/gtk/browser_titlebar.cc3
-rw-r--r--chrome/browser/ui/gtk/gtk_theme_service.cc1
-rw-r--r--chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc7
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view.cc6
-rw-r--r--chrome/browser/ui/webui/extensions/extension_settings_handler.cc7
-rw-r--r--chrome/browser/ui/webui/history_ui.cc14
-rw-r--r--chrome/browser/ui/webui/ntp/ntp_resource_cache.cc10
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc23
-rw-r--r--chrome/browser/ui/webui/options/manage_profile_handler.cc7
-rw-r--r--chrome/common/chrome_paths.h2
-rw-r--r--chrome/test/base/testing_profile.cc5
-rw-r--r--chrome/test/base/testing_profile.h1
30 files changed, 73 insertions, 126 deletions
diff --git a/chrome/browser/extensions/external_provider_impl.cc b/chrome/browser/extensions/external_provider_impl.cc
index 677f447..6ca0341 100644
--- a/chrome/browser/extensions/external_provider_impl.cc
+++ b/chrome/browser/extensions/external_provider_impl.cc
@@ -385,15 +385,10 @@ void ExternalProviderImpl::CreateExternalProviders(
Extension::WAS_INSTALLED_BY_DEFAULT;
#endif
- bool is_managed_profile = false;
+ bool is_managed_profile = profile->IsManaged();
int external_apps_path_id = chrome::DIR_EXTERNAL_EXTENSIONS;
-#if defined(ENABLE_MANAGED_USERS)
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile);
- is_managed_profile = managed_user_service->ProfileIsManaged();
if (is_managed_profile)
external_apps_path_id = chrome::DIR_MANAGED_USERS_DEFAULT_APPS;
-#endif
#if defined(OS_CHROMEOS)
typedef chromeos::ExternalPrefCacheLoader PrefLoader;
diff --git a/chrome/browser/invalidation/ticl_invalidation_service.cc b/chrome/browser/invalidation/ticl_invalidation_service.cc
index ee2da37..0c2cae7 100644
--- a/chrome/browser/invalidation/ticl_invalidation_service.cc
+++ b/chrome/browser/invalidation/ticl_invalidation_service.cc
@@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/invalidation/invalidation_service_util.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/profile_oauth2_token_service.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
@@ -276,7 +275,7 @@ void TiclInvalidationService::Shutdown() {
}
bool TiclInvalidationService::IsReadyToStart() {
- if (ManagedUserService::ProfileIsManaged(profile_)) {
+ if (profile_->IsManaged()) {
DVLOG(2) << "Not starting TiclInvalidationService: User is managed.";
return false;
}
diff --git a/chrome/browser/managed_mode/managed_user_service.cc b/chrome/browser/managed_mode/managed_user_service.cc
index e48e4b7..f6e0cd4 100644
--- a/chrome/browser/managed_mode/managed_user_service.cc
+++ b/chrome/browser/managed_mode/managed_user_service.cc
@@ -172,12 +172,7 @@ void ManagedUserService::Shutdown() {
}
bool ManagedUserService::ProfileIsManaged() const {
- return ProfileIsManaged(profile_);
-}
-
-// static
-bool ManagedUserService::ProfileIsManaged(Profile* profile) {
- return profile->GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
+ return profile_->IsManaged();
}
// static
@@ -563,6 +558,8 @@ void ManagedUserService::Init() {
void ManagedUserService::RegisterAndInitSync(
Profile* custodian_profile,
const ProfileManager::CreateCallback& callback) {
+ DCHECK(ProfileIsManaged());
+ DCHECK(!custodian_profile->IsManaged());
// Register the managed user with the custodian's account.
ManagedUserRegistrationService* registration_service =
diff --git a/chrome/browser/managed_mode/managed_user_service.h b/chrome/browser/managed_mode/managed_user_service.h
index 70de621..7095b17 100644
--- a/chrome/browser/managed_mode/managed_user_service.h
+++ b/chrome/browser/managed_mode/managed_user_service.h
@@ -57,12 +57,6 @@ class ManagedUserService : public BrowserContextKeyedService,
// ProfileKeyedService override:
virtual void Shutdown() OVERRIDE;
- bool ProfileIsManaged() const;
-
- // Checks whether the given profile is managed without constructing a
- // ManagedUserService (which could lead to cyclic dependencies).
- static bool ProfileIsManaged(Profile* profile);
-
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
// Returns true if managed users are enabled by either Finch or the command
@@ -162,6 +156,10 @@ class ManagedUserService : public BrowserContextKeyedService,
private:
friend class ManagedUserServiceExtensionTest;
friend class ManagedUserServiceFactory;
+ FRIEND_TEST_ALL_PREFIXES(ManagedUserServiceTest,
+ ExtensionManagementPolicyProviderUnmanaged);
+ FRIEND_TEST_ALL_PREFIXES(ManagedUserServiceTest,
+ ExtensionManagementPolicyProviderManaged);
// A bridge from ManagedMode (which lives on the UI thread) to the
// ManagedModeURLFilters, one of which lives on the IO thread. This class
@@ -206,6 +204,8 @@ class ManagedUserService : public BrowserContextKeyedService,
void SetupSync();
+ bool ProfileIsManaged() const;
+
// Internal implementation for ExtensionManagementPolicy::Delegate methods.
// If |error| is not NULL, it will be filled with an error message if the
// requested extension action (install, modify status, etc.) is not permitted.
diff --git a/chrome/browser/policy/cloud/user_policy_signin_service.cc b/chrome/browser/policy/cloud/user_policy_signin_service.cc
index ba593a9..eafb1d3 100644
--- a/chrome/browser/policy/cloud/user_policy_signin_service.cc
+++ b/chrome/browser/policy/cloud/user_policy_signin_service.cc
@@ -23,10 +23,6 @@
#include "content/public/browser/notification_source.h"
#include "google_apis/gaia/gaia_constants.h"
-#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#endif
-
namespace policy {
UserPolicySigninService::UserPolicySigninService(
@@ -102,12 +98,10 @@ void UserPolicySigninService::Observe(
const content::NotificationSource& source,
const content::NotificationDetails& details) {
-#if defined(ENABLE_MANAGED_USERS)
- if (ManagedUserService::ProfileIsManaged(profile())) {
+ if (profile()->IsManaged()) {
registrar()->RemoveAll();
return;
}
-#endif
// If using a TestingProfile with no SigninManager or UserCloudPolicyManager,
// skip initialization.
diff --git a/chrome/browser/profiles/avatar_menu_model.cc b/chrome/browser/profiles/avatar_menu_model.cc
index f6d769d1..88db32d 100644
--- a/chrome/browser/profiles/avatar_menu_model.cc
+++ b/chrome/browser/profiles/avatar_menu_model.cc
@@ -239,27 +239,20 @@ const AvatarMenuModel::Item& AvatarMenuModel::GetItemAt(size_t index) {
}
bool AvatarMenuModel::ShouldShowAddNewProfileLink() const {
-#if defined(ENABLE_MANAGED_USERS)
// |browser_| can be NULL in unit_tests.
- return !browser_ ||
- !ManagedUserService::ProfileIsManaged(browser_->profile());
-#endif
- return true;
+ return !browser_ || !browser_->profile()->IsManaged();
}
base::string16 AvatarMenuModel::GetManagedUserInformation() const {
-#if defined(ENABLE_MANAGED_USERS)
// |browser_| can be NULL in unit_tests.
- if (!browser_)
- return base::string16();
-
- ManagedUserService* service = ManagedUserServiceFactory::GetForProfile(
- browser_->profile());
- if (service->ProfileIsManaged()) {
+ if (browser_ && browser_->profile()->IsManaged()) {
+#if defined(ENABLE_MANAGED_USERS)
+ ManagedUserService* service = ManagedUserServiceFactory::GetForProfile(
+ browser_->profile());
base::string16 custodian = UTF8ToUTF16(service->GetCustodianName());
return l10n_util::GetStringFUTF16(IDS_MANAGED_USER_INFO, custodian);
- }
#endif
+ }
return base::string16();
}
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index a14d3ab..5ead5e3 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -230,6 +230,10 @@ ExtensionSpecialStoragePolicy*
return GetOriginalProfile()->GetExtensionSpecialStoragePolicy();
}
+bool OffTheRecordProfileImpl::IsManaged() {
+ return GetOriginalProfile()->IsManaged();
+}
+
PrefService* OffTheRecordProfileImpl::GetPrefs() {
return prefs_;
}
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h
index c43ad0a..85fced7 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.h
+++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -40,6 +40,7 @@ class OffTheRecordProfileImpl : public Profile {
virtual void DestroyOffTheRecordProfile() OVERRIDE;
virtual bool HasOffTheRecordProfile() OVERRIDE;
virtual Profile* GetOriginalProfile() OVERRIDE;
+ virtual bool IsManaged() OVERRIDE;
virtual ExtensionService* GetExtensionService() OVERRIDE;
virtual ExtensionSpecialStoragePolicy*
GetExtensionSpecialStoragePolicy() OVERRIDE;
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index 1e5270b..3af9eeb 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -198,6 +198,9 @@ class Profile : public content::BrowserContext {
// profile is not incognito.
virtual Profile* GetOriginalProfile() = 0;
+ // Returns whether the profile is managed (see ManagedUserService).
+ virtual bool IsManaged() = 0;
+
// Returns a pointer to the TopSites (thumbnail manager) instance
// for this profile.
virtual history::TopSites* GetTopSites() = 0;
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index b5b0b8d..9092e56 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -699,6 +699,10 @@ Profile* ProfileImpl::GetOriginalProfile() {
return this;
}
+bool ProfileImpl::IsManaged() {
+ return GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
+}
+
ExtensionService* ProfileImpl::GetExtensionService() {
return extensions::ExtensionSystem::Get(this)->extension_service();
}
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 4fb1a51..544091e 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -94,6 +94,7 @@ class ProfileImpl : public Profile {
virtual void DestroyOffTheRecordProfile() OVERRIDE;
virtual bool HasOffTheRecordProfile() OVERRIDE;
virtual Profile* GetOriginalProfile() OVERRIDE;
+ virtual bool IsManaged() OVERRIDE;
virtual history::TopSites* GetTopSites() OVERRIDE;
virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE;
virtual ExtensionService* GetExtensionService() OVERRIDE;
diff --git a/chrome/browser/profiles/profile_metrics.cc b/chrome/browser/profiles/profile_metrics.cc
index 6087a95..5e743ad 100644
--- a/chrome/browser/profiles/profile_metrics.cc
+++ b/chrome/browser/profiles/profile_metrics.cc
@@ -8,7 +8,6 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -232,7 +231,7 @@ void ProfileMetrics::LogProfileLaunch(Profile* profile) {
GetProfileType(profile_path),
NUM_PROFILE_TYPE_METRICS);
- if (ManagedUserService::ProfileIsManaged(profile)) {
+ if (profile->IsManaged()) {
content::RecordAction(
content::UserMetricsAction("ManagedMode_NewManagedUserWindow"));
}
diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc
index 0ce7f9f..e201636 100644
--- a/chrome/browser/sync/profile_sync_components_factory_impl.cc
+++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc
@@ -280,7 +280,7 @@ void ProfileSyncComponentsFactoryImpl::RegisterDesktopDataTypes(
#if defined(ENABLE_MANAGED_USERS)
if (ManagedUserService::AreManagedUsersEnabled()) {
- if (ManagedUserService::ProfileIsManaged(profile_)) {
+ if (profile_->IsManaged()) {
pss->RegisterDataTypeController(
new UIDataTypeController(
syncer::MANAGED_USER_SETTINGS, this, profile_, pss));
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 869d16c..c567adf 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -1845,11 +1845,7 @@ void ProfileSyncService::RequestAccessToken() {
return;
request_access_token_retry_timer_.Stop();
OAuth2TokenService::ScopeSet oauth2_scopes;
- bool is_managed = false;
-#if defined(ENABLE_MANAGED_USERS)
- is_managed = ManagedUserService::ProfileIsManaged(profile_);
-#endif
- if (is_managed) {
+ if (profile_->IsManaged()) {
oauth2_scopes.insert(GaiaConstants::kChromeSyncManagedOAuth2Scope);
} else {
oauth2_scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope);
@@ -2085,12 +2081,14 @@ void ProfileSyncService::OnInternalUnrecoverableError(
}
std::string ProfileSyncService::GetEffectiveUsername() {
+ if (profile_->IsManaged()) {
#if defined(ENABLE_MANAGED_USERS)
- if (ManagedUserService::ProfileIsManaged(profile_)) {
DCHECK_EQ(std::string(), signin_->GetAuthenticatedUsername());
return ManagedUserService::GetManagedUserPseudoEmail();
- }
+#else
+ NOTREACHED();
#endif
+ }
return signin_->GetAuthenticatedUsername();
}
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 22e9e28..7b96c21 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -34,7 +34,6 @@
#endif
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_service.h"
#include "chrome/browser/managed_mode/managed_user_theme.h"
#endif
@@ -451,15 +450,14 @@ void ThemeService::BuildFromExtension(const Extension* extension) {
}
bool ThemeService::IsManagedUser() const {
-#if defined(ENABLE_MANAGED_USERS)
- return ManagedUserService::ProfileIsManaged(profile_);
-#endif
- return false;
+ return profile_->IsManaged();
}
void ThemeService::SetManagedUserTheme() {
#if defined(ENABLE_MANAGED_USERS)
SetCustomDefaultTheme(new ManagedUserTheme);
+#else
+ NOTREACHED();
#endif
}
diff --git a/chrome/browser/ui/bookmarks/bookmark_utils.cc b/chrome/browser/ui/bookmarks/bookmark_utils.cc
index 71c8ad0..fa52139 100644
--- a/chrome/browser/ui/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_utils.cc
@@ -28,10 +28,6 @@
#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
-#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#endif
-
namespace chrome {
int num_bookmark_urls_before_prompting = 15;
@@ -288,12 +284,10 @@ bool IsAppsShortcutEnabled(const Profile* profile) {
}
bool ShouldShowAppsShortcutInBookmarkBar(Profile* profile) {
-#if defined(ENABLE_MANAGED_USERS)
// Managed users can not have apps installed currently so there's no need to
// show the apps shortcut.
- if (ManagedUserService::ProfileIsManaged(profile))
+ if (profile->IsManaged())
return false;
-#endif
return IsAppsShortcutEnabled(profile) &&
profile->GetPrefs()->GetBoolean(prefs::kShowAppsShortcutInBookmarkBar);
diff --git a/chrome/browser/ui/browser_tab_contents.cc b/chrome/browser/ui/browser_tab_contents.cc
index 02c1691..7beb272 100644
--- a/chrome/browser/ui/browser_tab_contents.cc
+++ b/chrome/browser/ui/browser_tab_contents.cc
@@ -55,7 +55,6 @@
#if defined(ENABLE_MANAGED_USERS)
#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
#endif
#if defined(ENABLE_PRINTING)
@@ -158,10 +157,13 @@ void BrowserTabContents::AttachTabHelpers(WebContents* web_contents) {
captive_portal::CaptivePortalTabHelper::CreateForWebContents(web_contents);
#endif
+ if (profile->IsManaged()) {
#if defined(ENABLE_MANAGED_USERS)
- if (ManagedUserService::ProfileIsManaged(profile))
ManagedModeNavigationObserver::CreateForWebContents(web_contents);
+#else
+ NOTREACHED();
#endif
+ }
#if defined(ENABLE_PRINTING)
printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
diff --git a/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm b/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm
index 2428978..471b64d 100644
--- a/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm
+++ b/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm
@@ -9,7 +9,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/command_updater.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_info_util.h"
@@ -152,7 +151,7 @@ const CGFloat kMenuYOffsetAdjust = 1.0;
// Managed users cannot enter incognito mode, so we only need to check
// it in this code path.
- if (ManagedUserService::ProfileIsManaged(profile)) {
+ if (profile->IsManaged()) {
labelButton_.reset([[NSButton alloc] initWithFrame:NSZeroRect]);
[labelButton_ setButtonType:NSMomentaryLightButton];
[labelButton_ setBezelStyle:NSRecessedBezelStyle];
diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc
index f59fa66..3400691 100644
--- a/chrome/browser/ui/gtk/browser_titlebar.cc
+++ b/chrome/browser/ui/gtk/browser_titlebar.cc
@@ -20,7 +20,6 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
#include "chrome/browser/profiles/avatar_menu_model.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
@@ -818,7 +817,7 @@ void BrowserTitlebar::UpdateAvatar() {
gtk_widget_show_all(avatar_);
Profile* profile = browser_window_->browser()->profile();
- if (ManagedUserService::ProfileIsManaged(profile)) {
+ if (profile->IsManaged()) {
avatar_label_ = gtk_label_new(NULL);
gtk_misc_set_padding(GTK_MISC(avatar_label_), 10, 2);
avatar_label_bg_ = gtk_event_box_new();
diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc
index b7f8201..f576966 100644
--- a/chrome/browser/ui/gtk/gtk_theme_service.cc
+++ b/chrome/browser/ui/gtk/gtk_theme_service.cc
@@ -16,7 +16,6 @@
#include "base/prefs/pref_service.h"
#include "base/stl_util.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service_factory.h"
diff --git a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
index 327df0e..e043412 100644
--- a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
+++ b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
@@ -16,7 +16,6 @@
#if defined(ENABLE_MANAGED_USERS)
#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
#endif
using content::NavigationEntry;
@@ -76,11 +75,7 @@ NavigationEntry* TabContentsSyncedTabDelegate::GetActiveEntry() const {
}
bool TabContentsSyncedTabDelegate::ProfileIsManaged() const {
-#if defined(ENABLE_MANAGED_USERS)
- return ManagedUserService::ProfileIsManaged(profile());
-#else
- return false;
-#endif
+ return profile()->IsManaged();
}
const std::vector<const content::NavigationEntry*>*
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
index ee5dda2..86ddf41 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
@@ -56,15 +56,11 @@ void BrowserNonClientFrameView::OnThemeChanged() {
void BrowserNonClientFrameView::UpdateAvatarInfo() {
if (browser_view_->ShouldShowAvatar()) {
if (!avatar_button_) {
-#if defined(ENABLE_MANAGED_USERS)
Profile* profile = browser_view_->browser()->profile();
- ManagedUserService* service =
- ManagedUserServiceFactory::GetForProfile(profile);
- if (service->ProfileIsManaged() && !avatar_label_) {
+ if (profile->IsManaged() && !avatar_label_) {
avatar_label_ = new AvatarLabel(browser_view_);
AddChildView(avatar_label_);
}
-#endif
avatar_button_ = new AvatarMenuButton(browser_view_->browser(),
browser_view_->IsOffTheRecord());
AddChildView(avatar_button_);
diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
index 2f9f547..3fe581bd 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -601,10 +601,7 @@ void ExtensionSettingsHandler::HandleRequestExtensionsData(
}
results.Set("extensions", extensions_list);
- ManagedUserService* service =
- ManagedUserServiceFactory::GetForProfile(profile);
-
- bool is_managed = service->ProfileIsManaged();
+ bool is_managed = profile->IsManaged();
bool developer_mode =
!is_managed &&
profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
@@ -624,7 +621,7 @@ void ExtensionSettingsHandler::HandleRequestExtensionsData(
void ExtensionSettingsHandler::HandleToggleDeveloperMode(
const ListValue* args) {
Profile* profile = Profile::FromWebUI(web_ui());
- if (ManagedUserServiceFactory::GetForProfile(profile)->ProfileIsManaged())
+ if (profile->IsManaged())
return;
bool developer_mode =
diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc
index 74dde3a..760b436 100644
--- a/chrome/browser/ui/webui/history_ui.cc
+++ b/chrome/browser/ui/webui/history_ui.cc
@@ -180,13 +180,7 @@ content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) {
source->SetDefaultResource(IDR_HISTORY_HTML);
source->SetUseJsonJSFormatV2();
source->DisableDenyXFrameOptions();
-
-#if defined(OS_ANDROID) || defined(OS_IOS)
- source->AddBoolean("isManagedProfile", false);
-#else
- source->AddBoolean("isManagedProfile",
- ManagedUserServiceFactory::GetForProfile(profile)->ProfileIsManaged());
-#endif
+ source->AddBoolean("isManagedProfile", profile->IsManaged());
return source;
}
@@ -370,8 +364,7 @@ scoped_ptr<DictionaryValue> BrowsingHistoryHandler::HistoryEntry::ToValue(
result->SetString("deviceType", device_type);
#if defined(ENABLE_MANAGED_USERS)
- DCHECK(managed_user_service);
- if (managed_user_service->ProfileIsManaged()) {
+ if (managed_user_service) {
const ManagedModeURLFilter* url_filter =
managed_user_service->GetURLFilterForUIThread();
int filtering_behavior =
@@ -697,7 +690,8 @@ void BrowsingHistoryHandler::ReturnResultsToFrontEnd() {
BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile);
ManagedUserService* managed_user_service = NULL;
#if defined(ENABLE_MANAGED_USERS)
- managed_user_service = ManagedUserServiceFactory::GetForProfile(profile);
+ if (profile->IsManaged())
+ managed_user_service = ManagedUserServiceFactory::GetForProfile(profile);
#endif
ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 5eb0b11..42a5eab 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -436,12 +436,10 @@ void NTPResourceCache::CreateNewTabHTML() {
// feature is enabled.
load_time_data.SetBoolean("isSwipeTrackingFromScrollEventsEnabled",
is_swipe_tracking_from_scroll_events_enabled_);
- #if defined(ENABLE_MANAGED_USERS)
- // Managed users can not have apps installed currently so there's no need to
- // show the app cards.
- if (ManagedUserService::ProfileIsManaged(profile_))
- should_show_apps_page_ = false;
- #endif
+ // Managed users can not have apps installed currently so there's no need to
+ // show the app cards.
+ if (profile_->IsManaged())
+ should_show_apps_page_ = false;
load_time_data.SetBoolean("showApps", should_show_apps_page_);
load_time_data.SetBoolean("showWebStoreIcon",
!prefs->GetBoolean(prefs::kHideWebStoreIcon));
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index f941f2e..c815c92 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -522,10 +522,8 @@ void BrowserOptionsHandler::GetLocalizedValues(DictionaryValue* values) {
if (ShouldShowMultiProfilesUserList(GetDesktopType()))
values->Set("profilesInfo", GetProfilesInfoList().release());
-#if defined(ENABLE_MANAGED_USERS)
values->SetBoolean("profileIsManaged",
- ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui())));
-#endif
+ Profile::FromWebUI(web_ui())->IsManaged());
#if !defined(OS_CHROMEOS)
values->SetBoolean(
@@ -1104,13 +1102,11 @@ chrome::HostDesktopType BrowserOptionsHandler::GetDesktopType() {
}
void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
-#if defined(ENABLE_MANAGED_USERS)
// This handler could have been called in managed mode, for example because
// the user fiddled with the web inspector. Silently return in this case.
Profile* current_profile = Profile::FromWebUI(web_ui());
- if (ManagedUserService::ProfileIsManaged(current_profile))
+ if (current_profile->IsManaged())
return;
-#endif
if (!profiles::IsMultipleProfilesEnabled())
return;
@@ -1139,13 +1135,9 @@ void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
managed_user);
if (managed_user && ManagedUserService::AreManagedUsersEnabled()) {
-#if defined(ENABLE_MANAGED_USERS)
callbacks.push_back(
base::Bind(&BrowserOptionsHandler::RegisterNewManagedUser,
weak_ptr_factory_.GetWeakPtr(), show_user_feedback));
-#else
- NOTREACHED();
-#endif
} else {
callbacks.push_back(show_user_feedback);
}
@@ -1167,7 +1159,6 @@ void BrowserOptionsHandler::RegisterNewManagedUser(
ManagedUserService* managed_user_service =
ManagedUserServiceFactory::GetForProfile(new_profile);
- DCHECK(managed_user_service->ProfileIsManaged());
// Register the managed user using the profile of the custodian.
managed_user_service->RegisterAndInitSync(Profile::FromWebUI(web_ui()),
@@ -1259,12 +1250,10 @@ void BrowserOptionsHandler::DeleteProfile(const ListValue* args) {
}
void BrowserOptionsHandler::DeleteProfileAtPath(base::FilePath file_path) {
-#if defined(ENABLE_MANAGED_USERS)
// This handler could have been called in managed mode, for example because
// the user fiddled with the web inspector. Silently return in this case.
- if (ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui())))
+ if (Profile::FromWebUI(web_ui())->IsManaged())
return;
-#endif
if (!profiles::IsMultipleProfilesEnabled())
return;
@@ -1292,7 +1281,7 @@ void BrowserOptionsHandler::CancelProfileRegistration(bool user_initiated) {
// Non-managed user creation cannot be canceled. (Creating a non-managed
// profile shouldn't take significant time, and it can easily be deleted
// afterward.)
- if (!ManagedUserService::ProfileIsManaged(new_profile))
+ if (!new_profile->IsManaged())
return;
if (user_initiated) {
@@ -1321,7 +1310,7 @@ void BrowserOptionsHandler::ObserveThemeChanged() {
bool is_native_theme = false;
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- bool profile_is_managed = ManagedUserService::ProfileIsManaged(profile);
+ bool profile_is_managed = profile->IsManaged();
is_native_theme = theme_service->UsingNativeTheme();
base::FundamentalValue native_theme_enabled(!is_native_theme &&
!profile_is_managed);
@@ -1365,7 +1354,7 @@ void BrowserOptionsHandler::UpdateAccountPicture() {
scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() {
scoped_ptr<DictionaryValue> sync_status(new DictionaryValue);
Profile* profile = Profile::FromWebUI(web_ui());
- if (ManagedUserService::ProfileIsManaged(profile)) {
+ if (profile->IsManaged()) {
sync_status->SetBoolean("supervisedUser", true);
sync_status->SetBoolean("signinAllowed", false);
return sync_status.Pass();
diff --git a/chrome/browser/ui/webui/options/manage_profile_handler.cc b/chrome/browser/ui/webui/options/manage_profile_handler.cc
index 903e818..8a9f871 100644
--- a/chrome/browser/ui/webui/options/manage_profile_handler.cc
+++ b/chrome/browser/ui/webui/options/manage_profile_handler.cc
@@ -36,11 +36,6 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/webui/web_ui_util.h"
-#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
-#endif
-
#if defined(ENABLE_SETTINGS_APP)
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "content/public/browser/web_contents.h"
@@ -301,7 +296,7 @@ void ManageProfileHandler::SetProfileIconAndName(const ListValue* args) {
}
ProfileMetrics::LogProfileUpdate(profile_file_path);
- if (ManagedUserService::ProfileIsManaged(profile))
+ if (profile->IsManaged())
return;
string16 new_profile_name;
diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h
index a3b4dab..9d1b050 100644
--- a/chrome/common/chrome_paths.h
+++ b/chrome/common/chrome_paths.h
@@ -101,11 +101,9 @@ enum {
DIR_CHROMEOS_CUSTOM_WALLPAPERS, // Directory where custom wallpapers
// reside.
#endif
-#if defined(ENABLE_MANAGED_USERS)
DIR_MANAGED_USERS_DEFAULT_APPS, // Directory where installer places .crx
// files to be installed when managed user
// session starts.
-#endif
// Valid only in development environment; TODO(darin): move these
DIR_GEN_TEST_DATA, // Directory where generated test data resides.
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 7611a93..3d9511d 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -53,6 +53,7 @@
#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/bookmark_load_observer.h"
#include "chrome/test/base/history_index_restore_observer.h"
@@ -545,6 +546,10 @@ Profile* TestingProfile::GetOriginalProfile() {
return this;
}
+bool TestingProfile::IsManaged() {
+ return GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
+}
+
ExtensionService* TestingProfile::GetExtensionService() {
return extensions::ExtensionSystem::Get(this)->extension_service();
}
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index 91a2a22..8e63e5a 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -194,6 +194,7 @@ class TestingProfile : public Profile {
virtual void DestroyOffTheRecordProfile() OVERRIDE {}
virtual bool HasOffTheRecordProfile() OVERRIDE;
virtual Profile* GetOriginalProfile() OVERRIDE;
+ virtual bool IsManaged() OVERRIDE;
virtual ExtensionService* GetExtensionService() OVERRIDE;
void SetExtensionSpecialStoragePolicy(
ExtensionSpecialStoragePolicy* extension_special_storage_policy);