summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authortreib@chromium.org <treib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 13:43:51 +0000
committertreib@chromium.org <treib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 13:43:51 +0000
commitcce15bbb3299234c61d0799db32fc56f572babb4 (patch)
treeeb8b67dbe4f5c6023ffc1d504b916df78909082b /chrome/browser
parent924d6e81f371779be8c23a13190ba7963ef5b7fc (diff)
downloadchromium_src-cce15bbb3299234c61d0799db32fc56f572babb4.zip
chromium_src-cce15bbb3299234c61d0799db32fc56f572babb4.tar.gz
chromium_src-cce15bbb3299234c61d0799db32fc56f572babb4.tar.bz2
Rename "managed (mode|user)" to "supervised user" (part 2)
Followup to https://codereview.chromium.org/316863002/ This CL changes: - c/b/managed_mode/ to c/b/supervised_user/ - "ManagedMode"/"ManagedUser" to "SupervisedUser" in c/b/supervised_user/ Still missing: - Some stuff outside of c/b/supervised_user/, mostly (but not only) c/b/chromeos/login/managed/ - JavaScript - Resource names The remaining things will come in followup CLs. TBR=nkostylev@chromium.org (c/b/chromeos) TBR=noms@chromium.org (c/b/profiles) TBR=thakis@chromium.org (rest of c/) All the TBRs are just trivial renames. BUG=385113 Review URL: https://codereview.chromium.org/335833003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277750 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/login/managed/locally_managed_user_constants.cc10
-rw-r--r--chrome/browser/chromeos/login/managed/locally_managed_user_constants.h14
-rw-r--r--chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc61
-rw-r--r--chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.h16
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_creation_browsertest.cc16
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_creation_controller.h2
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.cc17
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.h6
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.cc10
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.h4
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_password_browsertest.cc22
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_test_base.cc24
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_test_base.h10
-rw-r--r--chrome/browser/chromeos/login/managed/supervised_user_authentication.cc2
-rw-r--r--chrome/browser/chromeos/login/managed/supervised_user_login_flow.cc12
-rw-r--r--chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc57
-rw-r--r--chrome/browser/chromeos/login/users/user.h3
-rw-r--r--chrome/browser/chromeos/login/users/user_manager_impl.cc6
-rw-r--r--chrome/browser/extensions/webstore_startup_installer_browsertest.cc2
-rw-r--r--chrome/browser/managed_mode/chromeos/managed_user_password_service.h45
-rw-r--r--chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.h39
-rw-r--r--chrome/browser/managed_mode/managed_mode_resource_throttle.cc69
-rw-r--r--chrome/browser/managed_mode/managed_mode_resource_throttle.h47
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility.cc402
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility.h111
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility_stub.h47
-rw-r--r--chrome/browser/managed_mode/managed_user_service_factory.h37
-rw-r--r--chrome/browser/managed_mode/managed_user_settings_service_factory.cc43
-rw-r--r--chrome/browser/managed_mode/managed_user_settings_service_factory.h35
-rw-r--r--chrome/browser/managed_mode/managed_user_shared_settings_service_factory.cc39
-rw-r--r--chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h33
-rw-r--r--chrome/browser/managed_mode/managed_user_shared_settings_update.cc40
-rw-r--r--chrome/browser/managed_mode/managed_user_sync_service_factory.cc34
-rw-r--r--chrome/browser/managed_mode/managed_user_sync_service_factory.h32
-rw-r--r--chrome/browser/managed_mode/managed_user_sync_service_observer.h23
-rw-r--r--chrome/browser/managed_mode/managed_users.h14
-rw-r--r--chrome/browser/managed_mode/permission_request_creator_sync.h36
-rw-r--r--chrome/browser/prefs/browser_prefs.cc14
-rw-r--r--chrome/browser/prefs/chrome_pref_service_factory.cc15
-rw-r--r--chrome/browser/prefs/chrome_pref_service_factory.h4
-rw-r--r--chrome/browser/profiles/avatar_menu.cc8
-rw-r--r--chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc14
-rw-r--r--chrome/browser/profiles/profile_impl.cc14
-rw-r--r--chrome/browser/profiles/profile_io_data.cc16
-rw-r--r--chrome/browser/profiles/profile_io_data.h11
-rw-r--r--chrome/browser/profiles/profile_manager.cc6
-rw-r--r--chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc6
-rw-r--r--chrome/browser/search/search.cc16
-rw-r--r--chrome/browser/search/search_unittest.cc14
-rw-r--r--chrome/browser/signin/chrome_signin_client.cc2
-rw-r--r--chrome/browser/supervised_user/OWNERS (renamed from chrome/browser/managed_mode/OWNERS)0
-rw-r--r--chrome/browser/supervised_user/chromeos/manager_password_service.cc (renamed from chrome/browser/managed_mode/chromeos/manager_password_service.cc)59
-rw-r--r--chrome/browser/supervised_user/chromeos/manager_password_service.h (renamed from chrome/browser/managed_mode/chromeos/manager_password_service.h)46
-rw-r--r--chrome/browser/supervised_user/chromeos/manager_password_service_factory.cc (renamed from chrome/browser/managed_mode/chromeos/manager_password_service_factory.cc)17
-rw-r--r--chrome/browser/supervised_user/chromeos/manager_password_service_factory.h (renamed from chrome/browser/managed_mode/chromeos/manager_password_service_factory.h)8
-rw-r--r--chrome/browser/supervised_user/chromeos/supervised_user_password_service.cc (renamed from chrome/browser/managed_mode/chromeos/managed_user_password_service.cc)30
-rw-r--r--chrome/browser/supervised_user/chromeos/supervised_user_password_service.h46
-rw-r--r--chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.cc (renamed from chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.cc)37
-rw-r--r--chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h39
-rw-r--r--chrome/browser/supervised_user/custodian_profile_downloader_service.cc (renamed from chrome/browser/managed_mode/custodian_profile_downloader_service.cc)4
-rw-r--r--chrome/browser/supervised_user/custodian_profile_downloader_service.h (renamed from chrome/browser/managed_mode/custodian_profile_downloader_service.h)8
-rw-r--r--chrome/browser/supervised_user/custodian_profile_downloader_service_factory.cc (renamed from chrome/browser/managed_mode/custodian_profile_downloader_service_factory.cc)6
-rw-r--r--chrome/browser/supervised_user/custodian_profile_downloader_service_factory.h (renamed from chrome/browser/managed_mode/custodian_profile_downloader_service_factory.h)8
-rw-r--r--chrome/browser/supervised_user/permission_request_creator.h (renamed from chrome/browser/managed_mode/permission_request_creator.h)6
-rw-r--r--chrome/browser/supervised_user/permission_request_creator_apiary.cc (renamed from chrome/browser/managed_mode/permission_request_creator_apiary.cc)2
-rw-r--r--chrome/browser/supervised_user/permission_request_creator_apiary.h (renamed from chrome/browser/managed_mode/permission_request_creator_apiary.h)8
-rw-r--r--chrome/browser/supervised_user/permission_request_creator_sync.cc (renamed from chrome/browser/managed_mode/permission_request_creator_sync.cc)31
-rw-r--r--chrome/browser/supervised_user/permission_request_creator_sync.h36
-rw-r--r--chrome/browser/supervised_user/supervised_user_browsertest.cc (renamed from chrome/browser/managed_mode/managed_mode_browsertest.cc)91
-rw-r--r--chrome/browser/supervised_user/supervised_user_constants.cc (renamed from chrome/browser/managed_mode/managed_user_constants.cc)10
-rw-r--r--chrome/browser/supervised_user/supervised_user_constants.h (renamed from chrome/browser/managed_mode/managed_user_constants.h)20
-rw-r--r--chrome/browser/supervised_user/supervised_user_interstitial.cc (renamed from chrome/browser/managed_mode/managed_mode_interstitial.cc)68
-rw-r--r--chrome/browser/supervised_user/supervised_user_interstitial.h (renamed from chrome/browser/managed_mode/managed_mode_interstitial.h)26
-rw-r--r--chrome/browser/supervised_user/supervised_user_navigation_observer.cc (renamed from chrome/browser/managed_mode/managed_mode_navigation_observer.cc)98
-rw-r--r--chrome/browser/supervised_user/supervised_user_navigation_observer.h (renamed from chrome/browser/managed_mode/managed_mode_navigation_observer.h)32
-rw-r--r--chrome/browser/supervised_user/supervised_user_pref_mapping_service.cc (renamed from chrome/browser/managed_mode/supervised_user_pref_mapping_service.cc)32
-rw-r--r--chrome/browser/supervised_user/supervised_user_pref_mapping_service.h (renamed from chrome/browser/managed_mode/supervised_user_pref_mapping_service.h)30
-rw-r--r--chrome/browser/supervised_user/supervised_user_pref_mapping_service_factory.cc (renamed from chrome/browser/managed_mode/supervised_user_pref_mapping_service_factory.cc)11
-rw-r--r--chrome/browser/supervised_user/supervised_user_pref_mapping_service_factory.h (renamed from chrome/browser/managed_mode/supervised_user_pref_mapping_service_factory.h)8
-rw-r--r--chrome/browser/supervised_user/supervised_user_pref_mapping_service_unittest.cc (renamed from chrome/browser/managed_mode/supervised_user_pref_mapping_service_unittest.cc)27
-rw-r--r--chrome/browser/supervised_user/supervised_user_pref_store.cc (renamed from chrome/browser/managed_mode/supervised_user_pref_store.cc)40
-rw-r--r--chrome/browser/supervised_user/supervised_user_pref_store.h (renamed from chrome/browser/managed_mode/supervised_user_pref_store.h)18
-rw-r--r--chrome/browser/supervised_user/supervised_user_pref_store_unittest.cc (renamed from chrome/browser/managed_mode/supervised_user_pref_store_unittest.cc)28
-rw-r--r--chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.cc (renamed from chrome/browser/managed_mode/managed_user_refresh_token_fetcher.cc)79
-rw-r--r--chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h (renamed from chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h)26
-rw-r--r--chrome/browser/supervised_user/supervised_user_refresh_token_fetcher_unittest.cc (renamed from chrome/browser/managed_mode/managed_user_refresh_token_fetcher_unittest.cc)94
-rw-r--r--chrome/browser/supervised_user/supervised_user_registration_utility.cc408
-rw-r--r--chrome/browser/supervised_user/supervised_user_registration_utility.h110
-rw-r--r--chrome/browser/supervised_user/supervised_user_registration_utility_stub.cc (renamed from chrome/browser/managed_mode/managed_user_registration_utility_stub.cc)21
-rw-r--r--chrome/browser/supervised_user/supervised_user_registration_utility_stub.h47
-rw-r--r--chrome/browser/supervised_user/supervised_user_registration_utility_unittest.cc (renamed from chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc)125
-rw-r--r--chrome/browser/supervised_user/supervised_user_resource_throttle.cc71
-rw-r--r--chrome/browser/supervised_user/supervised_user_resource_throttle.h47
-rw-r--r--chrome/browser/supervised_user/supervised_user_resource_throttle_browsertest.cc (renamed from chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc)45
-rw-r--r--chrome/browser/supervised_user/supervised_user_service.cc (renamed from chrome/browser/managed_mode/managed_user_service.cc)249
-rw-r--r--chrome/browser/supervised_user/supervised_user_service.h (renamed from chrome/browser/managed_mode/managed_user_service.h)107
-rw-r--r--chrome/browser/supervised_user/supervised_user_service_browsertest.cc (renamed from chrome/browser/managed_mode/managed_user_service_browsertest.cc)49
-rw-r--r--chrome/browser/supervised_user/supervised_user_service_factory.cc (renamed from chrome/browser/managed_mode/managed_user_service_factory.cc)29
-rw-r--r--chrome/browser/supervised_user/supervised_user_service_factory.h37
-rw-r--r--chrome/browser/supervised_user/supervised_user_service_unittest.cc (renamed from chrome/browser/managed_mode/managed_user_service_unittest.cc)213
-rw-r--r--chrome/browser/supervised_user/supervised_user_settings_service.cc (renamed from chrome/browser/managed_mode/managed_user_settings_service.cc)79
-rw-r--r--chrome/browser/supervised_user/supervised_user_settings_service.h (renamed from chrome/browser/managed_mode/managed_user_settings_service.h)52
-rw-r--r--chrome/browser/supervised_user/supervised_user_settings_service_factory.cc43
-rw-r--r--chrome/browser/supervised_user/supervised_user_settings_service_factory.h35
-rw-r--r--chrome/browser/supervised_user/supervised_user_settings_service_unittest.cc (renamed from chrome/browser/managed_mode/managed_user_settings_service_unittest.cc)44
-rw-r--r--chrome/browser/supervised_user/supervised_user_shared_settings_service.cc (renamed from chrome/browser/managed_mode/managed_user_shared_settings_service.cc)112
-rw-r--r--chrome/browser/supervised_user/supervised_user_shared_settings_service.h (renamed from chrome/browser/managed_mode/managed_user_shared_settings_service.h)61
-rw-r--r--chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.cc40
-rw-r--r--chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h34
-rw-r--r--chrome/browser/supervised_user/supervised_user_shared_settings_service_unittest.cc (renamed from chrome/browser/managed_mode/managed_user_shared_settings_service_unittest.cc)36
-rw-r--r--chrome/browser/supervised_user/supervised_user_shared_settings_update.cc40
-rw-r--r--chrome/browser/supervised_user/supervised_user_shared_settings_update.h (renamed from chrome/browser/managed_mode/managed_user_shared_settings_update.h)28
-rw-r--r--chrome/browser/supervised_user/supervised_user_shared_settings_update_unittest.cc (renamed from chrome/browser/managed_mode/managed_user_shared_settings_update_unittest.cc)34
-rw-r--r--chrome/browser/supervised_user/supervised_user_site_list.cc (renamed from chrome/browser/managed_mode/managed_mode_site_list.cc)31
-rw-r--r--chrome/browser/supervised_user/supervised_user_site_list.h (renamed from chrome/browser/managed_mode/managed_mode_site_list.h)28
-rw-r--r--chrome/browser/supervised_user/supervised_user_sync_service.cc (renamed from chrome/browser/managed_mode/managed_user_sync_service.cc)243
-rw-r--r--chrome/browser/supervised_user/supervised_user_sync_service.h (renamed from chrome/browser/managed_mode/managed_user_sync_service.h)102
-rw-r--r--chrome/browser/supervised_user/supervised_user_sync_service_factory.cc36
-rw-r--r--chrome/browser/supervised_user/supervised_user_sync_service_factory.h32
-rw-r--r--chrome/browser/supervised_user/supervised_user_sync_service_observer.h23
-rw-r--r--chrome/browser/supervised_user/supervised_user_sync_service_unittest.cc (renamed from chrome/browser/managed_mode/managed_user_sync_service_unittest.cc)177
-rw-r--r--chrome/browser/supervised_user/supervised_user_theme.cc (renamed from chrome/browser/managed_mode/managed_user_theme.cc)34
-rw-r--r--chrome/browser/supervised_user/supervised_user_theme.h (renamed from chrome/browser/managed_mode/managed_user_theme.h)16
-rw-r--r--chrome/browser/supervised_user/supervised_user_url_filter.cc (renamed from chrome/browser/managed_mode/managed_mode_url_filter.cc)85
-rw-r--r--chrome/browser/supervised_user/supervised_user_url_filter.h (renamed from chrome/browser/managed_mode/managed_mode_url_filter.h)30
-rw-r--r--chrome/browser/supervised_user/supervised_user_url_filter_unittest.cc (renamed from chrome/browser/managed_mode/managed_mode_url_filter_unittest.cc)186
-rw-r--r--chrome/browser/supervised_user/supervised_users.h14
-rw-r--r--chrome/browser/sync/managed_user_signin_manager_wrapper.cc6
-rw-r--r--chrome/browser/sync/profile_sync_components_factory_impl.cc18
-rw-r--r--chrome/browser/sync/sessions/notification_service_sessions_router.cc10
-rw-r--r--chrome/browser/sync/test/integration/profile_sync_service_harness.cc4
-rw-r--r--chrome/browser/sync/test/integration/single_client_managed_user_settings_sync_test.cc34
-rw-r--r--chrome/browser/themes/theme_service.cc4
-rw-r--r--chrome/browser/themes/theme_service_unittest.cc4
-rw-r--r--chrome/browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm4
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator_browsertest.cc6
-rw-r--r--chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc6
-rw-r--r--chrome/browser/ui/tab_helpers.cc4
-rw-r--r--chrome/browser/ui/webui/downloads_ui_browsertest.cc4
-rw-r--r--chrome/browser/ui/webui/extensions/extension_settings_handler.cc4
-rw-r--r--chrome/browser/ui/webui/history_ui.cc23
-rw-r--r--chrome/browser/ui/webui/history_ui.h4
-rw-r--r--chrome/browser/ui/webui/options/create_profile_handler.cc31
-rw-r--r--chrome/browser/ui/webui/options/create_profile_handler.h5
-rw-r--r--chrome/browser/ui/webui/options/managed_user_import_handler.cc81
-rw-r--r--chrome/browser/ui/webui/options/managed_user_import_handler.h14
-rw-r--r--chrome/browser/ui/webui/signin/user_manager_screen_handler.cc2
147 files changed, 3144 insertions, 3046 deletions
diff --git a/chrome/browser/chromeos/login/managed/locally_managed_user_constants.cc b/chrome/browser/chromeos/login/managed/locally_managed_user_constants.cc
index 99bb39a..fbfff0b 100644
--- a/chrome/browser/chromeos/login/managed/locally_managed_user_constants.cc
+++ b/chrome/browser/chromeos/login/managed/locally_managed_user_constants.cc
@@ -8,16 +8,16 @@
namespace chromeos {
-const char kManagedUserTokenFilename[] = "token";
+const char kSupervisedUserTokenFilename[] = "token";
-const char kCryptohomeManagedUserKeyLabel[] = "managed";
+const char kCryptohomeSupervisedUserKeyLabel[] = "managed";
const char kCryptohomeMasterKeyLabel[] = "master";
-const char kLegacyCryptohomeManagedUserKeyLabel[] = "default-0";
+const char kLegacyCryptohomeSupervisedUserKeyLabel[] = "default-0";
const char kLegacyCryptohomeMasterKeyLabel[] = "default-1";
-const int kCryptohomeManagedUserKeyPrivileges =
+const int kCryptohomeSupervisedUserKeyPrivileges =
cryptohome::PRIV_AUTHORIZED_UPDATE | cryptohome::PRIV_MOUNT;
-const int kCryptohomeManagedUserIncompleteKeyPrivileges =
+const int kCryptohomeSupervisedUserIncompleteKeyPrivileges =
cryptohome::PRIV_MIGRATE | cryptohome::PRIV_MOUNT;
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/managed/locally_managed_user_constants.h b/chrome/browser/chromeos/login/managed/locally_managed_user_constants.h
index f7e6af8..aaffbfd 100644
--- a/chrome/browser/chromeos/login/managed/locally_managed_user_constants.h
+++ b/chrome/browser/chromeos/login/managed/locally_managed_user_constants.h
@@ -9,22 +9,22 @@
namespace chromeos {
-extern const char kManagedUserTokenFilename[];
+extern const char kSupervisedUserTokenFilename[];
-extern const char kCryptohomeManagedUserKeyLabel[];
+extern const char kCryptohomeSupervisedUserKeyLabel[];
extern const char kCryptohomeMasterKeyLabel[];
-extern const char kLegacyCryptohomeManagedUserKeyLabel[];
+extern const char kLegacyCryptohomeSupervisedUserKeyLabel[];
extern const char kLegacyCryptohomeMasterKeyLabel[];
-// Set of privileges for usual Managed User : Mount and UpdatePrivileged
+// Set of privileges for usual Supervised User : Mount and UpdatePrivileged
// (update with signed key).
-extern const int kCryptohomeManagedUserKeyPrivileges;
+extern const int kCryptohomeSupervisedUserKeyPrivileges;
// Set of privileges for corner case when pre-M35 managed user got new password.
// As we don't have signature yet, Migrate is used instead of UpdatePrivileged.
-// Privileges are reset to kCryptohomeManagedUserKeyPrivileges as soon as
+// Privileges are reset to kCryptohomeSupervisedUserKeyPrivileges as soon as
// manager signs in on the machine.
-extern const int kCryptohomeManagedUserIncompleteKeyPrivileges;
+extern const int kCryptohomeSupervisedUserIncompleteKeyPrivileges;
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc
index 1d341e8..525dbf8 100644
--- a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc
+++ b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc
@@ -22,11 +22,11 @@
#include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chromeos/network/network_state.h"
#include "content/public/browser/browser_thread.h"
#include "grit/generated_resources.h"
@@ -239,13 +239,13 @@ void LocallyManagedUserCreationScreen::ImportManagedUser(
std::string avatar;
bool exists;
int avatar_index = ManagedUserCreationController::kDummyAvatarIndex;
- user_info->GetString(ManagedUserSyncService::kName, &display_name);
- user_info->GetString(ManagedUserSyncService::kMasterKey, &master_key);
- user_info->GetString(ManagedUserSyncService::kPasswordSignatureKey,
+ user_info->GetString(SupervisedUserSyncService::kName, &display_name);
+ user_info->GetString(SupervisedUserSyncService::kMasterKey, &master_key);
+ user_info->GetString(SupervisedUserSyncService::kPasswordSignatureKey,
&signature_key);
- user_info->GetString(ManagedUserSyncService::kPasswordEncryptionKey,
+ user_info->GetString(SupervisedUserSyncService::kPasswordEncryptionKey,
&encryption_key);
- user_info->GetString(ManagedUserSyncService::kChromeOsAvatar, &avatar);
+ user_info->GetString(SupervisedUserSyncService::kChromeOsAvatar, &avatar);
user_info->GetBoolean(kUserExists, &exists);
// We should not get here with existing user selected, so just display error.
@@ -260,14 +260,14 @@ void LocallyManagedUserCreationScreen::ImportManagedUser(
return;
}
- ManagedUserSyncService::GetAvatarIndex(avatar, &avatar_index);
+ SupervisedUserSyncService::GetAvatarIndex(avatar, &avatar_index);
const base::DictionaryValue* password_data = NULL;
- ManagedUserSharedSettingsService* shared_settings_service =
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ SupervisedUserSharedSettingsService* shared_settings_service =
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
controller_->GetManagerProfile());
const base::Value* value = shared_settings_service->GetValue(
- user_id, managed_users::kChromeOSPasswordData);
+ user_id, supervised_users::kChromeOSPasswordData);
bool password_right_here = value && value->GetAsDictionary(&password_data) &&
!password_data->empty();
@@ -303,9 +303,9 @@ void LocallyManagedUserCreationScreen::ImportManagedUserWithPassword(
std::string avatar;
bool exists;
int avatar_index = ManagedUserCreationController::kDummyAvatarIndex;
- user_info->GetString(ManagedUserSyncService::kName, &display_name);
- user_info->GetString(ManagedUserSyncService::kMasterKey, &master_key);
- user_info->GetString(ManagedUserSyncService::kChromeOsAvatar, &avatar);
+ user_info->GetString(SupervisedUserSyncService::kName, &display_name);
+ user_info->GetString(SupervisedUserSyncService::kMasterKey, &master_key);
+ user_info->GetString(SupervisedUserSyncService::kChromeOsAvatar, &avatar);
user_info->GetBoolean(kUserExists, &exists);
// We should not get here with existing user selected, so just display error.
@@ -320,7 +320,7 @@ void LocallyManagedUserCreationScreen::ImportManagedUserWithPassword(
return;
}
- ManagedUserSyncService::GetAvatarIndex(avatar, &avatar_index);
+ SupervisedUserSyncService::GetAvatarIndex(avatar, &avatar_index);
controller_->StartImport(display_name,
password,
@@ -348,14 +348,15 @@ void LocallyManagedUserCreationScreen::OnManagerFullyAuthenticated(
last_page_ = kNameOfNewUserParametersScreen;
CHECK(!sync_service_);
- sync_service_ = ManagedUserSyncServiceFactory::GetForProfile(manager_profile);
+ sync_service_ = SupervisedUserSyncServiceFactory::GetForProfile(
+ manager_profile);
sync_service_->AddObserver(this);
- OnManagedUsersChanged();
+ OnSupervisedUsersChanged();
}
-void LocallyManagedUserCreationScreen::OnManagedUsersChanged() {
+void LocallyManagedUserCreationScreen::OnSupervisedUsersChanged() {
CHECK(sync_service_);
- sync_service_->GetManagedUsersAsync(
+ sync_service_->GetSupervisedUsersAsync(
base::Bind(&LocallyManagedUserCreationScreen::OnGetManagedUsers,
weak_factory_.GetWeakPtr()));
}
@@ -431,7 +432,7 @@ bool LocallyManagedUserCreationScreen::FindUserByDisplayName(
const base::DictionaryValue* user_info =
static_cast<const base::DictionaryValue*>(&it.value());
base::string16 user_display_name;
- if (user_info->GetString(ManagedUserSyncService::kName,
+ if (user_info->GetString(SupervisedUserSyncService::kName,
&user_display_name)) {
if (display_name == user_display_name) {
if (out_id)
@@ -502,17 +503,17 @@ void LocallyManagedUserCreationScreen::OnGetManagedUsers(
int avatar_index = ManagedUserCreationController::kDummyAvatarIndex;
std::string chromeos_avatar;
- if (local_copy->GetString(ManagedUserSyncService::kChromeOsAvatar,
+ if (local_copy->GetString(SupervisedUserSyncService::kChromeOsAvatar,
&chromeos_avatar) &&
!chromeos_avatar.empty() &&
- ManagedUserSyncService::GetAvatarIndex(
+ SupervisedUserSyncService::GetAvatarIndex(
chromeos_avatar, &avatar_index)) {
ui_copy->SetString(kAvatarURLKey, GetDefaultImageUrl(avatar_index));
} else {
int i = base::RandInt(kFirstDefaultImageIndex, kDefaultImagesCount - 1);
local_copy->SetString(
- ManagedUserSyncService::kChromeOsAvatar,
- ManagedUserSyncService::BuildAvatarString(i));
+ SupervisedUserSyncService::kChromeOsAvatar,
+ SupervisedUserSyncService::BuildAvatarString(i));
local_copy->SetBoolean(kRandomAvatarKey, true);
ui_copy->SetString(kAvatarURLKey, GetDefaultImageUrl(i));
}
@@ -521,7 +522,7 @@ void LocallyManagedUserCreationScreen::OnGetManagedUsers(
ui_copy->SetBoolean(kUserExists, false);
base::string16 display_name;
- local_copy->GetString(ManagedUserSyncService::kName, &display_name);
+ local_copy->GetString(SupervisedUserSyncService::kName, &display_name);
if (supervised_user_manager->FindBySyncId(it.key())) {
local_copy->SetBoolean(kUserExists, true);
@@ -534,11 +535,11 @@ void LocallyManagedUserCreationScreen::OnGetManagedUsers(
local_copy->SetString(kUserConflict, kUserConflictName);
ui_copy->SetString(kUserConflict, kUserConflictName);
}
- ui_copy->SetString(ManagedUserSyncService::kName, display_name);
+ ui_copy->SetString(SupervisedUserSyncService::kName, display_name);
std::string signature_key;
bool has_password =
- local_copy->GetString(ManagedUserSyncService::kPasswordSignatureKey,
+ local_copy->GetString(SupervisedUserSyncService::kPasswordSignatureKey,
&signature_key) &&
!signature_key.empty();
diff --git a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.h b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.h
index cb46152..034325e 100644
--- a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.h
+++ b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.h
@@ -14,7 +14,7 @@
#include "chrome/browser/chromeos/login/screens/wizard_screen.h"
#include "chrome/browser/chromeos/net/network_portal_detector.h"
#include "chrome/browser/image_decoder.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
#include "chrome/browser/ui/webui/chromeos/login/locally_managed_user_creation_screen_handler.h"
#include "ui/gfx/image/image_skia.h"
@@ -29,7 +29,7 @@ class LocallyManagedUserCreationScreen
: public WizardScreen,
public LocallyManagedUserCreationScreenHandler::Delegate,
public ManagedUserCreationController::StatusConsumer,
- public ManagedUserSyncServiceObserver,
+ public SupervisedUserSyncServiceObserver,
public ImageDecoder::Delegate,
public NetworkPortalDetector::Observer,
public CameraPresenceNotifier::Observer {
@@ -65,11 +65,11 @@ class LocallyManagedUserCreationScreen
// CameraPresenceNotifier::Observer implementation:
virtual void OnCameraPresenceCheckDone(bool is_camera_present) OVERRIDE;
- // ManagedUserSyncServiceObserver implementation
- virtual void OnManagedUserAcknowledged(
- const std::string& managed_user_id) OVERRIDE {}
- virtual void OnManagedUsersSyncingStopped() OVERRIDE {}
- virtual void OnManagedUsersChanged() OVERRIDE;
+ // SupervisedUserSyncServiceObserver implementation
+ virtual void OnSupervisedUserAcknowledged(
+ const std::string& supervised_user_id) OVERRIDE {}
+ virtual void OnSupervisedUsersSyncingStopped() OVERRIDE {}
+ virtual void OnSupervisedUsersChanged() OVERRIDE;
// WizardScreen implementation:
virtual void PrepareToShow() OVERRIDE;
@@ -134,7 +134,7 @@ class LocallyManagedUserCreationScreen
bool on_error_screen_;
std::string last_page_;
- ManagedUserSyncService* sync_service_;
+ SupervisedUserSyncService* sync_service_;
gfx::ImageSkia user_photo_;
scoped_refptr<ImageDecoder> image_decoder_;
diff --git a/chrome/browser/chromeos/login/managed/managed_user_creation_browsertest.cc b/chrome/browser/chromeos/login/managed/managed_user_creation_browsertest.cc
index 282f71c..5a5096c 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_creation_browsertest.cc
+++ b/chrome/browser/chromeos/login/managed/managed_user_creation_browsertest.cc
@@ -18,13 +18,13 @@
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility_stub.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility_stub.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chromeos/cryptohome/mock_async_method_caller.h"
#include "chromeos/cryptohome/mock_homedir_methods.h"
#include "content/public/browser/notification_service.h"
@@ -156,7 +156,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserTransactionCleanupTest,
EXPECT_EQ(registration_utility_stub_->display_name(),
base::UTF8ToUTF16(kTestSupervisedUserDisplayName));
- std::string user_id = registration_utility_stub_->managed_user_id();
+ std::string user_id = registration_utility_stub_->supervised_user_id();
// Make sure user is already in list.
ASSERT_EQ(3UL, UserManager::Get()->GetUsers().size());
diff --git a/chrome/browser/chromeos/login/managed/managed_user_creation_controller.h b/chrome/browser/chromeos/login/managed/managed_user_creation_controller.h
index becd69f..8faec8d 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_creation_controller.h
+++ b/chrome/browser/chromeos/login/managed/managed_user_creation_controller.h
@@ -14,7 +14,7 @@
#include "base/timer/timer.h"
#include "base/values.h"
#include "chrome/browser/chromeos/login/managed/managed_user_authenticator.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
class Profile;
diff --git a/chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.cc b/chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.cc
index 7cf86f3..f006207 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.cc
+++ b/chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.cc
@@ -45,7 +45,7 @@ bool StoreManagedUserFiles(const std::string& token,
// If running on desktop, cryptohome stub does not create home directory.
base::CreateDirectory(base_path);
}
- base::FilePath token_file = base_path.Append(kManagedUserTokenFilename);
+ base::FilePath token_file = base_path.Append(kSupervisedUserTokenFilename);
int bytes = base::WriteFile(token_file, token.c_str(), token.length());
return bytes >= 0;
}
@@ -152,7 +152,7 @@ void ManagedUserCreationControllerNew::StartCreationImpl() {
creation_context_->local_user_id = manager->GenerateUserId();
if (creation_context_->creation_type == NEW_USER) {
creation_context_->sync_user_id =
- ManagedUserRegistrationUtility::GenerateNewManagedUserId();
+ SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId();
}
manager->SetCreationTransactionUserId(creation_context_->local_user_id);
@@ -263,9 +263,10 @@ void ManagedUserCreationControllerNew::OnMountSuccess(
// Plain text password, hashed and salted with individual salt.
// It can be used for mounting homedir, and can be replaced only when signed.
- cryptohome::KeyDefinition password_key(creation_context_->salted_password,
- kCryptohomeManagedUserKeyLabel,
- kCryptohomeManagedUserKeyPrivileges);
+ cryptohome::KeyDefinition password_key(
+ creation_context_->salted_password,
+ kCryptohomeSupervisedUserKeyLabel,
+ kCryptohomeSupervisedUserKeyPrivileges);
base::Base64Decode(creation_context_->encryption_key,
&password_key.encryption_key);
base::Base64Decode(creation_context_->signature_key,
@@ -304,11 +305,11 @@ void ManagedUserCreationControllerNew::OnAddKeySuccess() {
consumer_->OnLongCreationWarning();
creation_context_->registration_utility =
- ManagedUserRegistrationUtility::Create(
+ SupervisedUserRegistrationUtility::Create(
creation_context_->manager_profile);
- ManagedUserRegistrationInfo info(creation_context_->display_name,
- creation_context_->avatar_index);
+ SupervisedUserRegistrationInfo info(creation_context_->display_name,
+ creation_context_->avatar_index);
info.master_key = creation_context_->master_key;
info.password_signature_key = creation_context_->signature_key;
info.password_encryption_key = creation_context_->encryption_key;
diff --git a/chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.h b/chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.h
index 9e9d241..e899552 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.h
+++ b/chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.h
@@ -15,7 +15,7 @@
#include "base/values.h"
#include "chrome/browser/chromeos/login/auth/extended_authenticator.h"
#include "chrome/browser/chromeos/login/managed/managed_user_creation_controller.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
class Profile;
@@ -142,7 +142,7 @@ class ManagedUserCreationControllerNew
base::DictionaryValue password_data;
Profile* manager_profile;
- scoped_ptr<ManagedUserRegistrationUtility> registration_utility;
+ scoped_ptr<SupervisedUserRegistrationUtility> registration_utility;
};
// ManagedUserAuthenticator::StatusConsumer overrides.
@@ -158,7 +158,7 @@ class ManagedUserCreationControllerNew
// Guard timer callback.
void CreationTimedOut();
- // ManagedUserRegistrationUtility callback.
+ // SupervisedUserRegistrationUtility callback.
void RegistrationCallback(const GoogleServiceAuthError& error,
const std::string& token);
diff --git a/chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.cc b/chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.cc
index 88db819..5bcaa5b 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.cc
+++ b/chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.cc
@@ -43,7 +43,7 @@ bool StoreManagedUserFiles(const std::string& token,
// If running on desktop, cryptohome stub does not create home directory.
base::CreateDirectory(base_path);
}
- base::FilePath token_file = base_path.Append(kManagedUserTokenFilename);
+ base::FilePath token_file = base_path.Append(kSupervisedUserTokenFilename);
int bytes = base::WriteFile(token_file, token.c_str(), token.length());
return bytes >= 0;
}
@@ -143,7 +143,7 @@ void ManagedUserCreationControllerOld::StartCreation() {
if (creation_context_->creation_type == NEW_USER) {
creation_context_->sync_user_id =
- ManagedUserRegistrationUtility::GenerateNewManagedUserId();
+ SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId();
}
manager->CreateUserRecord(creation_context_->manager_id,
@@ -217,14 +217,14 @@ void ManagedUserCreationControllerOld::OnMountSuccess(
void ManagedUserCreationControllerOld::OnAddKeySuccess() {
creation_context_->registration_utility =
- ManagedUserRegistrationUtility::Create(
+ SupervisedUserRegistrationUtility::Create(
creation_context_->manager_profile);
VLOG(1) << "Creating user on server";
// TODO(antrim) : add password data to sync once API is ready.
// http://crbug.com/316168
- ManagedUserRegistrationInfo info(creation_context_->display_name,
- creation_context_->avatar_index);
+ SupervisedUserRegistrationInfo info(creation_context_->display_name,
+ creation_context_->avatar_index);
info.master_key = creation_context_->master_key;
timeout_timer_.Stop();
creation_context_->registration_utility->Register(
diff --git a/chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.h b/chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.h
index f31ee44..448bea6 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.h
+++ b/chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.h
@@ -15,7 +15,7 @@
#include "base/values.h"
#include "chrome/browser/chromeos/login/managed/managed_user_authenticator.h"
#include "chrome/browser/chromeos/login/managed/managed_user_creation_controller.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
class Profile;
@@ -97,7 +97,7 @@ class ManagedUserCreationControllerOld
CreationType creation_type;
base::DictionaryValue password_data;
Profile* manager_profile;
- scoped_ptr<ManagedUserRegistrationUtility> registration_utility;
+ scoped_ptr<SupervisedUserRegistrationUtility> registration_utility;
};
void StartCreation();
diff --git a/chrome/browser/chromeos/login/managed/managed_user_password_browsertest.cc b/chrome/browser/chromeos/login/managed/managed_user_password_browsertest.cc
index 238debf..161c991 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_password_browsertest.cc
+++ b/chrome/browser/chromeos/login/managed/managed_user_password_browsertest.cc
@@ -18,13 +18,13 @@
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility_stub.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility_stub.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chromeos/cryptohome/mock_async_method_caller.h"
#include "chromeos/cryptohome/mock_homedir_methods.h"
#include "content/public/browser/notification_service.h"
@@ -92,7 +92,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest,
"new-encrypted-password");
shared_settings_adapter_->AddChange(
- sync_id, managed_users::kChromeOSPasswordData, password, true, false);
+ sync_id, supervised_users::kChromeOSPasswordData, password, true, false);
content::RunAllPendingInMessageLoop();
}
@@ -154,7 +154,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest,
password.SetStringWithoutPathExpansion(kEncryptedPassword,
"new-encrypted-password");
shared_settings_adapter_->AddChange(
- sync_id, managed_users::kChromeOSPasswordData, password, true, false);
+ sync_id, supervised_users::kChromeOSPasswordData, password, true, false);
content::RunAllPendingInMessageLoop();
testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_);
@@ -203,7 +203,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest,
"new-encrypted-password");
shared_settings_adapter_->AddChange(
- sync_id, managed_users::kChromeOSPasswordData, password, true, false);
+ sync_id, supervised_users::kChromeOSPasswordData, password, true, false);
content::RunAllPendingInMessageLoop();
}
@@ -242,7 +242,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserPasswordTest,
password.SetStringWithoutPathExpansion(kEncryptedPassword,
"new-encrypted-password");
shared_settings_adapter_->AddChange(
- sync_id, managed_users::kChromeOSPasswordData, password, true, false);
+ sync_id, supervised_users::kChromeOSPasswordData, password, true, false);
content::RunAllPendingInMessageLoop();
testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_);
diff --git a/chrome/browser/chromeos/login/managed/managed_user_test_base.cc b/chrome/browser/chromeos/login/managed/managed_user_test_base.cc
index 3c445a1..22e7aaa 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_test_base.cc
+++ b/chrome/browser/chromeos/login/managed/managed_user_test_base.cc
@@ -23,14 +23,14 @@
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility_stub.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
#include "chrome/browser/profiles/profile_impl.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility_stub.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chromeos/cryptohome/mock_async_method_caller.h"
#include "chromeos/cryptohome/mock_homedir_methods.h"
#include "content/public/browser/notification_service.h"
@@ -54,7 +54,7 @@ const char kCurrentPage[] = "$('managed-user-creation').currentPage_";
ManagedUsersSyncTestAdapter::ManagedUsersSyncTestAdapter(Profile* profile)
: processor_(), next_sync_data_id_(0) {
- service_ = ManagedUserSyncServiceFactory::GetForProfile(profile);
+ service_ = SupervisedUserSyncServiceFactory::GetForProfile(profile);
processor_ = new syncer::FakeSyncChangeProcessor();
service_->MergeDataAndStartSyncing(
syncer::SUPERVISED_USERS,
@@ -103,7 +103,7 @@ ManagedUsersSharedSettingsSyncTestAdapter::
ManagedUsersSharedSettingsSyncTestAdapter(Profile* profile)
: processor_(), next_sync_data_id_(0) {
service_ =
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
processor_ = new syncer::FakeSyncChangeProcessor();
service_->MergeDataAndStartSyncing(
syncer::SUPERVISED_USER_SHARED_SETTINGS,
@@ -155,7 +155,7 @@ void ManagedUsersSharedSettingsSyncTestAdapter::AddChange(
bool acknowledged,
bool update) {
syncer::SyncData data =
- ManagedUserSharedSettingsService::CreateSyncDataForSetting(
+ SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
mu_id, key, value, acknowledged);
AddChange(data.GetSpecifics().managed_user_shared_setting(), update);
}
@@ -182,8 +182,8 @@ void ManagedUserTestBase::SetUpInProcessBrowserTestFixture() {
mock_homedir_methods_->SetUp(true, cryptohome::MOUNT_ERROR_NONE);
cryptohome::HomedirMethods::InitializeForTesting(mock_homedir_methods_);
- registration_utility_stub_ = new ManagedUserRegistrationUtilityStub();
- scoped_utility_.reset(new ScopedTestingManagedUserRegistrationUtility(
+ registration_utility_stub_ = new SupervisedUserRegistrationUtilityStub();
+ scoped_utility_.reset(new ScopedTestingSupervisedUserRegistrationUtility(
registration_utility_stub_));
// Setup network portal detector to return online state for both
diff --git a/chrome/browser/chromeos/login/managed/managed_user_test_base.h b/chrome/browser/chromeos/login/managed/managed_user_test_base.h
index de4242f..b4d6760 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_test_base.h
+++ b/chrome/browser/chromeos/login/managed/managed_user_test_base.h
@@ -9,8 +9,8 @@
#include "base/compiler_specific.h"
#include "chrome/browser/chromeos/login/login_manager_test.h"
#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility_stub.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility_stub.h"
#include "chromeos/cryptohome/mock_async_method_caller.h"
#include "chromeos/cryptohome/mock_homedir_methods.h"
#include "sync/api/fake_sync_change_processor.h"
@@ -40,7 +40,7 @@ class ManagedUsersSyncTestAdapter {
void AddChange(const ::sync_pb::ManagedUserSpecifics& proto, bool update);
syncer::FakeSyncChangeProcessor* processor_;
- ManagedUserSyncService* service_;
+ SupervisedUserSyncService* service_;
int next_sync_data_id_;
};
@@ -62,7 +62,7 @@ class ManagedUsersSharedSettingsSyncTestAdapter {
bool update);
syncer::FakeSyncChangeProcessor* processor_;
- ManagedUserSharedSettingsService* service_;
+ SupervisedUserSharedSettingsService* service_;
int next_sync_data_id_;
};
@@ -102,8 +102,8 @@ class ManagedUserTestBase : public chromeos::LoginManagerTest {
cryptohome::MockAsyncMethodCaller* mock_async_method_caller_;
cryptohome::MockHomedirMethods* mock_homedir_methods_;
NetworkPortalDetectorTestImpl* network_portal_detector_;
- ManagedUserRegistrationUtilityStub* registration_utility_stub_;
- scoped_ptr<ScopedTestingManagedUserRegistrationUtility> scoped_utility_;
+ SupervisedUserRegistrationUtilityStub* registration_utility_stub_;
+ scoped_ptr<ScopedTestingSupervisedUserRegistrationUtility> scoped_utility_;
scoped_ptr<ManagedUsersSharedSettingsSyncTestAdapter>
shared_settings_adapter_;
scoped_ptr<ManagedUsersSyncTestAdapter> managed_users_adapter_;
diff --git a/chrome/browser/chromeos/login/managed/supervised_user_authentication.cc b/chrome/browser/chromeos/login/managed/supervised_user_authentication.cc
index ebec8a46..968bc18 100644
--- a/chrome/browser/chromeos/login/managed/supervised_user_authentication.cc
+++ b/chrome/browser/chromeos/login/managed/supervised_user_authentication.cc
@@ -116,7 +116,7 @@ UserContext SupervisedUserAuthentication::TransformKey(
DCHECK(!salt.empty());
Key* const key = result.GetKey();
key->Transform(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, salt);
- key->SetLabel(kCryptohomeManagedUserKeyLabel);
+ key->SetLabel(kCryptohomeSupervisedUserKeyLabel);
result.SetIsUsingOAuth(false);
return result;
}
diff --git a/chrome/browser/chromeos/login/managed/supervised_user_login_flow.cc b/chrome/browser/chromeos/login/managed/supervised_user_login_flow.cc
index 65a4485..3b056f5 100644
--- a/chrome/browser/chromeos/login/managed/supervised_user_login_flow.cc
+++ b/chrome/browser/chromeos/login/managed/supervised_user_login_flow.cc
@@ -132,8 +132,8 @@ void SupervisedUserLoginFlow::OnPasswordChangeDataLoaded(
base::Base64Decode(base64_signature, &signature);
scoped_ptr<base::DictionaryValue> data_copy(password_data->DeepCopy());
cryptohome::KeyDefinition key(password,
- kCryptohomeManagedUserKeyLabel,
- kCryptohomeManagedUserKeyPrivileges);
+ kCryptohomeSupervisedUserKeyLabel,
+ kCryptohomeSupervisedUserKeyPrivileges);
authenticator_ = new ExtendedAuthenticator(this);
SupervisedUserAuthentication::Schema current_schema =
@@ -144,7 +144,7 @@ void SupervisedUserLoginFlow::OnPasswordChangeDataLoaded(
if (SupervisedUserAuthentication::SCHEMA_PLAIN == current_schema) {
// We need to add new key, and block old one. As we don't actually have
// signature key, use Migrate privilege instead of AuthorizedUpdate.
- key.privileges = kCryptohomeManagedUserIncompleteKeyPrivileges;
+ key.privileges = kCryptohomeSupervisedUserIncompleteKeyPrivileges;
VLOG(1) << "Adding new schema key";
DCHECK(context_.GetKey()->GetLabel().empty());
@@ -160,10 +160,10 @@ void SupervisedUserLoginFlow::OnPasswordChangeDataLoaded(
if (auth->HasIncompleteKey(user_id())) {
// We need to use Migrate instead of Authorized Update privilege.
- key.privileges = kCryptohomeManagedUserIncompleteKeyPrivileges;
+ key.privileges = kCryptohomeSupervisedUserIncompleteKeyPrivileges;
}
// Just update the key.
- DCHECK_EQ(context_.GetKey()->GetLabel(), kCryptohomeManagedUserKeyLabel);
+ DCHECK_EQ(context_.GetKey()->GetLabel(), kCryptohomeSupervisedUserKeyLabel);
authenticator_->UpdateKeyAuthorized(
context_,
key,
@@ -185,7 +185,7 @@ void SupervisedUserLoginFlow::OnNewKeyAdded(
auth->MarkKeyIncomplete(user_id(), true /* incomplete */);
authenticator_->RemoveKey(
context_,
- kLegacyCryptohomeManagedUserKeyLabel,
+ kLegacyCryptohomeSupervisedUserKeyLabel,
base::Bind(&SupervisedUserLoginFlow::OnOldKeyRemoved,
weak_factory_.GetWeakPtr()));
}
diff --git a/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc b/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc
index b682e82..531e9b2 100644
--- a/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc
@@ -19,8 +19,8 @@
#include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h"
#include "chrome/browser/chromeos/login/users/user_manager_impl.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chromeos/settings/cros_settings_names.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/gaia/gaia_auth_util.h"
@@ -31,19 +31,19 @@ namespace {
// Names for pref keys in Local State.
// A map from locally managed user local user id to sync user id.
-const char kManagedUserSyncId[] =
+const char kSupervisedUserSyncId[] =
"ManagedUserSyncId";
// A map from locally managed user id to manager user id.
-const char kManagedUserManagers[] =
+const char kSupervisedUserManagers[] =
"ManagedUserManagers";
// A map from locally managed user id to manager display name.
-const char kManagedUserManagerNames[] =
+const char kSupervisedUserManagerNames[] =
"ManagedUserManagerNames";
// A map from locally managed user id to manager display e-mail.
-const char kManagedUserManagerDisplayEmails[] =
+const char kSupervisedUserManagerDisplayEmails[] =
"ManagedUserManagerDisplayEmails";
// A vector pref of the locally managed accounts defined on this device, that
@@ -86,7 +86,7 @@ const char kSupervisedUserIncompleteKey[] = "SupervisedUserHasIncompleteKey";
std::string LoadSyncToken(base::FilePath profile_dir) {
std::string token;
base::FilePath token_file =
- profile_dir.Append(chromeos::kManagedUserTokenFilename);
+ profile_dir.Append(chromeos::kSupervisedUserTokenFilename);
VLOG(1) << "Loading" << token_file.value();
if (!base::ReadFileToString(token_file, &token))
return std::string();
@@ -118,10 +118,10 @@ void SupervisedUserManager::RegisterPrefs(PrefRegistrySimple* registry) {
kLocallyManagedUserCreationTransactionDisplayName, "");
registry->RegisterStringPref(
kLocallyManagedUserCreationTransactionUserId, "");
- registry->RegisterDictionaryPref(kManagedUserSyncId);
- registry->RegisterDictionaryPref(kManagedUserManagers);
- registry->RegisterDictionaryPref(kManagedUserManagerNames);
- registry->RegisterDictionaryPref(kManagedUserManagerDisplayEmails);
+ registry->RegisterDictionaryPref(kSupervisedUserSyncId);
+ registry->RegisterDictionaryPref(kSupervisedUserManagers);
+ registry->RegisterDictionaryPref(kSupervisedUserManagerNames);
+ registry->RegisterDictionaryPref(kSupervisedUserManagerDisplayEmails);
registry->RegisterDictionaryPref(kSupervisedUserPasswordSchema);
registry->RegisterDictionaryPref(kSupervisedUserPasswordSalt);
@@ -197,12 +197,13 @@ const User* SupervisedUserManagerImpl::CreateUserRecord(
ListPrefUpdate prefs_new_users_update(local_state,
kLocallyManagedUsersFirstRun);
- DictionaryPrefUpdate sync_id_update(local_state, kManagedUserSyncId);
- DictionaryPrefUpdate manager_update(local_state, kManagedUserManagers);
+ DictionaryPrefUpdate sync_id_update(local_state, kSupervisedUserSyncId);
+ DictionaryPrefUpdate manager_update(local_state, kSupervisedUserManagers);
DictionaryPrefUpdate manager_name_update(local_state,
- kManagedUserManagerNames);
- DictionaryPrefUpdate manager_email_update(local_state,
- kManagedUserManagerDisplayEmails);
+ kSupervisedUserManagerNames);
+ DictionaryPrefUpdate manager_email_update(
+ local_state,
+ kSupervisedUserManagerDisplayEmails);
prefs_new_users_update->Insert(0, new base::StringValue(local_user_id));
@@ -224,7 +225,7 @@ const User* SupervisedUserManagerImpl::CreateUserRecord(
std::string SupervisedUserManagerImpl::GetUserSyncId(const std::string& user_id)
const {
std::string result;
- GetUserStringValue(user_id, kManagedUserSyncId, &result);
+ GetUserStringValue(user_id, kSupervisedUserSyncId, &result);
return result;
}
@@ -232,7 +233,7 @@ base::string16 SupervisedUserManagerImpl::GetManagerDisplayName(
const std::string& user_id) const {
PrefService* local_state = g_browser_process->local_state();
const base::DictionaryValue* manager_names =
- local_state->GetDictionary(kManagedUserManagerNames);
+ local_state->GetDictionary(kSupervisedUserManagerNames);
base::string16 result;
if (manager_names->GetStringWithoutPathExpansion(user_id, &result) &&
!result.empty())
@@ -243,14 +244,16 @@ base::string16 SupervisedUserManagerImpl::GetManagerDisplayName(
std::string SupervisedUserManagerImpl::GetManagerUserId(
const std::string& user_id) const {
std::string result;
- GetUserStringValue(user_id, kManagedUserManagers, &result);
+ GetUserStringValue(user_id, kSupervisedUserManagers, &result);
return result;
}
std::string SupervisedUserManagerImpl::GetManagerDisplayEmail(
const std::string& user_id) const {
std::string result;
- if (GetUserStringValue(user_id, kManagedUserManagerDisplayEmails, &result) &&
+ if (GetUserStringValue(user_id,
+ kSupervisedUserManagerDisplayEmails,
+ &result) &&
!result.empty())
return result;
return GetManagerUserId(user_id);
@@ -447,10 +450,10 @@ void SupervisedUserManagerImpl::RemoveNonCryptohomeData(
ListPrefUpdate prefs_new_users_update(prefs, kLocallyManagedUsersFirstRun);
prefs_new_users_update->Remove(base::StringValue(user_id), NULL);
- CleanPref(user_id, kManagedUserSyncId);
- CleanPref(user_id, kManagedUserManagers);
- CleanPref(user_id, kManagedUserManagerNames);
- CleanPref(user_id, kManagedUserManagerDisplayEmails);
+ CleanPref(user_id, kSupervisedUserSyncId);
+ CleanPref(user_id, kSupervisedUserManagers);
+ CleanPref(user_id, kSupervisedUserManagerNames);
+ CleanPref(user_id, kSupervisedUserManagerDisplayEmails);
CleanPref(user_id, kSupervisedUserPasswordSalt);
CleanPref(user_id, kSupervisedUserPasswordSchema);
CleanPref(user_id, kSupervisedUserPasswordRevision);
@@ -476,10 +479,10 @@ void SupervisedUserManagerImpl::UpdateManagerName(const std::string& manager_id,
PrefService* local_state = g_browser_process->local_state();
const base::DictionaryValue* manager_ids =
- local_state->GetDictionary(kManagedUserManagers);
+ local_state->GetDictionary(kSupervisedUserManagers);
DictionaryPrefUpdate manager_name_update(local_state,
- kManagedUserManagerNames);
+ kSupervisedUserManagerNames);
for (base::DictionaryValue::Iterator it(*manager_ids); !it.IsAtEnd();
it.Advance()) {
std::string user_id;
@@ -514,7 +517,7 @@ void SupervisedUserManagerImpl::ConfigureSyncWithToken(
Profile* profile,
const std::string& token) {
if (!token.empty())
- ManagedUserServiceFactory::GetForProfile(profile)->InitSync(token);
+ SupervisedUserServiceFactory::GetForProfile(profile)->InitSync(token);
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/users/user.h b/chrome/browser/chromeos/login/users/user.h
index 132e7f6..a47c677 100644
--- a/chrome/browser/chromeos/login/users/user.h
+++ b/chrome/browser/chromeos/login/users/user.h
@@ -39,7 +39,8 @@ class User : public ash::UserInfo {
// Public account user, logs in without authentication. Available only if
// enabled through policy.
USER_TYPE_PUBLIC_ACCOUNT = 3,
- // Locally managed user, logs in only with local authentication.
+ // Supervised (aka locally managed) user, logs in only with local
+ // authentication.
USER_TYPE_LOCALLY_MANAGED = 4,
// Kiosk app robot, logs in without authentication.
USER_TYPE_KIOSK_APP = 5,
diff --git a/chrome/browser/chromeos/login/users/user_manager_impl.cc b/chrome/browser/chromeos/login/users/user_manager_impl.cc
index 881fc10..0058b66 100644
--- a/chrome/browser/chromeos/login/users/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/users/user_manager_impl.cc
@@ -52,12 +52,12 @@
#include "chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/session_length_limiter.h"
-#include "chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.h"
-#include "chrome/browser/managed_mode/chromeos/manager_password_service_factory.h"
#include "chrome/browser/net/nss_context.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profiles_state.h"
+#include "chrome/browser/supervised_user/chromeos/manager_password_service_factory.h"
+#include "chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/chrome_constants.h"
@@ -942,7 +942,7 @@ void UserManagerImpl::Observe(int type,
!IsLoggedInAsGuest() &&
!IsLoggedInAsKioskApp()) {
if (IsLoggedInAsLocallyManagedUser())
- ManagedUserPasswordServiceFactory::GetForProfile(profile);
+ SupervisedUserPasswordServiceFactory::GetForProfile(profile);
if (IsLoggedInAsRegularUser())
ManagerPasswordServiceFactory::GetForProfile(profile);
diff --git a/chrome/browser/extensions/webstore_startup_installer_browsertest.cc b/chrome/browser/extensions/webstore_startup_installer_browsertest.cc
index d89d9a7..d57b066 100644
--- a/chrome/browser/extensions/webstore_startup_installer_browsertest.cc
+++ b/chrome/browser/extensions/webstore_startup_installer_browsertest.cc
@@ -9,8 +9,6 @@
#include "chrome/browser/extensions/startup_helper.h"
#include "chrome/browser/extensions/webstore_installer_test.h"
#include "chrome/browser/infobars/infobar_service.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
diff --git a/chrome/browser/managed_mode/chromeos/managed_user_password_service.h b/chrome/browser/managed_mode/chromeos/managed_user_password_service.h
deleted file mode 100644
index 165332c..0000000
--- a/chrome/browser/managed_mode/chromeos/managed_user_password_service.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGED_USER_PASSWORD_SERVICE_H_
-#define CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGED_USER_PASSWORD_SERVICE_H_
-
-#include <string>
-
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_users.h"
-#include "components/keyed_service/core/keyed_service.h"
-
-namespace chromeos {
-
-class ManagedUserPasswordService : public KeyedService {
- public:
- ManagedUserPasswordService();
- virtual ~ManagedUserPasswordService();
-
- virtual void Shutdown() OVERRIDE;
-
- void Init(const std::string& user_id,
- ManagedUserSharedSettingsService* service);
- private:
- void OnSharedSettingsChange(const std::string& mu_id, const std::string& key);
-
- // Cached value from Init().
- // User id of currently logged in managed user.
- std::string user_id_;
- ManagedUserSharedSettingsService* settings_service_;
-
- scoped_ptr<ManagedUserSharedSettingsService::ChangeCallbackList::Subscription>
- settings_service_subscription_;
-
- base::WeakPtrFactory<ManagedUserPasswordService> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(ManagedUserPasswordService);
-};
-
-} // namespace chromeos
-#endif // CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGED_USER_PASSWORD_SERVICE_H_
diff --git a/chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.h b/chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.h
deleted file mode 100644
index 1c14dd8..0000000
--- a/chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGED_USER_PASSWORD_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGED_USER_PASSWORD_SERVICE_FACTORY_H_
-
-#include "base/memory/singleton.h"
-#include "chrome/browser/managed_mode/managed_users.h"
-#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
-
-class Profile;
-
-namespace chromeos {
-
-class ManagedUserPasswordService;
-
-class ManagedUserPasswordServiceFactory
- : public BrowserContextKeyedServiceFactory {
- public:
- static ManagedUserPasswordService* GetForProfile(Profile* profile);
-
- static ManagedUserPasswordServiceFactory* GetInstance();
-
- private:
- friend struct DefaultSingletonTraits<ManagedUserPasswordServiceFactory>;
-
- ManagedUserPasswordServiceFactory();
- virtual ~ManagedUserPasswordServiceFactory();
-
- // BrowserContextKeyedServiceFactory:
- virtual KeyedService* BuildServiceInstanceFor(
- content::BrowserContext* profile) const OVERRIDE;
- virtual content::BrowserContext* GetBrowserContextToUse(
- content::BrowserContext* context) const OVERRIDE;
-};
-
-} // namespace chromeos
-#endif // CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGED_USER_PASSWORD_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/managed_mode_resource_throttle.cc b/chrome/browser/managed_mode/managed_mode_resource_throttle.cc
deleted file mode 100644
index 001508d..0000000
--- a/chrome/browser/managed_mode/managed_mode_resource_throttle.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/managed_mode/managed_mode_resource_throttle.h"
-
-#include "base/bind.h"
-#include "chrome/browser/managed_mode/managed_mode_interstitial.h"
-#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/resource_controller.h"
-#include "content/public/browser/resource_request_info.h"
-#include "net/url_request/url_request.h"
-
-using content::BrowserThread;
-
-ManagedModeResourceThrottle::ManagedModeResourceThrottle(
- const net::URLRequest* request,
- bool is_main_frame,
- const ManagedModeURLFilter* url_filter)
- : request_(request),
- is_main_frame_(is_main_frame),
- url_filter_(url_filter),
- weak_ptr_factory_(this) {}
-
-ManagedModeResourceThrottle::~ManagedModeResourceThrottle() {}
-
-void ManagedModeResourceThrottle::ShowInterstitialIfNeeded(bool is_redirect,
- const GURL& url,
- bool* defer) {
- // Only treat main frame requests for now (ignoring subresources).
- if (!is_main_frame_)
- return;
-
- if (url_filter_->GetFilteringBehaviorForURL(url) !=
- ManagedModeURLFilter::BLOCK) {
- return;
- }
-
- *defer = true;
- const content::ResourceRequestInfo* info =
- content::ResourceRequestInfo::ForRequest(request_);
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&ManagedModeNavigationObserver::OnRequestBlocked,
- info->GetChildID(), info->GetRouteID(), url,
- base::Bind(&ManagedModeResourceThrottle::OnInterstitialResult,
- weak_ptr_factory_.GetWeakPtr())));
-}
-
-void ManagedModeResourceThrottle::WillStartRequest(bool* defer) {
- ShowInterstitialIfNeeded(false, request_->url(), defer);
-}
-
-void ManagedModeResourceThrottle::WillRedirectRequest(const GURL& new_url,
- bool* defer) {
- ShowInterstitialIfNeeded(true, new_url, defer);
-}
-
-const char* ManagedModeResourceThrottle::GetNameForLogging() const {
- return "ManagedModeResourceThrottle";
-}
-
-void ManagedModeResourceThrottle::OnInterstitialResult(bool continue_request) {
- if (continue_request)
- controller()->Resume();
- else
- controller()->Cancel();
-}
diff --git a/chrome/browser/managed_mode/managed_mode_resource_throttle.h b/chrome/browser/managed_mode/managed_mode_resource_throttle.h
deleted file mode 100644
index 6cd17ee..0000000
--- a/chrome/browser/managed_mode/managed_mode_resource_throttle.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_RESOURCE_THROTTLE_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_RESOURCE_THROTTLE_H_
-
-#include "base/compiler_specific.h"
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/managed_mode/managed_users.h"
-#include "content/public/browser/resource_throttle.h"
-
-class ManagedModeURLFilter;
-
-namespace net {
-class URLRequest;
-}
-
-class ManagedModeResourceThrottle : public content::ResourceThrottle {
- public:
- ManagedModeResourceThrottle(const net::URLRequest* request,
- bool is_main_frame,
- const ManagedModeURLFilter* url_filter);
- virtual ~ManagedModeResourceThrottle();
-
- // content::ResourceThrottle implementation:
- virtual void WillStartRequest(bool* defer) OVERRIDE;
-
- virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE;
-
- virtual const char* GetNameForLogging() const OVERRIDE;
-
- private:
- void ShowInterstitialIfNeeded(bool is_redirect,
- const GURL& url,
- bool* defer);
- void OnInterstitialResult(bool continue_request);
-
- const net::URLRequest* request_;
- bool is_main_frame_;
- const ManagedModeURLFilter* url_filter_;
- base::WeakPtrFactory<ManagedModeResourceThrottle> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(ManagedModeResourceThrottle);
-};
-
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_RESOURCE_THROTTLE_H_
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility.cc b/chrome/browser/managed_mode/managed_user_registration_utility.cc
deleted file mode 100644
index 6d2d8e1..0000000
--- a/chrome/browser/managed_mode/managed_user_registration_utility.cc
+++ /dev/null
@@ -1,402 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
-
-#include "base/base64.h"
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/prefs/pref_service.h"
-#include "base/rand_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_update.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/sync/glue/device_info.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
-#include "components/signin/core/browser/signin_manager.h"
-#include "google_apis/gaia/gaia_urls.h"
-#include "google_apis/gaia/google_service_auth_error.h"
-
-using base::DictionaryValue;
-
-namespace {
-
-ManagedUserRegistrationUtility* g_instance_for_tests = NULL;
-
-// Actual implementation of ManagedUserRegistrationUtility.
-class ManagedUserRegistrationUtilityImpl
- : public ManagedUserRegistrationUtility,
- public ManagedUserSyncServiceObserver {
- public:
- ManagedUserRegistrationUtilityImpl(
- PrefService* prefs,
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher,
- ManagedUserSyncService* service,
- ManagedUserSharedSettingsService* shared_settings_service);
-
- virtual ~ManagedUserRegistrationUtilityImpl();
-
- // Registers a new managed user with the server. |managed_user_id| is a new
- // unique ID for the new managed user. If its value is the same as that of
- // of one of the existing managed users, then the same user will be created
- // on this machine (and if he has no avatar in sync, his avatar will
- // be updated). |info| contains necessary information like
- // the display name of the user and his avatar. |callback| is called
- // with the result of the registration. We use the info here and not the
- // profile, because on Chrome OS the profile of the managed user does not
- // yet exist.
- virtual void Register(const std::string& managed_user_id,
- const ManagedUserRegistrationInfo& info,
- const RegistrationCallback& callback) OVERRIDE;
-
- // ManagedUserSyncServiceObserver:
- virtual void OnManagedUserAcknowledged(const std::string& managed_user_id)
- OVERRIDE;
- virtual void OnManagedUsersSyncingStopped() OVERRIDE;
- virtual void OnManagedUsersChanged() OVERRIDE;
-
- private:
- // Fetches the managed user token when we have the device name.
- void FetchToken(const std::string& client_name);
-
- // Called when we have received a token for the managed user.
- void OnReceivedToken(const GoogleServiceAuthError& error,
- const std::string& token);
-
- // Dispatches the callback and cleans up if all the conditions have been met.
- void CompleteRegistrationIfReady();
-
- // Aborts any registration currently in progress. If |run_callback| is true,
- // calls the callback specified in Register() with the given |error|.
- void AbortPendingRegistration(bool run_callback,
- const GoogleServiceAuthError& error);
-
- // If |run_callback| is true, dispatches the callback with the saved token
- // (which may be empty) and the given |error|. In any case, resets internal
- // variables to be ready for the next registration.
- void CompleteRegistration(bool run_callback,
- const GoogleServiceAuthError& error);
-
- // Cancels any registration currently in progress, without calling the
- // callback or reporting an error.
- void CancelPendingRegistration();
-
- // ManagedUserSharedSettingsUpdate acknowledgment callback for password data
- // in shared settings.
- void OnPasswordChangeAcknowledged(bool success);
-
- PrefService* prefs_;
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher_;
-
- // A |KeyedService| owned by the custodian profile.
- ManagedUserSyncService* managed_user_sync_service_;
-
- // A |KeyedService| owned by the custodian profile.
- ManagedUserSharedSettingsService* managed_user_shared_settings_service_;
-
- std::string pending_managed_user_id_;
- std::string pending_managed_user_token_;
- bool pending_managed_user_acknowledged_;
- bool is_existing_managed_user_;
- bool avatar_updated_;
- RegistrationCallback callback_;
- scoped_ptr<ManagedUserSharedSettingsUpdate> password_update_;
-
- base::WeakPtrFactory<ManagedUserRegistrationUtilityImpl> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationUtilityImpl);
-};
-
-} // namespace
-
-ManagedUserRegistrationInfo::ManagedUserRegistrationInfo(
- const base::string16& name,
- int avatar_index)
- : avatar_index(avatar_index),
- name(name) {
-}
-
-ManagedUserRegistrationInfo::~ManagedUserRegistrationInfo() {}
-
-ScopedTestingManagedUserRegistrationUtility::
- ScopedTestingManagedUserRegistrationUtility(
- ManagedUserRegistrationUtility* instance) {
- ManagedUserRegistrationUtility::SetUtilityForTests(instance);
-}
-
-ScopedTestingManagedUserRegistrationUtility::
- ~ScopedTestingManagedUserRegistrationUtility() {
- ManagedUserRegistrationUtility::SetUtilityForTests(NULL);
-}
-
-// static
-scoped_ptr<ManagedUserRegistrationUtility>
-ManagedUserRegistrationUtility::Create(Profile* profile) {
- if (g_instance_for_tests) {
- ManagedUserRegistrationUtility* result = g_instance_for_tests;
- g_instance_for_tests = NULL;
- return make_scoped_ptr(result);
- }
-
- ProfileOAuth2TokenService* token_service =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
- SigninManagerBase* signin_manager =
- SigninManagerFactory::GetForProfile(profile);
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher =
- ManagedUserRefreshTokenFetcher::Create(
- token_service,
- signin_manager->GetAuthenticatedAccountId(),
- profile->GetRequestContext());
- ManagedUserSyncService* managed_user_sync_service =
- ManagedUserSyncServiceFactory::GetForProfile(profile);
- ManagedUserSharedSettingsService* managed_user_shared_settings_service =
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
- return make_scoped_ptr(ManagedUserRegistrationUtility::CreateImpl(
- profile->GetPrefs(),
- token_fetcher.Pass(),
- managed_user_sync_service,
- managed_user_shared_settings_service));
-}
-
-// static
-std::string ManagedUserRegistrationUtility::GenerateNewManagedUserId() {
- std::string new_managed_user_id;
- base::Base64Encode(base::RandBytesAsString(8), &new_managed_user_id);
- return new_managed_user_id;
-}
-
-// static
-void ManagedUserRegistrationUtility::SetUtilityForTests(
- ManagedUserRegistrationUtility* utility) {
- if (g_instance_for_tests)
- delete g_instance_for_tests;
- g_instance_for_tests = utility;
-}
-
-// static
-ManagedUserRegistrationUtility* ManagedUserRegistrationUtility::CreateImpl(
- PrefService* prefs,
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher,
- ManagedUserSyncService* service,
- ManagedUserSharedSettingsService* shared_settings_service) {
- return new ManagedUserRegistrationUtilityImpl(prefs,
- token_fetcher.Pass(),
- service,
- shared_settings_service);
-}
-
-namespace {
-
-ManagedUserRegistrationUtilityImpl::ManagedUserRegistrationUtilityImpl(
- PrefService* prefs,
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher,
- ManagedUserSyncService* service,
- ManagedUserSharedSettingsService* shared_settings_service)
- : prefs_(prefs),
- token_fetcher_(token_fetcher.Pass()),
- managed_user_sync_service_(service),
- managed_user_shared_settings_service_(shared_settings_service),
- pending_managed_user_acknowledged_(false),
- is_existing_managed_user_(false),
- avatar_updated_(false),
- weak_ptr_factory_(this) {
- managed_user_sync_service_->AddObserver(this);
-}
-
-ManagedUserRegistrationUtilityImpl::~ManagedUserRegistrationUtilityImpl() {
- managed_user_sync_service_->RemoveObserver(this);
- CancelPendingRegistration();
-}
-
-void ManagedUserRegistrationUtilityImpl::Register(
- const std::string& managed_user_id,
- const ManagedUserRegistrationInfo& info,
- const RegistrationCallback& callback) {
- DCHECK(pending_managed_user_id_.empty());
- callback_ = callback;
- pending_managed_user_id_ = managed_user_id;
-
- bool need_password_update = !info.password_data.empty();
- const base::DictionaryValue* dict =
- prefs_->GetDictionary(prefs::kSupervisedUsers);
- is_existing_managed_user_ = dict->HasKey(managed_user_id);
- if (!is_existing_managed_user_) {
- managed_user_sync_service_->AddManagedUser(pending_managed_user_id_,
- base::UTF16ToUTF8(info.name),
- info.master_key,
- info.password_signature_key,
- info.password_encryption_key,
- info.avatar_index);
- } else {
- const base::DictionaryValue* value = NULL;
- bool success =
- dict->GetDictionaryWithoutPathExpansion(managed_user_id, &value);
- DCHECK(success);
- std::string key;
- bool need_keys = !info.password_signature_key.empty() ||
- !info.password_encryption_key.empty();
- bool have_keys =
- value->GetString(ManagedUserSyncService::kPasswordSignatureKey, &key) &&
- !key.empty() &&
- value->GetString(ManagedUserSyncService::kPasswordEncryptionKey,
- &key) &&
- !key.empty();
-
- bool keys_need_update = need_keys && !have_keys;
-
- if (keys_need_update) {
- managed_user_sync_service_->UpdateManagedUser(
- pending_managed_user_id_,
- base::UTF16ToUTF8(info.name),
- info.master_key,
- info.password_signature_key,
- info.password_encryption_key,
- info.avatar_index);
- } else {
- // The user already exists and does not need to be updated.
- need_password_update = false;
- OnManagedUserAcknowledged(managed_user_id);
- }
- avatar_updated_ =
- managed_user_sync_service_->UpdateManagedUserAvatarIfNeeded(
- managed_user_id,
- info.avatar_index);
- }
-#if defined(OS_CHROMEOS)
- const char* kAvatarKey = managed_users::kChromeOSAvatarIndex;
-#else
- const char* kAvatarKey = managed_users::kChromeAvatarIndex;
-#endif
- managed_user_shared_settings_service_->SetValue(
- pending_managed_user_id_, kAvatarKey,
- base::FundamentalValue(info.avatar_index));
- if (need_password_update) {
- password_update_.reset(new ManagedUserSharedSettingsUpdate(
- managed_user_shared_settings_service_,
- pending_managed_user_id_,
- managed_users::kChromeOSPasswordData,
- scoped_ptr<base::Value>(info.password_data.DeepCopy()),
- base::Bind(
- &ManagedUserRegistrationUtilityImpl::OnPasswordChangeAcknowledged,
- weak_ptr_factory_.GetWeakPtr())));
- }
-
- browser_sync::DeviceInfo::GetClientName(
- base::Bind(&ManagedUserRegistrationUtilityImpl::FetchToken,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void ManagedUserRegistrationUtilityImpl::CancelPendingRegistration() {
- AbortPendingRegistration(
- false, // Don't run the callback. The error will be ignored.
- GoogleServiceAuthError(GoogleServiceAuthError::NONE));
-}
-
-void ManagedUserRegistrationUtilityImpl::OnManagedUserAcknowledged(
- const std::string& managed_user_id) {
- DCHECK_EQ(pending_managed_user_id_, managed_user_id);
- DCHECK(!pending_managed_user_acknowledged_);
- pending_managed_user_acknowledged_ = true;
- CompleteRegistrationIfReady();
-}
-
-void ManagedUserRegistrationUtilityImpl::OnPasswordChangeAcknowledged(
- bool success) {
- DCHECK(password_update_);
- DCHECK(success);
- password_update_.reset();
- CompleteRegistrationIfReady();
-}
-
-void ManagedUserRegistrationUtilityImpl::OnManagedUsersSyncingStopped() {
- AbortPendingRegistration(
- true, // Run the callback.
- GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED));
-}
-
-void ManagedUserRegistrationUtilityImpl::OnManagedUsersChanged() {}
-
-void ManagedUserRegistrationUtilityImpl::FetchToken(
- const std::string& client_name) {
- token_fetcher_->Start(
- pending_managed_user_id_, client_name,
- base::Bind(&ManagedUserRegistrationUtilityImpl::OnReceivedToken,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void ManagedUserRegistrationUtilityImpl::OnReceivedToken(
- const GoogleServiceAuthError& error,
- const std::string& token) {
- if (error.state() != GoogleServiceAuthError::NONE) {
- CompleteRegistration(true, error);
- return;
- }
-
- DCHECK(!token.empty());
- pending_managed_user_token_ = token;
- CompleteRegistrationIfReady();
-}
-
-void ManagedUserRegistrationUtilityImpl::CompleteRegistrationIfReady() {
- bool skip_check = CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kNoSupervisedUserAcknowledgmentCheck);
-
- if (!pending_managed_user_acknowledged_ && !skip_check)
- return;
- if (password_update_ && !skip_check)
- return;
- if (pending_managed_user_token_.empty())
- return;
-
- GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
- CompleteRegistration(true, error);
-}
-
-void ManagedUserRegistrationUtilityImpl::AbortPendingRegistration(
- bool run_callback,
- const GoogleServiceAuthError& error) {
- pending_managed_user_token_.clear();
- CompleteRegistration(run_callback, error);
-}
-
-void ManagedUserRegistrationUtilityImpl::CompleteRegistration(
- bool run_callback,
- const GoogleServiceAuthError& error) {
- if (callback_.is_null())
- return;
-
- if (pending_managed_user_token_.empty()) {
- DCHECK(!pending_managed_user_id_.empty());
-
- if (!is_existing_managed_user_) {
- // Remove the pending managed user if we weren't successful.
- // However, check that we are not importing a managed user
- // before deleting it from sync to avoid accidental deletion of
- // existing managed users by just canceling the registration for example.
- managed_user_sync_service_->DeleteManagedUser(pending_managed_user_id_);
- } else if (avatar_updated_) {
- // Canceling (or failing) a managed user import that did set the avatar
- // should undo this change.
- managed_user_sync_service_->ClearManagedUserAvatar(
- pending_managed_user_id_);
- }
- }
-
- if (run_callback)
- callback_.Run(error, pending_managed_user_token_);
- callback_.Reset();
-}
-
-} // namespace
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility.h b/chrome/browser/managed_mode/managed_user_registration_utility.h
deleted file mode 100644
index 98c9f54..0000000
--- a/chrome/browser/managed_mode/managed_user_registration_utility.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_H_
-
-#include <map>
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/weak_ptr.h"
-#include "base/prefs/pref_change_registrar.h"
-#include "base/strings/string16.h"
-#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_observer.h"
-#include "chrome/browser/managed_mode/managed_users.h"
-#include "components/keyed_service/core/keyed_service.h"
-
-class GoogleServiceAuthError;
-class ManagedUserRefreshTokenFetcher;
-class ManagedUserRegistrationUtilityTest;
-class ManagedUserSharedSettingsService;
-class PrefService;
-class Profile;
-
-namespace browser_sync {
-class DeviceInfo;
-}
-
-// Structure to store registration information.
-struct ManagedUserRegistrationInfo {
- ManagedUserRegistrationInfo(const base::string16& name, int avatar_index);
- ~ManagedUserRegistrationInfo();
- int avatar_index;
- base::string16 name;
- std::string master_key;
- std::string password_signature_key;
- std::string password_encryption_key;
- base::DictionaryValue password_data;
-};
-
-// Holds the state necessary for registering a new managed user with the
-// management server and associating it with its custodian. Each instance
-// of this class handles registering a single managed user and should not
-// be used afterwards.
-class ManagedUserRegistrationUtility {
- public:
- // Callback for Register() below. If registration is successful, |token| will
- // contain an OAuth2 refresh token for the newly registered managed user,
- // otherwise |token| will be empty and |error| will contain the authentication
- // error for the custodian.
- typedef base::Callback<void(const GoogleServiceAuthError& /* error */,
- const std::string& /* token */)>
- RegistrationCallback;
-
- virtual ~ManagedUserRegistrationUtility() {}
-
- // Creates ManagedUserRegistrationUtility for a given |profile|.
- static scoped_ptr<ManagedUserRegistrationUtility> Create(Profile* profile);
-
- static std::string GenerateNewManagedUserId();
-
- // Registers a new managed user with the server. |managed_user_id| is a new
- // unique ID for the new managed user. If its value is the same as that of
- // of one of the existing managed users, then the same user will be created
- // on this machine (and if he has no avatar in sync, his avatar will
- // be updated). |info| contains necessary information like
- // the display name of the user and his avatar. |callback| is called
- // with the result of the registration. We use the info here and not the
- // profile, because on Chrome OS the profile of the managed user does not
- // yet exist.
- virtual void Register(const std::string& managed_user_id,
- const ManagedUserRegistrationInfo& info,
- const RegistrationCallback& callback) = 0;
-
- protected:
- ManagedUserRegistrationUtility() {}
-
- private:
- friend class ScopedTestingManagedUserRegistrationUtility;
- friend class ManagedUserRegistrationUtilityTest;
-
- // Creates implementation with explicit dependencies, can be used for testing.
- static ManagedUserRegistrationUtility* CreateImpl(
- PrefService* prefs,
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher,
- ManagedUserSyncService* service,
- ManagedUserSharedSettingsService* shared_settings_service);
-
- // Set the instance of ManagedUserRegistrationUtility that will be returned
- // by next Create() call. Takes ownership of the |utility|.
- static void SetUtilityForTests(ManagedUserRegistrationUtility* utility);
-};
-
-// Class that sets the instance of ManagedUserRegistrationUtility that will be
-// returned by next Create() call, and correctly destroys it if Create() was
-// not called.
-class ScopedTestingManagedUserRegistrationUtility {
- public:
- // Delegates ownership of the |instance| to ManagedUserRegistrationUtility.
- ScopedTestingManagedUserRegistrationUtility(
- ManagedUserRegistrationUtility* instance);
-
- ~ScopedTestingManagedUserRegistrationUtility();
-};
-
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_H_
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility_stub.h b/chrome/browser/managed_mode/managed_user_registration_utility_stub.h
deleted file mode 100644
index b1880f4..0000000
--- a/chrome/browser/managed_mode/managed_user_registration_utility_stub.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_STUB_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_STUB_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/strings/string16.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
-#include "google_apis/gaia/google_service_auth_error.h"
-
-class ManagedUserRegistrationUtilityStub
- : public ManagedUserRegistrationUtility {
- public:
- ManagedUserRegistrationUtilityStub();
- virtual ~ManagedUserRegistrationUtilityStub();
-
- virtual void Register(const std::string& managed_user_id,
- const ManagedUserRegistrationInfo& info,
- const RegistrationCallback& callback) OVERRIDE;
-
- bool register_was_called() { return register_was_called_; }
-
- std::string managed_user_id() { return managed_user_id_; }
-
- base::string16 display_name() { return display_name_; }
-
- std::string master_key() { return master_key_; }
-
- void RunSuccessCallback(const std::string& token);
- void RunFailureCallback(GoogleServiceAuthError::State error);
-
- private:
- RegistrationCallback callback_;
- bool register_was_called_;
- std::string managed_user_id_;
- base::string16 display_name_;
- std::string master_key_;
-
- DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationUtilityStub);
-};
-
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REGISTRATION_UTILITY_STUB_H_
diff --git a/chrome/browser/managed_mode/managed_user_service_factory.h b/chrome/browser/managed_mode/managed_user_service_factory.h
deleted file mode 100644
index 059439c..0000000
--- a/chrome/browser/managed_mode/managed_user_service_factory.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_FACTORY_H_
-
-#include "base/memory/singleton.h"
-#include "chrome/browser/managed_mode/managed_users.h"
-#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
-
-class ManagedUserService;
-class Profile;
-
-class ManagedUserServiceFactory : public BrowserContextKeyedServiceFactory {
- public:
- static ManagedUserService* GetForProfile(Profile* profile);
-
- static ManagedUserServiceFactory* GetInstance();
-
- // Used to create instances for testing.
- static KeyedService* BuildInstanceFor(Profile* profile);
-
- private:
- friend struct DefaultSingletonTraits<ManagedUserServiceFactory>;
-
- ManagedUserServiceFactory();
- virtual ~ManagedUserServiceFactory();
-
- // BrowserContextKeyedServiceFactory:
- virtual content::BrowserContext* GetBrowserContextToUse(
- content::BrowserContext* context) const OVERRIDE;
- virtual KeyedService* BuildServiceInstanceFor(
- content::BrowserContext* profile) const OVERRIDE;
-};
-
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/managed_user_settings_service_factory.cc b/chrome/browser/managed_mode/managed_user_settings_service_factory.cc
deleted file mode 100644
index 51f1a84f..0000000
--- a/chrome/browser/managed_mode/managed_user_settings_service_factory.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
-
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/profiles/incognito_helpers.h"
-#include "chrome/browser/profiles/profile.h"
-#include "components/keyed_service/content/browser_context_dependency_manager.h"
-
-// static
-ManagedUserSettingsService*
-ManagedUserSettingsServiceFactory::GetForProfile(Profile* profile) {
- return static_cast<ManagedUserSettingsService*>(
- GetInstance()->GetServiceForBrowserContext(profile, true));
-}
-
-// static
-ManagedUserSettingsServiceFactory*
-ManagedUserSettingsServiceFactory::GetInstance() {
- return Singleton<ManagedUserSettingsServiceFactory>::get();
-}
-
-ManagedUserSettingsServiceFactory::ManagedUserSettingsServiceFactory()
- : BrowserContextKeyedServiceFactory(
- "ManagedUserSettingsService",
- BrowserContextDependencyManager::GetInstance()) {
-}
-
-ManagedUserSettingsServiceFactory::
- ~ManagedUserSettingsServiceFactory() {}
-
-KeyedService* ManagedUserSettingsServiceFactory::BuildServiceInstanceFor(
- content::BrowserContext* profile) const {
- return new ManagedUserSettingsService();
-}
-
-content::BrowserContext*
-ManagedUserSettingsServiceFactory::GetBrowserContextToUse(
- content::BrowserContext* context) const {
- return chrome::GetBrowserContextRedirectedInIncognito(context);
-}
diff --git a/chrome/browser/managed_mode/managed_user_settings_service_factory.h b/chrome/browser/managed_mode/managed_user_settings_service_factory.h
deleted file mode 100644
index 084966c..0000000
--- a/chrome/browser/managed_mode/managed_user_settings_service_factory.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_FACTORY_H_
-
-#include "base/memory/singleton.h"
-#include "chrome/browser/managed_mode/managed_users.h"
-#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
-
-class ManagedUserSettingsService;
-class Profile;
-
-class ManagedUserSettingsServiceFactory
- : public BrowserContextKeyedServiceFactory {
- public:
- static ManagedUserSettingsService* GetForProfile(Profile* profile);
-
- static ManagedUserSettingsServiceFactory* GetInstance();
-
- private:
- friend struct DefaultSingletonTraits<ManagedUserSettingsServiceFactory>;
-
- ManagedUserSettingsServiceFactory();
- virtual ~ManagedUserSettingsServiceFactory();
-
- // BrowserContextKeyedServiceFactory:
- virtual KeyedService* BuildServiceInstanceFor(
- content::BrowserContext* profile) const OVERRIDE;
- virtual content::BrowserContext* GetBrowserContextToUse(
- content::BrowserContext* context) const OVERRIDE;
-};
-
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/managed_user_shared_settings_service_factory.cc b/chrome/browser/managed_mode/managed_user_shared_settings_service_factory.cc
deleted file mode 100644
index 53f8836..0000000
--- a/chrome/browser/managed_mode/managed_user_shared_settings_service_factory.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "components/keyed_service/content/browser_context_dependency_manager.h"
-#include "components/user_prefs/user_prefs.h"
-#include "content/public/browser/browser_context.h"
-
-// static
-ManagedUserSharedSettingsService*
-ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
- content::BrowserContext* profile) {
- return static_cast<ManagedUserSharedSettingsService*>(
- GetInstance()->GetServiceForBrowserContext(profile, true));
-}
-
-// static
-ManagedUserSharedSettingsServiceFactory*
-ManagedUserSharedSettingsServiceFactory::GetInstance() {
- return Singleton<ManagedUserSharedSettingsServiceFactory>::get();
-}
-
-ManagedUserSharedSettingsServiceFactory::
- ManagedUserSharedSettingsServiceFactory()
- : BrowserContextKeyedServiceFactory(
- "ManagedUserSharedSettingsService",
- BrowserContextDependencyManager::GetInstance()) {}
-
-ManagedUserSharedSettingsServiceFactory::
- ~ManagedUserSharedSettingsServiceFactory() {}
-
-KeyedService* ManagedUserSharedSettingsServiceFactory::BuildServiceInstanceFor(
- content::BrowserContext* profile) const {
- return new ManagedUserSharedSettingsService(
- user_prefs::UserPrefs::Get(profile));
-}
diff --git a/chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h b/chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h
deleted file mode 100644
index 6f4a0ac..0000000
--- a/chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_FACTORY_H_
-
-#include "base/memory/singleton.h"
-#include "chrome/browser/managed_mode/managed_users.h"
-#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
-
-class ManagedUserSharedSettingsService;
-
-class ManagedUserSharedSettingsServiceFactory
- : public BrowserContextKeyedServiceFactory {
- public:
- static ManagedUserSharedSettingsService* GetForBrowserContext(
- content::BrowserContext* profile);
-
- static ManagedUserSharedSettingsServiceFactory* GetInstance();
-
- private:
- friend struct DefaultSingletonTraits<ManagedUserSharedSettingsServiceFactory>;
-
- ManagedUserSharedSettingsServiceFactory();
- virtual ~ManagedUserSharedSettingsServiceFactory();
-
- // BrowserContextKeyedServiceFactory:
- virtual KeyedService* BuildServiceInstanceFor(
- content::BrowserContext* profile) const OVERRIDE;
-};
-
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/managed_user_shared_settings_update.cc b/chrome/browser/managed_mode/managed_user_shared_settings_update.cc
deleted file mode 100644
index e018f96..0000000
--- a/chrome/browser/managed_mode/managed_user_shared_settings_update.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/managed_mode/managed_user_shared_settings_update.h"
-
-#include "base/bind.h"
-#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-
-ManagedUserSharedSettingsUpdate::ManagedUserSharedSettingsUpdate(
- ManagedUserSharedSettingsService* service,
- const std::string& mu_id,
- const std::string& key,
- scoped_ptr<base::Value> value,
- const base::Callback<void(bool)>& success_callback)
- : service_(service),
- mu_id_(mu_id),
- key_(key),
- value_(value.Pass()),
- callback_(success_callback) {
- service->SetValueInternal(mu_id, key, *value_, false);
- subscription_ = service->Subscribe(
- base::Bind(&ManagedUserSharedSettingsUpdate::OnSettingChanged,
- base::Unretained(this)));
-}
-
-ManagedUserSharedSettingsUpdate::~ManagedUserSharedSettingsUpdate() {}
-
-void ManagedUserSharedSettingsUpdate::OnSettingChanged(const std::string& mu_id,
- const std::string& key) {
- if (mu_id != mu_id_)
- return;
-
- if (key != key_)
- return;
-
- const base::Value* value = service_->GetValue(mu_id, key);
- callback_.Run(value->Equals(value_.get()));
-}
diff --git a/chrome/browser/managed_mode/managed_user_sync_service_factory.cc b/chrome/browser/managed_mode/managed_user_sync_service_factory.cc
deleted file mode 100644
index 76b3169..0000000
--- a/chrome/browser/managed_mode/managed_user_sync_service_factory.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
-
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "components/keyed_service/content/browser_context_dependency_manager.h"
-
-// static
-ManagedUserSyncService* ManagedUserSyncServiceFactory::GetForProfile(
- Profile* profile) {
- return static_cast<ManagedUserSyncService*>(
- GetInstance()->GetServiceForBrowserContext(profile, true));
-}
-
-// static
-ManagedUserSyncServiceFactory* ManagedUserSyncServiceFactory::GetInstance() {
- return Singleton<ManagedUserSyncServiceFactory>::get();
-}
-
-ManagedUserSyncServiceFactory::ManagedUserSyncServiceFactory()
- : BrowserContextKeyedServiceFactory(
- "ManagedUserSyncService",
- BrowserContextDependencyManager::GetInstance()) {
-}
-
-ManagedUserSyncServiceFactory::~ManagedUserSyncServiceFactory() {}
-
-KeyedService* ManagedUserSyncServiceFactory::BuildServiceInstanceFor(
- content::BrowserContext* profile) const {
- return new ManagedUserSyncService(static_cast<Profile*>(profile)->GetPrefs());
-}
diff --git a/chrome/browser/managed_mode/managed_user_sync_service_factory.h b/chrome/browser/managed_mode/managed_user_sync_service_factory.h
deleted file mode 100644
index 11f7de3..0000000
--- a/chrome/browser/managed_mode/managed_user_sync_service_factory.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_FACTORY_H_
-
-#include "base/memory/singleton.h"
-#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
-
-class ManagedUserSyncService;
-class Profile;
-
-class ManagedUserSyncServiceFactory
- : public BrowserContextKeyedServiceFactory {
- public:
- static ManagedUserSyncService* GetForProfile(Profile* profile);
-
- static ManagedUserSyncServiceFactory* GetInstance();
-
- private:
- friend struct DefaultSingletonTraits<ManagedUserSyncServiceFactory>;
-
- ManagedUserSyncServiceFactory();
- virtual ~ManagedUserSyncServiceFactory();
-
- // BrowserContextKeyedServiceFactory:
- virtual KeyedService* BuildServiceInstanceFor(
- content::BrowserContext* profile) const OVERRIDE;
-};
-
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/managed_user_sync_service_observer.h b/chrome/browser/managed_mode/managed_user_sync_service_observer.h
deleted file mode 100644
index a70cfec..0000000
--- a/chrome/browser/managed_mode/managed_user_sync_service_observer.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_OBSERVER_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_OBSERVER_H_
-
-class ManagedUserSyncServiceObserver {
- public:
- // Called when the Sync server has acknowledged a newly
- // created managed user.
- virtual void OnManagedUserAcknowledged(
- const std::string& managed_user_id) = 0;
-
- virtual void OnManagedUsersSyncingStopped() = 0;
-
- virtual void OnManagedUsersChanged() = 0;
-
- protected:
- virtual ~ManagedUserSyncServiceObserver() {}
-};
-
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_OBSERVER_H_
diff --git a/chrome/browser/managed_mode/managed_users.h b/chrome/browser/managed_mode/managed_users.h
deleted file mode 100644
index 3e9842b..0000000
--- a/chrome/browser/managed_mode/managed_users.h
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USERS_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USERS_H_
-
-// Compile-time check to make sure that we don't include managed user source
-// files when ENABLE_MANAGED_USERS is not defined.
-#if !defined(ENABLE_MANAGED_USERS)
-#error "Managed users aren't enabled."
-#endif
-
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USERS_H_
diff --git a/chrome/browser/managed_mode/permission_request_creator_sync.h b/chrome/browser/managed_mode/permission_request_creator_sync.h
deleted file mode 100644
index 8586e64..0000000
--- a/chrome/browser/managed_mode/permission_request_creator_sync.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_SYNC_H_
-#define CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_SYNC_H_
-
-#include "chrome/browser/managed_mode/permission_request_creator.h"
-
-#include "base/memory/scoped_ptr.h"
-
-class ManagedUserSettingsService;
-class ManagedUserSharedSettingsService;
-class ManagedUserSigninManagerWrapper;
-
-class PermissionRequestCreatorSync : public PermissionRequestCreator {
- public:
- PermissionRequestCreatorSync(
- ManagedUserSettingsService* settings_service,
- ManagedUserSharedSettingsService* shared_settings_service,
- const std::string& name,
- const std::string& managed_user_id);
- virtual ~PermissionRequestCreatorSync();
-
- // PermissionRequestCreator implementation:
- virtual void CreatePermissionRequest(const std::string& url_requested,
- const base::Closure& callback) OVERRIDE;
-
- private:
- ManagedUserSettingsService* settings_service_;
- ManagedUserSharedSettingsService* shared_settings_service_;
- std::string name_;
- std::string managed_user_id_;
-};
-
-#endif // CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_SYNC_H_
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 6c10c4d..00fab13 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -112,9 +112,9 @@
#endif
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
#endif
#if defined(ENABLE_SERVICE_DISCOVERY)
@@ -398,9 +398,9 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
#endif
#if defined(ENABLE_MANAGED_USERS)
- ManagedUserService::RegisterProfilePrefs(registry);
- ManagedUserSharedSettingsService::RegisterProfilePrefs(registry);
- ManagedUserSyncService::RegisterProfilePrefs(registry);
+ SupervisedUserService::RegisterProfilePrefs(registry);
+ SupervisedUserSharedSettingsService::RegisterProfilePrefs(registry);
+ SupervisedUserSyncService::RegisterProfilePrefs(registry);
#endif
#if defined(ENABLE_NOTIFICATIONS)
@@ -520,7 +520,7 @@ void MigrateUserPrefs(Profile* profile) {
TranslatePrefs::MigrateUserPrefs(prefs, prefs::kAcceptLanguages);
#if defined(ENABLE_MANAGED_USERS)
- ManagedUserService::MigrateUserPrefs(prefs);
+ SupervisedUserService::MigrateUserPrefs(prefs);
#endif
#if defined(OS_MACOSX) && !defined(OS_IOS)
diff --git a/chrome/browser/prefs/chrome_pref_service_factory.cc b/chrome/browser/prefs/chrome_pref_service_factory.cc
index 6945d96..951726a 100644
--- a/chrome/browser/prefs/chrome_pref_service_factory.cc
+++ b/chrome/browser/prefs/chrome_pref_service_factory.cc
@@ -54,7 +54,7 @@
#endif
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/supervised_user_pref_store.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_store.h"
#endif
#if defined(OS_WIN)
@@ -347,7 +347,7 @@ scoped_ptr<ProfilePrefStoreManager> CreateProfilePrefStoreManager(
void PrepareFactory(
PrefServiceSyncableFactory* factory,
policy::PolicyService* policy_service,
- ManagedUserSettingsService* managed_user_settings,
+ SupervisedUserSettingsService* supervised_user_settings,
scoped_refptr<PersistentPrefStore> user_pref_store,
const scoped_refptr<PrefStore>& extension_prefs,
bool async) {
@@ -366,9 +366,10 @@ void PrepareFactory(
#endif // ENABLE_CONFIGURATION_POLICY
#if defined(ENABLE_MANAGED_USERS)
- if (managed_user_settings) {
+ if (supervised_user_settings) {
factory->set_supervised_user_prefs(
- make_scoped_refptr(new SupervisedUserPrefStore(managed_user_settings)));
+ make_scoped_refptr(
+ new SupervisedUserPrefStore(supervised_user_settings)));
}
#endif
@@ -407,7 +408,7 @@ scoped_ptr<PrefService> CreateLocalState(
PrepareFactory(
&factory,
policy_service,
- NULL, // managed_user_settings
+ NULL, // supervised_user_settings
new JsonPrefStore(
pref_filename, pref_io_task_runner, scoped_ptr<PrefFilter>()),
NULL, // extension_prefs
@@ -420,7 +421,7 @@ scoped_ptr<PrefServiceSyncable> CreateProfilePrefs(
base::SequencedTaskRunner* pref_io_task_runner,
TrackedPreferenceValidationDelegate* validation_delegate,
policy::PolicyService* policy_service,
- ManagedUserSettingsService* managed_user_settings,
+ SupervisedUserSettingsService* supervised_user_settings,
const scoped_refptr<PrefStore>& extension_prefs,
const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry,
bool async) {
@@ -429,7 +430,7 @@ scoped_ptr<PrefServiceSyncable> CreateProfilePrefs(
PrepareFactory(
&factory,
policy_service,
- managed_user_settings,
+ supervised_user_settings,
scoped_refptr<PersistentPrefStore>(
CreateProfilePrefStoreManager(profile_path)->CreateProfilePrefStore(
pref_io_task_runner, validation_delegate)),
diff --git a/chrome/browser/prefs/chrome_pref_service_factory.h b/chrome/browser/prefs/chrome_pref_service_factory.h
index 39da845..f7cfb8f 100644
--- a/chrome/browser/prefs/chrome_pref_service_factory.h
+++ b/chrome/browser/prefs/chrome_pref_service_factory.h
@@ -23,7 +23,6 @@ namespace user_prefs {
class PrefRegistrySyncable;
}
-class ManagedUserSettingsService;
class PrefHashStore;
class PrefRegistry;
class PrefRegistrySimple;
@@ -31,6 +30,7 @@ class PrefService;
class PrefServiceSyncable;
class PrefStore;
class Profile;
+class SupervisedUserSettingsService;
class TrackedPreferenceValidationDelegate;
namespace chrome_prefs {
@@ -72,7 +72,7 @@ scoped_ptr<PrefServiceSyncable> CreateProfilePrefs(
base::SequencedTaskRunner* pref_io_task_runner,
TrackedPreferenceValidationDelegate* validation_delegate,
policy::PolicyService* policy_service,
- ManagedUserSettingsService* managed_user_settings,
+ SupervisedUserSettingsService* supervised_user_settings,
const scoped_refptr<PrefStore>& extension_prefs,
const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry,
bool async);
diff --git a/chrome/browser/profiles/avatar_menu.cc b/chrome/browser/profiles/avatar_menu.cc
index 209dda2..0039b10 100644
--- a/chrome/browser/profiles/avatar_menu.cc
+++ b/chrome/browser/profiles/avatar_menu.cc
@@ -33,8 +33,8 @@
#include "ui/base/resource/resource_bundle.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"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#endif
using content::BrowserThread;
@@ -189,8 +189,8 @@ base::string16 AvatarMenu::GetSupervisedUserInformation() const {
// |browser_| can be NULL in unit_tests.
if (browser_ && browser_->profile()->IsSupervised()) {
#if defined(ENABLE_MANAGED_USERS)
- ManagedUserService* service = ManagedUserServiceFactory::GetForProfile(
- browser_->profile());
+ SupervisedUserService* service =
+ SupervisedUserServiceFactory::GetForProfile(browser_->profile());
base::string16 custodian =
base::UTF8ToUTF16(service->GetCustodianEmailAddress());
return l10n_util::GetStringFUTF16(IDS_MANAGED_USER_INFO, custodian);
diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
index 7e7a47c..3bfc8a1 100644
--- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
+++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
@@ -82,11 +82,11 @@
#endif
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#if defined(OS_CHROMEOS)
-#include "chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.h"
-#include "chrome/browser/managed_mode/chromeos/manager_password_service_factory.h"
+#include "chrome/browser/supervised_user/chromeos/manager_password_service_factory.h"
+#include "chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h"
#endif
#endif
@@ -195,11 +195,11 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() {
#endif
#if defined(ENABLE_MANAGED_USERS)
#if defined(OS_CHROMEOS)
- chromeos::ManagedUserPasswordServiceFactory::GetInstance();
+ chromeos::SupervisedUserPasswordServiceFactory::GetInstance();
chromeos::ManagerPasswordServiceFactory::GetInstance();
#endif
- ManagedUserServiceFactory::GetInstance();
- ManagedUserSyncServiceFactory::GetInstance();
+ SupervisedUserServiceFactory::GetInstance();
+ SupervisedUserSyncServiceFactory::GetInstance();
#endif
#if !defined(OS_ANDROID)
MediaGalleriesPreferencesFactory::GetInstance();
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index d6a4466..ed645b7 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -137,8 +137,8 @@
#endif
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
#endif
using base::Time;
@@ -458,11 +458,11 @@ ProfileImpl::ProfileImpl(
BrowserContextDependencyManager::GetInstance()->
RegisterProfilePrefsForServices(this, pref_registry_.get());
- ManagedUserSettingsService* managed_user_settings = NULL;
+ SupervisedUserSettingsService* supervised_user_settings = NULL;
#if defined(ENABLE_MANAGED_USERS)
- managed_user_settings =
- ManagedUserSettingsServiceFactory::GetForProfile(this);
- managed_user_settings->Init(
+ supervised_user_settings =
+ SupervisedUserSettingsServiceFactory::GetForProfile(this);
+ supervised_user_settings->Init(
path_, sequenced_task_runner, create_mode == CREATE_MODE_SYNCHRONOUS);
#endif
@@ -483,7 +483,7 @@ ProfileImpl::ProfileImpl(
sequenced_task_runner,
pref_validation_delegate_.get(),
profile_policy_connector_->policy_service(),
- managed_user_settings,
+ supervised_user_settings,
new ExtensionPrefStore(
ExtensionPrefValueMapFactory::GetForBrowserContext(this), false),
pref_registry_,
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index 6e14ddc..b47f92e 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -89,9 +89,9 @@
#endif
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#endif
#if defined(OS_CHROMEOS)
@@ -343,10 +343,10 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
.reset(ProxyServiceFactory::CreateProxyConfigService(
profile->GetProxyConfigTracker()));
#if defined(ENABLE_MANAGED_USERS)
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile);
- params->managed_mode_url_filter =
- managed_user_service->GetURLFilterForIOThread();
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile);
+ params->supervised_user_url_filter =
+ supervised_user_service->GetURLFilterForIOThread();
#endif
#if defined(OS_CHROMEOS)
chromeos::UserManager* user_manager = chromeos::UserManager::Get();
@@ -989,7 +989,7 @@ void ProfileIOData::Init(
resource_context_->request_context_ = main_request_context_.get();
#if defined(ENABLE_MANAGED_USERS)
- managed_mode_url_filter_ = profile_params_->managed_mode_url_filter;
+ supervised_user_url_filter_ = profile_params_->supervised_user_url_filter;
#endif
#if defined(OS_CHROMEOS)
diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h
index 8b310a9..bbe1ace 100644
--- a/chrome/browser/profiles/profile_io_data.h
+++ b/chrome/browser/profiles/profile_io_data.h
@@ -33,10 +33,10 @@ class ChromeNetworkDelegate;
class CookieSettings;
class DevToolsNetworkController;
class HostContentSettingsMap;
-class ManagedModeURLFilter;
class MediaDeviceIDSalt;
class ProtocolHandlerRegistry;
class SigninNamesOnIOThread;
+class SupervisedUserURLFilter;
namespace extensions {
class InfoMap;
@@ -221,8 +221,8 @@ class ProfileIOData {
#endif
#if defined(ENABLE_MANAGED_USERS)
- const ManagedModeURLFilter* managed_mode_url_filter() const {
- return managed_mode_url_filter_.get();
+ const SupervisedUserURLFilter* supervised_user_url_filter() const {
+ return supervised_user_url_filter_.get();
}
#endif
@@ -302,7 +302,7 @@ class ProfileIOData {
scoped_ptr<net::ProxyConfigService> proxy_config_service;
#if defined(ENABLE_MANAGED_USERS)
- scoped_refptr<const ManagedModeURLFilter> managed_mode_url_filter;
+ scoped_refptr<const SupervisedUserURLFilter> supervised_user_url_filter;
#endif
#if defined(OS_CHROMEOS)
@@ -579,7 +579,8 @@ class ProfileIOData {
chrome_http_user_agent_settings_;
#if defined(ENABLE_MANAGED_USERS)
- mutable scoped_refptr<const ManagedModeURLFilter> managed_mode_url_filter_;
+ mutable scoped_refptr<const SupervisedUserURLFilter>
+ supervised_user_url_filter_;
#endif
mutable scoped_ptr<DevToolsNetworkController> network_controller_;
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 0d457a8..85ba788 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -62,8 +62,8 @@
#include "ui/base/l10n/l10n_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"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#endif
#if !defined(OS_IOS)
@@ -985,7 +985,7 @@ void ProfileManager::DoFinalInitForServices(Profile* profile,
// Initialization needs to happen after extension system initialization (for
// extension::ManagementPolicy) and InitProfileUserPrefs (for setting the
// initializing the supervised flag if necessary).
- ManagedUserServiceFactory::GetForProfile(profile)->Init();
+ SupervisedUserServiceFactory::GetForProfile(profile)->Init();
#endif
// Start the deferred task runners once the profile is loaded.
StartupTaskRunnerServiceFactory::GetForProfile(profile)->
diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
index c1f959b..6a52315 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
@@ -65,7 +65,7 @@
#endif
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_mode_resource_throttle.h"
+#include "chrome/browser/supervised_user/supervised_user_resource_throttle.h"
#endif
#if defined(USE_SYSTEM_PROTOBUF)
@@ -495,9 +495,9 @@ void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles(
#if defined(ENABLE_MANAGED_USERS)
bool is_subresource_request = resource_type != ResourceType::MAIN_FRAME;
- throttles->push_back(new ManagedModeResourceThrottle(
+ throttles->push_back(new SupervisedUserResourceThrottle(
request, !is_subresource_request,
- io_data->managed_mode_url_filter()));
+ io_data->supervised_user_url_filter()));
#endif
content::ResourceThrottle* throttle =
diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc
index 0b60126..43a52da 100644
--- a/chrome/browser/search/search.cc
+++ b/chrome/browser/search/search.cc
@@ -37,9 +37,9 @@
#include "ui/base/l10n/l10n_util.h"
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#endif
namespace chrome {
@@ -289,12 +289,12 @@ base::string16 GetSearchTermsImpl(const content::WebContents* contents,
bool IsURLAllowedForSupervisedUser(const GURL& url, Profile* profile) {
#if defined(ENABLE_MANAGED_USERS)
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile);
- ManagedModeURLFilter* url_filter =
- managed_user_service->GetURLFilterForUIThread();
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile);
+ SupervisedUserURLFilter* url_filter =
+ supervised_user_service->GetURLFilterForUIThread();
if (url_filter->GetFilteringBehaviorForURL(url) ==
- ManagedModeURLFilter::BLOCK) {
+ SupervisedUserURLFilter::BLOCK) {
return false;
}
#endif
diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc
index e6d2746..b50d75c 100644
--- a/chrome/browser/search/search_unittest.cc
+++ b/chrome/browser/search/search_unittest.cc
@@ -9,15 +9,15 @@
#include "base/metrics/statistics_recorder.h"
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/instant_service_factory.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -553,10 +553,10 @@ TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) {
TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) {
// Block access to foo.com in the URL filter.
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile());
- ManagedModeURLFilter* url_filter =
- managed_user_service->GetURLFilterForUIThread();
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile());
+ SupervisedUserURLFilter* url_filter =
+ supervised_user_service->GetURLFilterForUIThread();
std::map<std::string, bool> hosts;
hosts["foo.com"] = false;
url_filter->SetManualHosts(&hosts);
diff --git a/chrome/browser/signin/chrome_signin_client.cc b/chrome/browser/signin/chrome_signin_client.cc
index c5550c4..29a6355 100644
--- a/chrome/browser/signin/chrome_signin_client.cc
+++ b/chrome/browser/signin/chrome_signin_client.cc
@@ -18,7 +18,7 @@
#include "url/gurl.h"
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
#endif
#if defined(OS_CHROMEOS)
diff --git a/chrome/browser/managed_mode/OWNERS b/chrome/browser/supervised_user/OWNERS
index 3dd0ccc..3dd0ccc 100644
--- a/chrome/browser/managed_mode/OWNERS
+++ b/chrome/browser/supervised_user/OWNERS
diff --git a/chrome/browser/managed_mode/chromeos/manager_password_service.cc b/chrome/browser/supervised_user/chromeos/manager_password_service.cc
index 0548b12..79958c6 100644
--- a/chrome/browser/managed_mode/chromeos/manager_password_service.cc
+++ b/chrome/browser/supervised_user/chromeos/manager_password_service.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/chromeos/manager_password_service.h"
+#include "chrome/browser/supervised_user/chromeos/manager_password_service.h"
#include "base/bind.h"
#include "base/logging.h"
@@ -15,8 +15,8 @@
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
namespace chromeos {
@@ -26,8 +26,8 @@ ManagerPasswordService::~ManagerPasswordService() {}
void ManagerPasswordService::Init(
const std::string& user_id,
- ManagedUserSyncService* user_service,
- ManagedUserSharedSettingsService* shared_settings_service) {
+ SupervisedUserSyncService* user_service,
+ SupervisedUserSharedSettingsService* shared_settings_service) {
user_id_ = user_id;
user_service_ = user_service;
settings_service_ = shared_settings_service;
@@ -51,24 +51,24 @@ void ManagerPasswordService::Init(
continue;
OnSharedSettingsChange(
supervised_user_manager->GetUserSyncId((*it)->email()),
- managed_users::kChromeOSPasswordData);
+ supervised_users::kChromeOSPasswordData);
}
}
void ManagerPasswordService::OnSharedSettingsChange(
- const std::string& mu_id,
+ const std::string& su_id,
const std::string& key) {
- if (key != managed_users::kChromeOSPasswordData)
+ if (key != supervised_users::kChromeOSPasswordData)
return;
SupervisedUserManager* supervised_user_manager =
UserManager::Get()->GetSupervisedUserManager();
- const User* user = supervised_user_manager->FindBySyncId(mu_id);
+ const User* user = supervised_user_manager->FindBySyncId(su_id);
// No user on device.
if (user == NULL)
return;
- const base::Value* value = settings_service_->GetValue(mu_id, key);
+ const base::Value* value = settings_service_->GetValue(su_id, key);
if (value == NULL) {
LOG(WARNING) << "Got empty value from sync.";
@@ -88,27 +88,27 @@ void ManagerPasswordService::OnSharedSettingsChange(
return;
}
scoped_ptr<base::DictionaryValue> wrapper(dict->DeepCopy());
- user_service_->GetManagedUsersAsync(
- base::Bind(&ManagerPasswordService::GetManagedUsersCallback,
+ user_service_->GetSupervisedUsersAsync(
+ base::Bind(&ManagerPasswordService::GetSupervisedUsersCallback,
weak_ptr_factory_.GetWeakPtr(),
- mu_id,
+ su_id,
user->email(),
Passed(&wrapper)));
}
-void ManagerPasswordService::GetManagedUsersCallback(
- const std::string& sync_mu_id,
+void ManagerPasswordService::GetSupervisedUsersCallback(
+ const std::string& sync_su_id,
const std::string& user_id,
scoped_ptr<base::DictionaryValue> password_data,
- const base::DictionaryValue* managed_users) {
- const base::DictionaryValue* managed_user = NULL;
- if (!managed_users->GetDictionary(sync_mu_id, &managed_user))
+ const base::DictionaryValue* supervised_users) {
+ const base::DictionaryValue* supervised_user = NULL;
+ if (!supervised_users->GetDictionary(sync_su_id, &supervised_user))
return;
std::string master_key;
std::string encryption_key;
std::string signature_key;
- if (!managed_user->GetString(ManagedUserSyncService::kMasterKey,
- &master_key)) {
+ if (!supervised_user->GetString(SupervisedUserSyncService::kMasterKey,
+ &master_key)) {
LOG(WARNING) << "Can not apply password change to " << user_id
<< ": no master key found";
UMA_HISTOGRAM_ENUMERATION(
@@ -118,10 +118,11 @@ void ManagerPasswordService::GetManagedUsersCallback(
return;
}
- if (!managed_user->GetString(ManagedUserSyncService::kPasswordSignatureKey,
- &signature_key) ||
- !managed_user->GetString(ManagedUserSyncService::kPasswordEncryptionKey,
- &encryption_key)) {
+ if (!supervised_user->GetString(
+ SupervisedUserSyncService::kPasswordSignatureKey, &signature_key) ||
+ !supervised_user->GetString(
+ SupervisedUserSyncService::kPasswordEncryptionKey,
+ &encryption_key)) {
LOG(WARNING) << "Can not apply password change to " << user_id
<< ": no signature / encryption keys.";
UMA_HISTOGRAM_ENUMERATION(
@@ -157,7 +158,7 @@ void ManagerPasswordService::GetManagedUsersCallback(
cryptohome::KeyDefinition new_key_definition(
new_key,
- kCryptohomeManagedUserKeyLabel,
+ kCryptohomeSupervisedUserKeyLabel,
cryptohome::PRIV_AUTHORIZED_UPDATE || cryptohome::PRIV_MOUNT);
new_key_definition.revision = revision;
@@ -238,15 +239,15 @@ void ManagerPasswordService::OnNewManagerKeySuccess(
VLOG(1) << "Added new master key for " << master_key_context.GetUserID();
authenticator_->RemoveKey(
master_key_context,
- kLegacyCryptohomeManagedUserKeyLabel,
- base::Bind(&ManagerPasswordService::OnOldManagedUserKeyDeleted,
+ kLegacyCryptohomeSupervisedUserKeyLabel,
+ base::Bind(&ManagerPasswordService::OnOldSupervisedUserKeyDeleted,
weak_ptr_factory_.GetWeakPtr(),
master_key_context));
}
-void ManagerPasswordService::OnOldManagedUserKeyDeleted(
+void ManagerPasswordService::OnOldSupervisedUserKeyDeleted(
const UserContext& master_key_context) {
- VLOG(1) << "Removed old managed user key for "
+ VLOG(1) << "Removed old supervised user key for "
<< master_key_context.GetUserID();
authenticator_->RemoveKey(
master_key_context,
diff --git a/chrome/browser/managed_mode/chromeos/manager_password_service.h b/chrome/browser/supervised_user/chromeos/manager_password_service.h
index 65a790e..24425a5c 100644
--- a/chrome/browser/managed_mode/chromeos/manager_password_service.h
+++ b/chrome/browser/supervised_user/chromeos/manager_password_service.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_
-#define CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_
#include <string>
@@ -11,22 +11,22 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/login/auth/extended_authenticator.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "components/keyed_service/core/keyed_service.h"
namespace chromeos {
class UserContext;
-// Handles managed user password change that is detected while manager is
+// Handles supervised user password change that is detected while manager is
// signed in.
-// It uses manager's master key to authorize update of managed user's key.
+// It uses manager's master key to authorize update of supervised user's key.
// Edge case: Pre-M35 supervised users don't have correct labels for keys.
-// After new managed user key is added, migration is done in following way:
+// After new supervised user key is added, migration is done in following way:
// 1) Master key is added with correct label
-// 2) Old managed user's key is deleted.
+// 2) Old supervised user's key is deleted.
// 3) Old master key is deleted.
class ManagerPasswordService
: public KeyedService,
@@ -38,34 +38,36 @@ class ManagerPasswordService
virtual void Shutdown() OVERRIDE;
void Init(const std::string& user_id,
- ManagedUserSyncService* user_service,
- ManagedUserSharedSettingsService* service);
+ SupervisedUserSyncService* user_service,
+ SupervisedUserSharedSettingsService* service);
// chromeos::ExtendedAuthenticator::AuthStatusConsumer overrides:
virtual void OnAuthenticationFailure(ExtendedAuthenticator::AuthState state)
OVERRIDE;
private:
- void OnSharedSettingsChange(const std::string& mu_id, const std::string& key);
- void GetManagedUsersCallback(const std::string& sync_mu_id,
- const std::string& user_id,
- scoped_ptr<base::DictionaryValue> password_data,
- const base::DictionaryValue* managed_users);
+ void OnSharedSettingsChange(const std::string& su_id, const std::string& key);
+ void GetSupervisedUsersCallback(
+ const std::string& sync_su_id,
+ const std::string& user_id,
+ scoped_ptr<base::DictionaryValue> password_data,
+ const base::DictionaryValue* supervised_users);
void OnAddKeySuccess(const UserContext& master_key_context,
const std::string& user_id,
scoped_ptr<base::DictionaryValue> password_data);
void OnKeyTransformedIfNeeded(const UserContext& master_key_context);
void OnNewManagerKeySuccess(const UserContext& master_key_context);
- void OnOldManagedUserKeyDeleted(const UserContext& master_key_context);
+ void OnOldSupervisedUserKeyDeleted(const UserContext& master_key_context);
void OnOldManagerKeyDeleted(const UserContext& master_key_context);
// Cached value from Init().
- // User id of currently logged in user, that have managed users on device.
+ // User id of currently logged in user, that have supervised users on device.
std::string user_id_;
- ManagedUserSyncService* user_service_;
- ManagedUserSharedSettingsService* settings_service_;
+ SupervisedUserSyncService* user_service_;
+ SupervisedUserSharedSettingsService* settings_service_;
- scoped_ptr<ManagedUserSharedSettingsService::ChangeCallbackList::Subscription>
+ scoped_ptr<SupervisedUserSharedSettingsService::ChangeCallbackList::
+ Subscription>
settings_service_subscription_;
scoped_refptr<ExtendedAuthenticator> authenticator_;
@@ -76,4 +78,4 @@ class ManagerPasswordService
};
} // namespace chromeos
-#endif // CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_
diff --git a/chrome/browser/managed_mode/chromeos/manager_password_service_factory.cc b/chrome/browser/supervised_user/chromeos/manager_password_service_factory.cc
index 975de94..0778b82 100644
--- a/chrome/browser/managed_mode/chromeos/manager_password_service_factory.cc
+++ b/chrome/browser/supervised_user/chromeos/manager_password_service_factory.cc
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/chromeos/manager_password_service_factory.h"
+#include "chrome/browser/supervised_user/chromeos/manager_password_service_factory.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
-#include "chrome/browser/managed_mode/chromeos/manager_password_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/chromeos/manager_password_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
namespace chromeos {
@@ -33,8 +33,8 @@ ManagerPasswordServiceFactory::ManagerPasswordServiceFactory()
: BrowserContextKeyedServiceFactory(
"ManagerPasswordService",
BrowserContextDependencyManager::GetInstance()) {
- DependsOn(ManagedUserSharedSettingsServiceFactory::GetInstance());
- DependsOn(ManagedUserSyncServiceFactory::GetInstance());
+ DependsOn(SupervisedUserSharedSettingsServiceFactory::GetInstance());
+ DependsOn(SupervisedUserSyncServiceFactory::GetInstance());
}
ManagerPasswordServiceFactory::
@@ -50,8 +50,9 @@ KeyedService* ManagerPasswordServiceFactory::BuildServiceInstanceFor(
ManagerPasswordService* result = new ManagerPasswordService();
result->Init(
user->email(),
- ManagedUserSyncServiceFactory::GetForProfile(profile),
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile));
+ SupervisedUserSyncServiceFactory::GetForProfile(profile),
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ profile));
return result;
}
return NULL;
diff --git a/chrome/browser/managed_mode/chromeos/manager_password_service_factory.h b/chrome/browser/supervised_user/chromeos/manager_password_service_factory.h
index 837b1d6..2a916fb 100644
--- a/chrome/browser/managed_mode/chromeos/manager_password_service_factory.h
+++ b/chrome/browser/supervised_user/chromeos/manager_password_service_factory.h
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGER_PASSWORD_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGER_PASSWORD_SERVICE_FACTORY_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_FACTORY_H_
#include "base/memory/singleton.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class Profile;
@@ -36,4 +36,4 @@ class ManagerPasswordServiceFactory
};
} // namespace chromeos
-#endif // CHROME_BROWSER_MANAGED_MODE_CHROMEOS_MANAGER_PASSWORD_SERVICE_FACTORY_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/chromeos/managed_user_password_service.cc b/chrome/browser/supervised_user/chromeos/supervised_user_password_service.cc
index 321074a..ecc22e4 100644
--- a/chrome/browser/managed_mode/chromeos/managed_user_password_service.cc
+++ b/chrome/browser/supervised_user/chromeos/supervised_user_password_service.cc
@@ -2,30 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/chromeos/managed_user_password_service.h"
+#include "chrome/browser/supervised_user/chromeos/supervised_user_password_service.h"
#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
namespace chromeos {
-ManagedUserPasswordService::ManagedUserPasswordService()
+SupervisedUserPasswordService::SupervisedUserPasswordService()
: weak_ptr_factory_(this) {}
-ManagedUserPasswordService::~ManagedUserPasswordService() {}
+SupervisedUserPasswordService::~SupervisedUserPasswordService() {}
-void ManagedUserPasswordService::Init(
+void SupervisedUserPasswordService::Init(
const std::string& user_id,
- ManagedUserSharedSettingsService* shared_settings_service) {
+ SupervisedUserSharedSettingsService* shared_settings_service) {
user_id_ = user_id;
settings_service_ = shared_settings_service;
settings_service_subscription_ = settings_service_->Subscribe(
- base::Bind(&ManagedUserPasswordService::OnSharedSettingsChange,
+ base::Bind(&SupervisedUserPasswordService::OnSharedSettingsChange,
weak_ptr_factory_.GetWeakPtr()));
// Force value check in case we have missed some notification.
@@ -34,17 +34,17 @@ void ManagedUserPasswordService::Init(
chromeos::UserManager::Get()->GetSupervisedUserManager();
OnSharedSettingsChange(supervised_user_manager->GetUserSyncId(user_id),
- managed_users::kChromeOSPasswordData);
+ supervised_users::kChromeOSPasswordData);
}
-void ManagedUserPasswordService::OnSharedSettingsChange(
- const std::string& mu_id,
+void SupervisedUserPasswordService::OnSharedSettingsChange(
+ const std::string& su_id,
const std::string& key) {
- if (key != managed_users::kChromeOSPasswordData)
+ if (key != supervised_users::kChromeOSPasswordData)
return;
chromeos::SupervisedUserManager* supervised_user_manager =
chromeos::UserManager::Get()->GetSupervisedUserManager();
- const chromeos::User* user = supervised_user_manager->FindBySyncId(mu_id);
+ const chromeos::User* user = supervised_user_manager->FindBySyncId(su_id);
if (user == NULL) {
LOG(WARNING) << "Got notification for user not on device.";
return;
@@ -52,7 +52,7 @@ void ManagedUserPasswordService::OnSharedSettingsChange(
DCHECK(user_id_ == user->email());
if (user_id_ != user->email())
return;
- const base::Value* value = settings_service_->GetValue(mu_id, key);
+ const base::Value* value = settings_service_->GetValue(su_id, key);
if (value == NULL) {
LOG(WARNING) << "Got empty value from sync.";
return;
@@ -69,7 +69,7 @@ void ManagedUserPasswordService::OnSharedSettingsChange(
auth->ScheduleSupervisedPasswordChange(user_id_, dict);
}
-void ManagedUserPasswordService::Shutdown() {
+void SupervisedUserPasswordService::Shutdown() {
settings_service_subscription_.reset();
}
diff --git a/chrome/browser/supervised_user/chromeos/supervised_user_password_service.h b/chrome/browser/supervised_user/chromeos/supervised_user_password_service.h
new file mode 100644
index 0000000..30cedca
--- /dev/null
+++ b/chrome/browser/supervised_user/chromeos/supervised_user_password_service.h
@@ -0,0 +1,46 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_SUPERVISED_USER_PASSWORD_SERVICE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_SUPERVISED_USER_PASSWORD_SERVICE_H_
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
+#include "components/keyed_service/core/keyed_service.h"
+
+namespace chromeos {
+
+class SupervisedUserPasswordService : public KeyedService {
+ public:
+ SupervisedUserPasswordService();
+ virtual ~SupervisedUserPasswordService();
+
+ virtual void Shutdown() OVERRIDE;
+
+ void Init(const std::string& user_id,
+ SupervisedUserSharedSettingsService* service);
+ private:
+ void OnSharedSettingsChange(const std::string& su_id, const std::string& key);
+
+ // Cached value from Init().
+ // User id of currently logged in supervised user.
+ std::string user_id_;
+ SupervisedUserSharedSettingsService* settings_service_;
+
+ scoped_ptr<SupervisedUserSharedSettingsService::ChangeCallbackList::
+ Subscription>
+ settings_service_subscription_;
+
+ base::WeakPtrFactory<SupervisedUserPasswordService> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserPasswordService);
+};
+
+} // namespace chromeos
+#endif // CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_SUPERVISED_USER_PASSWORD_SERVICE_H_
diff --git a/chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.cc b/chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.cc
index 6e31f61..842f43b 100644
--- a/chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.cc
+++ b/chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.cc
@@ -2,57 +2,58 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.h"
+#include "chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
-#include "chrome/browser/managed_mode/chromeos/managed_user_password_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/chromeos/supervised_user_password_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
namespace chromeos {
// static
-ManagedUserPasswordService*
-ManagedUserPasswordServiceFactory::GetForProfile(Profile* profile) {
- return static_cast<ManagedUserPasswordService*>(
+SupervisedUserPasswordService*
+SupervisedUserPasswordServiceFactory::GetForProfile(Profile* profile) {
+ return static_cast<SupervisedUserPasswordService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
// static
-ManagedUserPasswordServiceFactory*
-ManagedUserPasswordServiceFactory::GetInstance() {
- return Singleton<ManagedUserPasswordServiceFactory>::get();
+SupervisedUserPasswordServiceFactory*
+SupervisedUserPasswordServiceFactory::GetInstance() {
+ return Singleton<SupervisedUserPasswordServiceFactory>::get();
}
-ManagedUserPasswordServiceFactory::ManagedUserPasswordServiceFactory()
+SupervisedUserPasswordServiceFactory::SupervisedUserPasswordServiceFactory()
: BrowserContextKeyedServiceFactory(
- "ManagedUserPasswordService",
+ "SupervisedUserPasswordService",
BrowserContextDependencyManager::GetInstance()) {
- DependsOn(ManagedUserSharedSettingsServiceFactory::GetInstance());
+ DependsOn(SupervisedUserSharedSettingsServiceFactory::GetInstance());
}
-ManagedUserPasswordServiceFactory::
- ~ManagedUserPasswordServiceFactory() {}
+SupervisedUserPasswordServiceFactory::
+ ~SupervisedUserPasswordServiceFactory() {}
-KeyedService* ManagedUserPasswordServiceFactory::BuildServiceInstanceFor(
+KeyedService* SupervisedUserPasswordServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile= static_cast<Profile*>(context);
User* user = UserManager::Get()->GetUserByProfile(profile);
if (user->GetType() != User::USER_TYPE_LOCALLY_MANAGED)
return NULL;
- ManagedUserPasswordService* result = new ManagedUserPasswordService();
+ SupervisedUserPasswordService* result = new SupervisedUserPasswordService();
result->Init(
user->email(),
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile));
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ profile));
return result;
}
content::BrowserContext*
-ManagedUserPasswordServiceFactory::GetBrowserContextToUse(
+SupervisedUserPasswordServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context);
}
diff --git a/chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h b/chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h
new file mode 100644
index 0000000..4971699
--- /dev/null
+++ b/chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h
@@ -0,0 +1,39 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_SUPERVISED_USER_PASSWORD_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_SUPERVISED_USER_PASSWORD_SERVICE_FACTORY_H_
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+
+class Profile;
+
+namespace chromeos {
+
+class SupervisedUserPasswordService;
+
+class SupervisedUserPasswordServiceFactory
+ : public BrowserContextKeyedServiceFactory {
+ public:
+ static SupervisedUserPasswordService* GetForProfile(Profile* profile);
+
+ static SupervisedUserPasswordServiceFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<SupervisedUserPasswordServiceFactory>;
+
+ SupervisedUserPasswordServiceFactory();
+ virtual ~SupervisedUserPasswordServiceFactory();
+
+ // BrowserContextKeyedServiceFactory:
+ virtual KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const OVERRIDE;
+ virtual content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const OVERRIDE;
+};
+
+} // namespace chromeos
+#endif // CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_SUPERVISED_USER_PASSWORD_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/custodian_profile_downloader_service.cc b/chrome/browser/supervised_user/custodian_profile_downloader_service.cc
index 87dc65c9..3955cef 100644
--- a/chrome/browser/managed_mode/custodian_profile_downloader_service.cc
+++ b/chrome/browser/supervised_user/custodian_profile_downloader_service.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/custodian_profile_downloader_service.h"
+#include "chrome/browser/supervised_user/custodian_profile_downloader_service.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
diff --git a/chrome/browser/managed_mode/custodian_profile_downloader_service.h b/chrome/browser/supervised_user/custodian_profile_downloader_service.h
index 5092b8d..0c998d1 100644
--- a/chrome/browser/managed_mode/custodian_profile_downloader_service.h
+++ b/chrome/browser/supervised_user/custodian_profile_downloader_service.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
-#define CHROME_BROWSER_MANAGED_MODE_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
#include "base/callback.h"
#include "chrome/browser/profiles/profile_downloader.h"
@@ -56,4 +56,4 @@ class CustodianProfileDownloaderService : public KeyedService,
std::string in_progress_profile_email_;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_H_
diff --git a/chrome/browser/managed_mode/custodian_profile_downloader_service_factory.cc b/chrome/browser/supervised_user/custodian_profile_downloader_service_factory.cc
index 1957f44a..da320a1 100644
--- a/chrome/browser/managed_mode/custodian_profile_downloader_service_factory.cc
+++ b/chrome/browser/supervised_user/custodian_profile_downloader_service_factory.cc
@@ -1,12 +1,12 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/custodian_profile_downloader_service_factory.h"
+#include "chrome/browser/supervised_user/custodian_profile_downloader_service_factory.h"
-#include "chrome/browser/managed_mode/custodian_profile_downloader_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/supervised_user/custodian_profile_downloader_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
// static
diff --git a/chrome/browser/managed_mode/custodian_profile_downloader_service_factory.h b/chrome/browser/supervised_user/custodian_profile_downloader_service_factory.h
index 42a21e6..c603dbe 100644
--- a/chrome/browser/managed_mode/custodian_profile_downloader_service_factory.h
+++ b/chrome/browser/supervised_user/custodian_profile_downloader_service_factory.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_MANAGED_MODE_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_FACTORY_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_FACTORY_H_
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
@@ -30,4 +30,4 @@ class CustodianProfileDownloaderServiceFactory
content::BrowserContext* profile) const OVERRIDE;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_FACTORY_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_CUSTODIAN_PROFILE_DOWNLOADER_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/permission_request_creator.h b/chrome/browser/supervised_user/permission_request_creator.h
index 1dea0c6..b70e56b 100644
--- a/chrome/browser/managed_mode/permission_request_creator.h
+++ b/chrome/browser/supervised_user/permission_request_creator.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_H_
-#define CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_H_
+#define CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_H_
#include <string>
@@ -17,4 +17,4 @@ class PermissionRequestCreator {
const base::Closure& callback) = 0;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_H_
diff --git a/chrome/browser/managed_mode/permission_request_creator_apiary.cc b/chrome/browser/supervised_user/permission_request_creator_apiary.cc
index ae92f49..a590fdb 100644
--- a/chrome/browser/managed_mode/permission_request_creator_apiary.cc
+++ b/chrome/browser/supervised_user/permission_request_creator_apiary.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/permission_request_creator_apiary.h"
+#include "chrome/browser/supervised_user/permission_request_creator_apiary.h"
#include "base/callback.h"
#include "base/command_line.h"
diff --git a/chrome/browser/managed_mode/permission_request_creator_apiary.h b/chrome/browser/supervised_user/permission_request_creator_apiary.h
index 7eb25e8..24dd4cc 100644
--- a/chrome/browser/managed_mode/permission_request_creator_apiary.h
+++ b/chrome/browser/supervised_user/permission_request_creator_apiary.h
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_APIARY_H_
-#define CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_APIARY_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_
-#include "chrome/browser/managed_mode/permission_request_creator.h"
+#include "chrome/browser/supervised_user/permission_request_creator.h"
#include "base/memory/scoped_ptr.h"
#include "google_apis/gaia/oauth2_token_service.h"
@@ -69,4 +69,4 @@ class PermissionRequestCreatorApiary : public PermissionRequestCreator,
scoped_ptr<net::URLFetcher> url_fetcher_;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_PERMISSION_REQUEST_CREATOR_APIARY_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_
diff --git a/chrome/browser/managed_mode/permission_request_creator_sync.cc b/chrome/browser/supervised_user/permission_request_creator_sync.cc
index d7f6190..4ad68c5 100644
--- a/chrome/browser/managed_mode/permission_request_creator_sync.cc
+++ b/chrome/browser/supervised_user/permission_request_creator_sync.cc
@@ -2,21 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/permission_request_creator_sync.h"
+#include "chrome/browser/supervised_user/permission_request_creator_sync.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
#include "chrome/common/chrome_switches.h"
using base::Time;
-const char kManagedUserAccessRequestKeyPrefix[] =
+const char kSupervisedUserAccessRequestKeyPrefix[] =
"X-ManagedUser-AccessRequests";
-const char kManagedUserAccessRequestTime[] = "timestamp";
-const char kManagedUserName[] = "name";
+const char kSupervisedUserAccessRequestTime[] = "timestamp";
+const char kSupervisedUserName[] = "name";
// Key for the notification setting of the custodian. This is a shared setting
// so we can include the setting in the access request data that is used to
@@ -24,14 +24,14 @@ const char kManagedUserName[] = "name";
const char kNotificationSetting[] = "custodian-notification-setting";
PermissionRequestCreatorSync::PermissionRequestCreatorSync(
- ManagedUserSettingsService* settings_service,
- ManagedUserSharedSettingsService* shared_settings_service,
+ SupervisedUserSettingsService* settings_service,
+ SupervisedUserSharedSettingsService* shared_settings_service,
const std::string& name,
- const std::string& managed_user_id)
+ const std::string& supervised_user_id)
: settings_service_(settings_service),
shared_settings_service_(shared_settings_service),
name_(name),
- managed_user_id_(managed_user_id) {
+ supervised_user_id_(supervised_user_id) {
}
PermissionRequestCreatorSync::~PermissionRequestCreatorSync() {}
@@ -40,19 +40,20 @@ void PermissionRequestCreatorSync::CreatePermissionRequest(
const std::string& url_requested,
const base::Closure& callback) {
// Add the prefix.
- std::string key = ManagedUserSettingsService::MakeSplitSettingKey(
- kManagedUserAccessRequestKeyPrefix, url_requested);
+ std::string key = SupervisedUserSettingsService::MakeSplitSettingKey(
+ kSupervisedUserAccessRequestKeyPrefix, url_requested);
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
// TODO(sergiu): Use sane time here when it's ready.
- dict->SetDouble(kManagedUserAccessRequestTime, base::Time::Now().ToJsTime());
+ dict->SetDouble(kSupervisedUserAccessRequestTime,
+ base::Time::Now().ToJsTime());
- dict->SetString(kManagedUserName, name_);
+ dict->SetString(kSupervisedUserName, name_);
// Copy the notification setting of the custodian.
const base::Value* value = shared_settings_service_->GetValue(
- managed_user_id_, kNotificationSetting);
+ supervised_user_id_, kNotificationSetting);
bool notifications_enabled = false;
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAccessRequestNotifications)) {
diff --git a/chrome/browser/supervised_user/permission_request_creator_sync.h b/chrome/browser/supervised_user/permission_request_creator_sync.h
new file mode 100644
index 0000000..196423d
--- /dev/null
+++ b/chrome/browser/supervised_user/permission_request_creator_sync.h
@@ -0,0 +1,36 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_SYNC_H_
+#define CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_SYNC_H_
+
+#include "chrome/browser/supervised_user/permission_request_creator.h"
+
+#include "base/memory/scoped_ptr.h"
+
+class SupervisedUserSettingsService;
+class SupervisedUserSharedSettingsService;
+class ManagedUserSigninManagerWrapper;
+
+class PermissionRequestCreatorSync : public PermissionRequestCreator {
+ public:
+ PermissionRequestCreatorSync(
+ SupervisedUserSettingsService* settings_service,
+ SupervisedUserSharedSettingsService* shared_settings_service,
+ const std::string& name,
+ const std::string& supervised_user_id);
+ virtual ~PermissionRequestCreatorSync();
+
+ // PermissionRequestCreator implementation:
+ virtual void CreatePermissionRequest(const std::string& url_requested,
+ const base::Closure& callback) OVERRIDE;
+
+ private:
+ SupervisedUserSettingsService* settings_service_;
+ SupervisedUserSharedSettingsService* shared_settings_service_;
+ std::string name_;
+ std::string supervised_user_id_;
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_SYNC_H_
diff --git a/chrome/browser/managed_mode/managed_mode_browsertest.cc b/chrome/browser/supervised_user/supervised_user_browsertest.cc
index 9af827e..3400638 100644
--- a/chrome/browser/managed_mode/managed_mode_browsertest.cc
+++ b/chrome/browser/supervised_user/supervised_user_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,14 +10,14 @@
#include "chrome/browser/common/cancelable_request.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/infobars/infobar_service.h"
-#include "chrome/browser/managed_mode/managed_mode_interstitial.h"
-#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_interstitial.h"
+#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -48,7 +48,7 @@ using content::WebContents;
namespace {
// Tests the filter mode in which all sites are blocked by default.
-class ManagedModeBlockModeTest : public InProcessBrowserTest {
+class SupervisedUserBlockModeTest : public InProcessBrowserTest {
public:
// Indicates whether the interstitial should proceed or not.
enum InterstitialAction {
@@ -56,8 +56,8 @@ class ManagedModeBlockModeTest : public InProcessBrowserTest {
INTERSTITIAL_DONTPROCEED,
};
- ManagedModeBlockModeTest() : managed_user_service_(NULL) {}
- virtual ~ManagedModeBlockModeTest() {}
+ SupervisedUserBlockModeTest() : supervised_user_service_(NULL) {}
+ virtual ~SupervisedUserBlockModeTest() {}
void CheckShownPageIsInterstitial(WebContents* tab) {
CheckShownPage(tab, content::PAGE_TYPE_INTERSTITIAL);
@@ -79,7 +79,7 @@ class ManagedModeBlockModeTest : public InProcessBrowserTest {
InterstitialPage* interstitial_page = tab->GetInterstitialPage();
ASSERT_TRUE(interstitial_page);
- // Get the ManagedModeInterstitial delegate.
+ // Get the SupervisedUserInterstitial delegate.
content::InterstitialPageDelegate* delegate =
interstitial_page->GetDelegateForTesting();
@@ -91,7 +91,7 @@ class ManagedModeBlockModeTest : public InProcessBrowserTest {
InterstitialPage* interstitial_page = tab->GetInterstitialPage();
ASSERT_TRUE(interstitial_page);
- // Get the ManagedModeInterstitial delegate.
+ // Get the SupervisedUserInterstitial delegate.
content::InterstitialPageDelegate* delegate =
interstitial_page->GetDelegateForTesting();
@@ -101,20 +101,21 @@ class ManagedModeBlockModeTest : public InProcessBrowserTest {
protected:
virtual void SetUpOnMainThread() OVERRIDE {
- // Set up the ManagedModeNavigationObserver manually since the profile was
- // not managed when the browser was created.
+ // Set up the SupervisedUserNavigationObserver manually since the profile
+ // was not supervised when the browser was created.
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
- ManagedModeNavigationObserver::CreateForWebContents(web_contents);
+ SupervisedUserNavigationObserver::CreateForWebContents(web_contents);
Profile* profile = browser()->profile();
- managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile);
- ManagedUserSettingsService* managed_user_settings_service =
- ManagedUserSettingsServiceFactory::GetForProfile(profile);
- managed_user_settings_service->SetLocalSettingForTesting(
- managed_users::kContentPackDefaultFilteringBehavior,
+ supervised_user_service_ =
+ SupervisedUserServiceFactory::GetForProfile(profile);
+ SupervisedUserSettingsService* supervised_user_settings_service =
+ SupervisedUserSettingsServiceFactory::GetForProfile(profile);
+ supervised_user_settings_service->SetLocalSettingForTesting(
+ supervised_users::kContentPackDefaultFilteringBehavior,
scoped_ptr<base::Value>(
- new base::FundamentalValue(ManagedModeURLFilter::BLOCK)));
+ new base::FundamentalValue(SupervisedUserURLFilter::BLOCK)));
}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
@@ -141,7 +142,7 @@ class ManagedModeBlockModeTest : public InProcessBrowserTest {
base::UTF8ToUTF16(text_query),
options,
&history_request_consumer,
- base::Bind(&ManagedModeBlockModeTest::QueryHistoryComplete,
+ base::Bind(&SupervisedUserBlockModeTest::QueryHistoryComplete,
base::Unretained(this),
results,
&run_loop));
@@ -156,7 +157,7 @@ class ManagedModeBlockModeTest : public InProcessBrowserTest {
run_loop->Quit(); // Will return out to QueryHistory.
}
- ManagedUserService* managed_user_service_;
+ SupervisedUserService* supervised_user_service_;
};
class MockTabStripModelObserver : public TabStripModelObserver {
@@ -177,7 +178,7 @@ class MockTabStripModelObserver : public TabStripModelObserver {
};
// Navigates to a blocked URL.
-IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
+IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
SendAccessRequestOnBlockedURL) {
GURL test_url("http://www.example.com/files/simple.html");
ui_test_utils::NavigateToURL(browser(), test_url);
@@ -200,7 +201,7 @@ IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
// Navigates to a blocked URL in a new tab. We expect the tab to be closed
// automatically on pressing the "back" button on the interstitial.
-IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, OpenBlockedURLInNewTab) {
+IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, OpenBlockedURLInNewTab) {
TabStripModel* tab_strip = browser()->tab_strip_model();
WebContents* prev_tab = tab_strip->GetActiveWebContents();
@@ -224,22 +225,22 @@ IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, OpenBlockedURLInNewTab) {
}
// Tests whether a visit attempt adds a special history entry.
-IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
+IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
HistoryVisitRecorded) {
GURL allowed_url("http://www.example.com/files/simple.html");
// Set the host as allowed.
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true);
- ManagedUserSettingsService* managed_user_settings_service =
- ManagedUserSettingsServiceFactory::GetForProfile(
+ SupervisedUserSettingsService* supervised_user_settings_service =
+ SupervisedUserSettingsServiceFactory::GetForProfile(
browser()->profile());
- managed_user_settings_service->SetLocalSettingForTesting(
- managed_users::kContentPackManualBehaviorHosts,
+ supervised_user_settings_service->SetLocalSettingForTesting(
+ supervised_users::kContentPackManualBehaviorHosts,
dict.PassAs<base::Value>());
EXPECT_EQ(
- ManagedUserService::MANUAL_ALLOW,
- managed_user_service_->GetManualBehaviorForHost(allowed_url.host()));
+ SupervisedUserService::MANUAL_ALLOW,
+ supervised_user_service_->GetManualBehaviorForHost(allowed_url.host()));
ui_test_utils::NavigateToURL(browser(), allowed_url);
@@ -259,11 +260,13 @@ IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
// Check that we went back to the first URL and that the manual behaviors
// have not changed.
EXPECT_EQ(allowed_url.spec(), tab->GetURL().spec());
- EXPECT_EQ(ManagedUserService::MANUAL_ALLOW,
- managed_user_service_->GetManualBehaviorForHost("www.example.com"));
+ EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW,
+ supervised_user_service_->GetManualBehaviorForHost(
+ "www.example.com"));
EXPECT_EQ(
- ManagedUserService::MANUAL_NONE,
- managed_user_service_->GetManualBehaviorForHost("www.new-example.com"));
+ SupervisedUserService::MANUAL_NONE,
+ supervised_user_service_->GetManualBehaviorForHost(
+ "www.new-example.com"));
// Query the history entry.
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
@@ -280,7 +283,7 @@ IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
EXPECT_FALSE(results[1].blocked_visit());
}
-IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, Unblock) {
+IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, Unblock) {
GURL test_url("http://www.example.com/files/simple.html");
ui_test_utils::NavigateToURL(browser(), test_url);
@@ -296,15 +299,15 @@ IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, Unblock) {
// Set the host as allowed.
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
dict->SetBooleanWithoutPathExpansion(test_url.host(), true);
- ManagedUserSettingsService* managed_user_settings_service =
- ManagedUserSettingsServiceFactory::GetForProfile(
+ SupervisedUserSettingsService* supervised_user_settings_service =
+ SupervisedUserSettingsServiceFactory::GetForProfile(
browser()->profile());
- managed_user_settings_service->SetLocalSettingForTesting(
- managed_users::kContentPackManualBehaviorHosts,
+ supervised_user_settings_service->SetLocalSettingForTesting(
+ supervised_users::kContentPackManualBehaviorHosts,
dict.PassAs<base::Value>());
EXPECT_EQ(
- ManagedUserService::MANUAL_ALLOW,
- managed_user_service_->GetManualBehaviorForHost(test_url.host()));
+ SupervisedUserService::MANUAL_ALLOW,
+ supervised_user_service_->GetManualBehaviorForHost(test_url.host()));
observer.Wait();
EXPECT_EQ(test_url, web_contents->GetURL());
diff --git a/chrome/browser/managed_mode/managed_user_constants.cc b/chrome/browser/supervised_user/supervised_user_constants.cc
index 3d2a903..a424075 100644
--- a/chrome/browser/managed_mode/managed_user_constants.cc
+++ b/chrome/browser/supervised_user/supervised_user_constants.cc
@@ -1,10 +1,10 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
-namespace managed_users {
+namespace supervised_users {
const char kContentPackDefaultFilteringBehavior[] =
"ContentPackDefaultFilteringBehavior";
@@ -16,11 +16,11 @@ const char kUserName[] = "UserName";
const char kUserPasswordRecord[] = "UserPasswordRecord";
-const char kManagedUserPseudoEmail[] = "managed_user@localhost";
+const char kSupervisedUserPseudoEmail[] = "managed_user@localhost";
const char kChromeAvatarIndex[] = "chrome-avatar-index";
const char kChromeOSAvatarIndex[] = "chromeos-avatar-index";
const char kChromeOSPasswordData[] = "chromeos-password-data";
-} // namespace managed_users
+} // namespace supervised_users
diff --git a/chrome/browser/managed_mode/managed_user_constants.h b/chrome/browser/supervised_user/supervised_user_constants.h
index c27fc6d..5e17f10 100644
--- a/chrome/browser/managed_mode/managed_user_constants.h
+++ b/chrome/browser/supervised_user/supervised_user_constants.h
@@ -1,14 +1,14 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_CONSTANTS_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_CONSTANTS_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_CONSTANTS_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_CONSTANTS_H_
-namespace managed_users {
+namespace supervised_users {
-// Keys for managed user settings. These are configured remotely and mapped to
-// preferences by the SupervisedUserPrefStore.
+// Keys for supervised user settings. These are configured remotely and mapped
+// to preferences by the SupervisedUserPrefStore.
extern const char kContentPackDefaultFilteringBehavior[];
extern const char kContentPackManualBehaviorHosts[];
extern const char kContentPackManualBehaviorURLs[];
@@ -20,15 +20,15 @@ extern const char kUserPasswordRecord[];
// A pseudo-email address for systems that expect well-formed email addresses
// (like Sync), even though we're not signed in.
-extern const char kManagedUserPseudoEmail[];
+extern const char kSupervisedUserPseudoEmail[];
-// Keys for managed user shared settings. These can be configured remotely or
+// Keys for supervised user shared settings. These can be configured remotely or
// locally, and are mapped to preferences by the
// SupervisedUserPrefMappingService.
extern const char kChromeAvatarIndex[];
extern const char kChromeOSAvatarIndex[];
extern const char kChromeOSPasswordData[];
-} // namespace managed_users
+} // namespace supervised_users
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_CONSTANTS_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_CONSTANTS_H_
diff --git a/chrome/browser/managed_mode/managed_mode_interstitial.cc b/chrome/browser/supervised_user/supervised_user_interstitial.cc
index 0aa1c70..56e7c11 100644
--- a/chrome/browser/managed_mode/managed_mode_interstitial.cc
+++ b/chrome/browser/supervised_user/supervised_user_interstitial.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_mode_interstitial.h"
+#include "chrome/browser/supervised_user/supervised_user_interstitial.h"
#include "base/i18n/rtl.h"
#include "base/metrics/histogram.h"
@@ -10,9 +10,9 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/infobars/infobar_service.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobar_delegate.h"
@@ -34,11 +34,11 @@
using content::BrowserThread;
// static
-void ManagedModeInterstitial::Show(content::WebContents* web_contents,
+void SupervisedUserInterstitial::Show(content::WebContents* web_contents,
const GURL& url,
const base::Callback<void(bool)>& callback) {
- ManagedModeInterstitial* interstitial =
- new ManagedModeInterstitial(web_contents, url, callback);
+ SupervisedUserInterstitial* interstitial =
+ new SupervisedUserInterstitial(web_contents, url, callback);
// If Init() does not complete fully, immediately delete the interstitial.
if (!interstitial->Init())
@@ -46,7 +46,7 @@ void ManagedModeInterstitial::Show(content::WebContents* web_contents,
// Otherwise |interstitial_page_| is responsible for deleting it.
}
-ManagedModeInterstitial::ManagedModeInterstitial(
+SupervisedUserInterstitial::SupervisedUserInterstitial(
content::WebContents* web_contents,
const GURL& url,
const base::Callback<void(bool)>& callback)
@@ -55,9 +55,9 @@ ManagedModeInterstitial::ManagedModeInterstitial(
url_(url),
callback_(callback) {}
-ManagedModeInterstitial::~ManagedModeInterstitial() {}
+SupervisedUserInterstitial::~SupervisedUserInterstitial() {}
-bool ManagedModeInterstitial::Init() {
+bool SupervisedUserInterstitial::Init() {
if (ShouldProceed()) {
// It can happen that the site was only allowed very recently and the URL
// filter on the IO thread had not been updated yet. Proceed with the
@@ -92,22 +92,23 @@ bool ManagedModeInterstitial::Init() {
}
}
- // TODO(bauerb): Extract an observer callback on ManagedUserService for this.
+ // TODO(bauerb): Extract an observer callback on SupervisedUserService for
+ // this.
Profile* profile =
Profile::FromBrowserContext(web_contents_->GetBrowserContext());
PrefService* prefs = profile->GetPrefs();
pref_change_registrar_.Init(prefs);
pref_change_registrar_.Add(
prefs::kDefaultSupervisedUserFilteringBehavior,
- base::Bind(&ManagedModeInterstitial::OnFilteringPrefsChanged,
+ base::Bind(&SupervisedUserInterstitial::OnFilteringPrefsChanged,
base::Unretained(this)));
pref_change_registrar_.Add(
prefs::kSupervisedUserManualHosts,
- base::Bind(&ManagedModeInterstitial::OnFilteringPrefsChanged,
+ base::Bind(&SupervisedUserInterstitial::OnFilteringPrefsChanged,
base::Unretained(this)));
pref_change_registrar_.Add(
prefs::kSupervisedUserManualURLs,
- base::Bind(&ManagedModeInterstitial::OnFilteringPrefsChanged,
+ base::Bind(&SupervisedUserInterstitial::OnFilteringPrefsChanged,
base::Unretained(this)));
languages_ = prefs->GetString(prefs::kAcceptLanguages);
@@ -118,21 +119,21 @@ bool ManagedModeInterstitial::Init() {
return true;
}
-std::string ManagedModeInterstitial::GetHTMLContents() {
+std::string SupervisedUserInterstitial::GetHTMLContents() {
base::DictionaryValue strings;
strings.SetString("blockPageTitle",
l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_TITLE));
Profile* profile =
Profile::FromBrowserContext(web_contents_->GetBrowserContext());
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile);
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile);
- bool allow_access_requests = managed_user_service->AccessRequestsEnabled();
+ bool allow_access_requests = supervised_user_service->AccessRequestsEnabled();
strings.SetBoolean("allowAccessRequests", allow_access_requests);
base::string16 custodian =
- base::UTF8ToUTF16(managed_user_service->GetCustodianName());
+ base::UTF8ToUTF16(supervised_user_service->GetCustodianName());
strings.SetString(
"blockPageMessage",
allow_access_requests
@@ -160,7 +161,7 @@ std::string ManagedModeInterstitial::GetHTMLContents() {
return webui::GetI18nTemplateHtml(html, &strings);
}
-void ManagedModeInterstitial::CommandReceived(const std::string& command) {
+void SupervisedUserInterstitial::CommandReceived(const std::string& command) {
// For use in histograms.
enum Commands {
PREVIEW,
@@ -185,9 +186,9 @@ void ManagedModeInterstitial::CommandReceived(const std::string& command) {
Profile* profile =
Profile::FromBrowserContext(web_contents_->GetBrowserContext());
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile);
- managed_user_service->AddAccessRequest(url_);
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile);
+ supervised_user_service->AddAccessRequest(url_);
DVLOG(1) << "Sent access request for " << url_.spec();
return;
@@ -196,34 +197,35 @@ void ManagedModeInterstitial::CommandReceived(const std::string& command) {
NOTREACHED();
}
-void ManagedModeInterstitial::OnProceed() {
+void SupervisedUserInterstitial::OnProceed() {
// CHECK instead of DCHECK as defense in depth in case we'd accidentally
// proceed on a blocked page.
CHECK(ShouldProceed());
DispatchContinueRequest(true);
}
-void ManagedModeInterstitial::OnDontProceed() {
+void SupervisedUserInterstitial::OnDontProceed() {
DispatchContinueRequest(false);
}
-bool ManagedModeInterstitial::ShouldProceed() {
+bool SupervisedUserInterstitial::ShouldProceed() {
Profile* profile =
Profile::FromBrowserContext(web_contents_->GetBrowserContext());
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile);
- ManagedModeURLFilter* url_filter =
- managed_user_service->GetURLFilterForUIThread();
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile);
+ SupervisedUserURLFilter* url_filter =
+ supervised_user_service->GetURLFilterForUIThread();
return url_filter->GetFilteringBehaviorForURL(url_) !=
- ManagedModeURLFilter::BLOCK;
+ SupervisedUserURLFilter::BLOCK;
}
-void ManagedModeInterstitial::OnFilteringPrefsChanged() {
+void SupervisedUserInterstitial::OnFilteringPrefsChanged() {
if (ShouldProceed())
interstitial_page_->Proceed();
}
-void ManagedModeInterstitial::DispatchContinueRequest(bool continue_request) {
+void SupervisedUserInterstitial::DispatchContinueRequest(
+ bool continue_request) {
// If there is no history entry to go back to, close the tab instead.
int nav_entry_count = web_contents_->GetController().GetEntryCount();
if (!continue_request && nav_entry_count == 0)
diff --git a/chrome/browser/managed_mode/managed_mode_interstitial.h b/chrome/browser/supervised_user/supervised_user_interstitial.h
index 7acc205..790b824 100644
--- a/chrome/browser/managed_mode/managed_mode_interstitial.h
+++ b/chrome/browser/supervised_user/supervised_user_interstitial.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_INTERSTITIAL_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_INTERSTITIAL_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_
#include <string>
@@ -18,20 +18,20 @@ class InterstitialPage;
class WebContents;
}
-// Delegate for an interstitial page when a page is blocked in managed mode
-// because it is not on any whitelist. It lets an authorized user preview the
-// blocked page, to decide later whether to manually allow it.
-class ManagedModeInterstitial : public content::InterstitialPageDelegate {
+// Delegate for an interstitial page when a page is blocked for a supervised
+// user because it is on a blacklist (in "allow everything" mode) or not on any
+// whitelist (in "allow only specified sites" mode).
+class SupervisedUserInterstitial : public content::InterstitialPageDelegate {
public:
static void Show(content::WebContents* web_contents,
const GURL& url,
const base::Callback<void(bool)>& callback);
private:
- ManagedModeInterstitial(content::WebContents* web_contents,
- const GURL& url,
- const base::Callback<void(bool)>& callback);
- virtual ~ManagedModeInterstitial();
+ SupervisedUserInterstitial(content::WebContents* web_contents,
+ const GURL& url,
+ const base::Callback<void(bool)>& callback);
+ virtual ~SupervisedUserInterstitial();
bool Init();
@@ -62,7 +62,7 @@ class ManagedModeInterstitial : public content::InterstitialPageDelegate {
base::Callback<void(bool)> callback_;
- DISALLOW_COPY_AND_ASSIGN(ManagedModeInterstitial);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial);
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_INTERSTITIAL_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_
diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc b/chrome/browser/supervised_user/supervised_user_navigation_observer.cc
index cec5958..0b58bab 100644
--- a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
+++ b/chrome/browser/supervised_user/supervised_user_navigation_observer.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
+#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
#include "base/bind.h"
#include "base/callback.h"
@@ -12,12 +12,12 @@
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/browser/infobars/infobar_service.h"
-#include "chrome/browser/managed_mode/managed_mode_interstitial.h"
-#include "chrome/browser/managed_mode/managed_mode_resource_throttle.h"
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_interstitial.h"
+#include "chrome/browser/supervised_user/supervised_user_resource_throttle.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "components/infobars/core/infobar.h"
@@ -75,17 +75,17 @@ void GoBackToSafety(content::WebContents* web_contents) {
}
#endif
-// ManagedModeWarningInfoBarDelegate ------------------------------------------
+// SupervisedUserWarningInfoBarDelegate ---------------------------------------
-class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate {
+class SupervisedUserWarningInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- // Creates a managed mode warning infobar and delegate and adds the infobar to
- // |infobar_service|. Returns the infobar if it was successfully added.
+ // Creates a supervised user warning infobar and delegate and adds the infobar
+ // to |infobar_service|. Returns the infobar if it was successfully added.
static infobars::InfoBar* Create(InfoBarService* infobar_service);
private:
- ManagedModeWarningInfoBarDelegate();
- virtual ~ManagedModeWarningInfoBarDelegate();
+ SupervisedUserWarningInfoBarDelegate();
+ virtual ~SupervisedUserWarningInfoBarDelegate();
// ConfirmInfoBarDelegate:
virtual bool ShouldExpire(const NavigationDetails& details) const OVERRIDE;
@@ -95,52 +95,52 @@ class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate {
virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
virtual bool Accept() OVERRIDE;
- DISALLOW_COPY_AND_ASSIGN(ManagedModeWarningInfoBarDelegate);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserWarningInfoBarDelegate);
};
// static
-infobars::InfoBar* ManagedModeWarningInfoBarDelegate::Create(
+infobars::InfoBar* SupervisedUserWarningInfoBarDelegate::Create(
InfoBarService* infobar_service) {
return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
scoped_ptr<ConfirmInfoBarDelegate>(
- new ManagedModeWarningInfoBarDelegate())));
+ new SupervisedUserWarningInfoBarDelegate())));
}
-ManagedModeWarningInfoBarDelegate::ManagedModeWarningInfoBarDelegate()
+SupervisedUserWarningInfoBarDelegate::SupervisedUserWarningInfoBarDelegate()
: ConfirmInfoBarDelegate() {
}
-ManagedModeWarningInfoBarDelegate::~ManagedModeWarningInfoBarDelegate() {
+SupervisedUserWarningInfoBarDelegate::~SupervisedUserWarningInfoBarDelegate() {
}
-bool ManagedModeWarningInfoBarDelegate::ShouldExpire(
+bool SupervisedUserWarningInfoBarDelegate::ShouldExpire(
const NavigationDetails& details) const {
- // ManagedModeNavigationObserver removes us below.
+ // SupervisedUserNavigationObserver removes us below.
return false;
}
-void ManagedModeWarningInfoBarDelegate::InfoBarDismissed() {
+void SupervisedUserWarningInfoBarDelegate::InfoBarDismissed() {
content::WebContents* web_contents =
InfoBarService::WebContentsFromInfoBar(infobar());
- ManagedModeNavigationObserver::FromWebContents(
+ SupervisedUserNavigationObserver::FromWebContents(
web_contents)->WarnInfoBarDismissed();
}
-base::string16 ManagedModeWarningInfoBarDelegate::GetMessageText() const {
+base::string16 SupervisedUserWarningInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringUTF16(IDS_MANAGED_USER_WARN_INFOBAR_MESSAGE);
}
-int ManagedModeWarningInfoBarDelegate::GetButtons() const {
+int SupervisedUserWarningInfoBarDelegate::GetButtons() const {
return BUTTON_OK;
}
-base::string16 ManagedModeWarningInfoBarDelegate::GetButtonLabel(
+base::string16 SupervisedUserWarningInfoBarDelegate::GetButtonLabel(
InfoBarButton button) const {
DCHECK_EQ(BUTTON_OK, button);
return l10n_util::GetStringUTF16(IDS_MANAGED_USER_WARN_INFOBAR_GO_BACK);
}
-bool ManagedModeWarningInfoBarDelegate::Accept() {
+bool SupervisedUserWarningInfoBarDelegate::Accept() {
#if defined(OS_ANDROID)
// TODO(bauerb): Get rid of the platform-specific #ifdef here.
// http://crbug.com/313377
@@ -155,35 +155,36 @@ bool ManagedModeWarningInfoBarDelegate::Accept() {
} // namespace
-// ManagedModeNavigationObserver ----------------------------------------------
+// SupervisedUserNavigationObserver -------------------------------------------
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagedModeNavigationObserver);
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(SupervisedUserNavigationObserver);
-ManagedModeNavigationObserver::~ManagedModeNavigationObserver() {
+SupervisedUserNavigationObserver::~SupervisedUserNavigationObserver() {
}
-ManagedModeNavigationObserver::ManagedModeNavigationObserver(
+SupervisedUserNavigationObserver::SupervisedUserNavigationObserver(
content::WebContents* web_contents)
: WebContentsObserver(web_contents),
warn_infobar_(NULL) {
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
- managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile);
- url_filter_ = managed_user_service_->GetURLFilterForUIThread();
+ supervised_user_service_ =
+ SupervisedUserServiceFactory::GetForProfile(profile);
+ url_filter_ = supervised_user_service_->GetURLFilterForUIThread();
}
-void ManagedModeNavigationObserver::WarnInfoBarDismissed() {
+void SupervisedUserNavigationObserver::WarnInfoBarDismissed() {
DCHECK(warn_infobar_);
warn_infobar_ = NULL;
}
-void ManagedModeNavigationObserver::ProvisionalChangeToMainFrameUrl(
+void SupervisedUserNavigationObserver::ProvisionalChangeToMainFrameUrl(
const GURL& url,
content::RenderFrameHost* render_frame_host) {
- ManagedModeURLFilter::FilteringBehavior behavior =
+ SupervisedUserURLFilter::FilteringBehavior behavior =
url_filter_->GetFilteringBehaviorForURL(url);
- if (behavior == ManagedModeURLFilter::WARN || !warn_infobar_)
+ if (behavior == SupervisedUserURLFilter::WARN || !warn_infobar_)
return;
// If we shouldn't have a warn infobar remove it here.
@@ -191,7 +192,7 @@ void ManagedModeNavigationObserver::ProvisionalChangeToMainFrameUrl(
warn_infobar_ = NULL;
}
-void ManagedModeNavigationObserver::DidCommitProvisionalLoadForFrame(
+void SupervisedUserNavigationObserver::DidCommitProvisionalLoadForFrame(
int64 frame_id,
const base::string16& frame_unique_name,
bool is_main_frame,
@@ -202,17 +203,17 @@ void ManagedModeNavigationObserver::DidCommitProvisionalLoadForFrame(
return;
DVLOG(1) << "DidCommitProvisionalLoadForFrame " << url.spec();
- ManagedModeURLFilter::FilteringBehavior behavior =
+ SupervisedUserURLFilter::FilteringBehavior behavior =
url_filter_->GetFilteringBehaviorForURL(url);
- if (behavior == ManagedModeURLFilter::WARN && !warn_infobar_) {
- warn_infobar_ = ManagedModeWarningInfoBarDelegate::Create(
+ if (behavior == SupervisedUserURLFilter::WARN && !warn_infobar_) {
+ warn_infobar_ = SupervisedUserWarningInfoBarDelegate::Create(
InfoBarService::FromWebContents(web_contents()));
}
}
// static
-void ManagedModeNavigationObserver::OnRequestBlocked(
+void SupervisedUserNavigationObserver::OnRequestBlocked(
int render_process_host_id,
int render_view_id,
const GURL& url,
@@ -225,16 +226,17 @@ void ManagedModeNavigationObserver::OnRequestBlocked(
return;
}
- ManagedModeNavigationObserver* navigation_observer =
- ManagedModeNavigationObserver::FromWebContents(web_contents);
+ SupervisedUserNavigationObserver* navigation_observer =
+ SupervisedUserNavigationObserver::FromWebContents(web_contents);
if (navigation_observer)
navigation_observer->OnRequestBlockedInternal(url);
// Show the interstitial.
- ManagedModeInterstitial::Show(web_contents, url, callback);
+ SupervisedUserInterstitial::Show(web_contents, url, callback);
}
-void ManagedModeNavigationObserver::OnRequestBlockedInternal(const GURL& url) {
+void SupervisedUserNavigationObserver::OnRequestBlockedInternal(
+ const GURL& url) {
Time timestamp = Time::Now(); // TODO(bauerb): Use SaneTime when available.
// Create a history entry for the attempt and mark it as such.
history::HistoryAddPageArgs add_page_args(
@@ -257,7 +259,7 @@ void ManagedModeNavigationObserver::OnRequestBlockedInternal(const GURL& url) {
entry->SetVirtualURL(url);
entry->SetTimestamp(timestamp);
blocked_navigations_.push_back(entry.release());
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile);
- managed_user_service->DidBlockNavigation(web_contents());
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile);
+ supervised_user_service->DidBlockNavigation(web_contents());
}
diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.h b/chrome/browser/supervised_user/supervised_user_navigation_observer.h
index 4a484d7..6822eeb 100644
--- a/chrome/browser/managed_mode/managed_mode_navigation_observer.h
+++ b/chrome/browser/supervised_user/supervised_user_navigation_observer.h
@@ -1,21 +1,21 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_NAVIGATION_OBSERVER_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_NAVIGATION_OBSERVER_H_
#include <set>
#include <vector>
#include "base/memory/scoped_vector.h"
#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
-class ManagedModeURLFilter;
-class ManagedUserService;
+class SupervisedUserService;
+class SupervisedUserURLFilter;
namespace content {
class NavigationEntry;
@@ -25,11 +25,11 @@ namespace infobars {
class InfoBar;
}
-class ManagedModeNavigationObserver
+class SupervisedUserNavigationObserver
: public content::WebContentsObserver,
- public content::WebContentsUserData<ManagedModeNavigationObserver> {
+ public content::WebContentsUserData<SupervisedUserNavigationObserver> {
public:
- virtual ~ManagedModeNavigationObserver();
+ virtual ~SupervisedUserNavigationObserver();
// Sets the specific infobar as dismissed.
void WarnInfoBarDismissed();
@@ -46,9 +46,9 @@ class ManagedModeNavigationObserver
const base::Callback<void(bool)>& callback);
private:
- friend class content::WebContentsUserData<ManagedModeNavigationObserver>;
+ friend class content::WebContentsUserData<SupervisedUserNavigationObserver>;
- explicit ManagedModeNavigationObserver(content::WebContents* web_contents);
+ explicit SupervisedUserNavigationObserver(content::WebContents* web_contents);
// content::WebContentsObserver implementation.
virtual void ProvisionalChangeToMainFrameUrl(
@@ -65,17 +65,17 @@ class ManagedModeNavigationObserver
void OnRequestBlockedInternal(const GURL& url);
// Owned by the profile, so outlives us.
- ManagedUserService* managed_user_service_;
+ SupervisedUserService* supervised_user_service_;
- // Owned by ManagedUserService.
- const ManagedModeURLFilter* url_filter_;
+ // Owned by SupervisedUserService.
+ const SupervisedUserURLFilter* url_filter_;
// Owned by the InfoBarService, which has the same lifetime as this object.
infobars::InfoBar* warn_infobar_;
ScopedVector<const content::NavigationEntry> blocked_navigations_;
- DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserNavigationObserver);
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_NAVIGATION_OBSERVER_H_
diff --git a/chrome/browser/managed_mode/supervised_user_pref_mapping_service.cc b/chrome/browser/supervised_user/supervised_user_pref_mapping_service.cc
index dce8165..b70ae63 100644
--- a/chrome/browser/managed_mode/supervised_user_pref_mapping_service.cc
+++ b/chrome/browser/supervised_user/supervised_user_pref_mapping_service.cc
@@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/supervised_user_pref_mapping_service.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_mapping_service.h"
#include "base/bind.h"
#include "base/prefs/pref_service.h"
#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
#include "chrome/common/pref_names.h"
const int kNoAvatar = -1;
SupervisedUserPrefMappingService::SupervisedUserPrefMappingService(
PrefService* prefs,
- ManagedUserSharedSettingsService* shared_settings)
+ SupervisedUserSharedSettingsService* shared_settings)
: prefs_(prefs),
shared_settings_(shared_settings),
- managed_user_id_(prefs->GetString(prefs::kSupervisedUserId)),
+ supervised_user_id_(prefs->GetString(prefs::kSupervisedUserId)),
weak_ptr_factory_(this) {}
SupervisedUserPrefMappingService::~SupervisedUserPrefMappingService() {}
@@ -36,10 +36,12 @@ void SupervisedUserPrefMappingService::Init() {
// Check if we need to update the shared setting with the avatar index.
// Otherwise we update the user pref in case we missed a notification.
- if (GetChromeAvatarIndex() == kNoAvatar)
+ if (GetChromeAvatarIndex() == kNoAvatar) {
OnAvatarChanged();
- else
- OnSharedSettingChanged(managed_user_id_, managed_users::kChromeAvatarIndex);
+ } else {
+ OnSharedSettingChanged(supervised_user_id_,
+ supervised_users::kChromeAvatarIndex);
+ }
}
void SupervisedUserPrefMappingService::OnAvatarChanged() {
@@ -52,19 +54,19 @@ void SupervisedUserPrefMappingService::OnAvatarChanged() {
return;
// If yes, update the shared settings value.
- shared_settings_->SetValue(managed_user_id_,
- managed_users::kChromeAvatarIndex,
+ shared_settings_->SetValue(supervised_user_id_,
+ supervised_users::kChromeAvatarIndex,
base::FundamentalValue(new_avatar_index));
}
void SupervisedUserPrefMappingService::OnSharedSettingChanged(
- const std::string& mu_id,
+ const std::string& su_id,
const std::string& key) {
- DCHECK_EQ(mu_id, managed_user_id_);
- if (key != managed_users::kChromeAvatarIndex)
+ DCHECK_EQ(su_id, supervised_user_id_);
+ if (key != supervised_users::kChromeAvatarIndex)
return;
- const base::Value* value = shared_settings_->GetValue(mu_id, key);
+ const base::Value* value = shared_settings_->GetValue(su_id, key);
int avatar_index;
bool success = value->GetAsInteger(&avatar_index);
DCHECK(success);
@@ -77,7 +79,7 @@ void SupervisedUserPrefMappingService::Shutdown() {
int SupervisedUserPrefMappingService::GetChromeAvatarIndex() {
const base::Value* value = shared_settings_->GetValue(
- managed_user_id_, managed_users::kChromeAvatarIndex);
+ supervised_user_id_, supervised_users::kChromeAvatarIndex);
if (!value)
return kNoAvatar;
diff --git a/chrome/browser/managed_mode/supervised_user_pref_mapping_service.h b/chrome/browser/supervised_user/supervised_user_pref_mapping_service.h
index 1f0f96c..bcabd92 100644
--- a/chrome/browser/managed_mode/supervised_user_pref_mapping_service.h
+++ b/chrome/browser/supervised_user/supervised_user_pref_mapping_service.h
@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_SUPERVISED_USER_PREF_MAPPING_SERVICE_H_
-#define CHROME_BROWSER_MANAGED_MODE_SUPERVISED_USER_PREF_MAPPING_SERVICE_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_PREF_MAPPING_SERVICE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_PREF_MAPPING_SERVICE_H_
#include "base/callback.h"
#include "base/callback_list.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/prefs/pref_change_registrar.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "components/keyed_service/core/keyed_service.h"
-class ManagedUserSharedSettingsService;
class PrefService;
+class SupervisedUserSharedSettingsService;
-// SupervisedUserPrefMappingService maps shared managed user settings to user
-// preferences. When a shared managed user setting is updated via sync, the
+// SupervisedUserPrefMappingService maps shared supervised user settings to user
+// preferences. When a shared supervised user setting is updated via sync, the
// corresponding local user preference is set to this new value.
class SupervisedUserPrefMappingService : public KeyedService {
public:
@@ -26,7 +26,7 @@ class SupervisedUserPrefMappingService : public KeyedService {
SupervisedUserPrefMappingService(
PrefService* prefs,
- ManagedUserSharedSettingsService* shared_settings);
+ SupervisedUserSharedSettingsService* shared_settings);
virtual ~SupervisedUserPrefMappingService();
// KeyedService implementation:
@@ -34,26 +34,26 @@ class SupervisedUserPrefMappingService : public KeyedService {
void Init();
- // Updates the managed user shared setting when the avatar has changed.
+ // Updates the supervised user shared setting when the avatar has changed.
void OnAvatarChanged();
- // Called when a managed user shared setting was changed by receiving new sync
- // data. Updates the corresponding user pref.
- void OnSharedSettingChanged(const std::string& mu_id, const std::string& key);
+ // Called when a supervised user shared setting was changed by receiving new
+ // sync data. Updates the corresponding user pref.
+ void OnSharedSettingChanged(const std::string& su_id, const std::string& key);
private:
- // Returns the current chrome avatar index that is stored as a managed user
+ // Returns the current chrome avatar index that is stored as a supervised user
// shared setting, or -1 if no avatar index is stored.
int GetChromeAvatarIndex();
PrefService* prefs_;
- ManagedUserSharedSettingsService* shared_settings_;
+ SupervisedUserSharedSettingsService* shared_settings_;
scoped_ptr<CallbackList::Subscription> subscription_;
- std::string managed_user_id_;
+ std::string supervised_user_id_;
PrefChangeRegistrar pref_change_registrar_;
base::WeakPtrFactory<SupervisedUserPrefMappingService> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SupervisedUserPrefMappingService);
};
-#endif // CHROME_BROWSER_MANAGED_MODE_SUPERVISED_USER_PREF_MAPPING_SERVICE_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_PREF_MAPPING_SERVICE_H_
diff --git a/chrome/browser/managed_mode/supervised_user_pref_mapping_service_factory.cc b/chrome/browser/supervised_user/supervised_user_pref_mapping_service_factory.cc
index bef54d8..55a8fb9 100644
--- a/chrome/browser/managed_mode/supervised_user_pref_mapping_service_factory.cc
+++ b/chrome/browser/supervised_user/supervised_user_pref_mapping_service_factory.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/supervised_user_pref_mapping_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_mapping_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/supervised_user_pref_mapping_service.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_mapping_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
@@ -29,7 +29,7 @@ SupervisedUserPrefMappingServiceFactory::
: BrowserContextKeyedServiceFactory(
"SupervisedUserPrefMappingService",
BrowserContextDependencyManager::GetInstance()) {
- DependsOn(ManagedUserSharedSettingsServiceFactory::GetInstance());
+ DependsOn(SupervisedUserSharedSettingsServiceFactory::GetInstance());
}
SupervisedUserPrefMappingServiceFactory::
@@ -39,5 +39,6 @@ KeyedService* SupervisedUserPrefMappingServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
return new SupervisedUserPrefMappingService(
user_prefs::UserPrefs::Get(profile),
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile));
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ profile));
}
diff --git a/chrome/browser/managed_mode/supervised_user_pref_mapping_service_factory.h b/chrome/browser/supervised_user/supervised_user_pref_mapping_service_factory.h
index 5258f64..abf7cc3 100644
--- a/chrome/browser/managed_mode/supervised_user_pref_mapping_service_factory.h
+++ b/chrome/browser/supervised_user/supervised_user_pref_mapping_service_factory.h
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_SUPERVISED_USER_PREF_MAPPING_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_MANAGED_MODE_SUPERVISED_USER_PREF_MAPPING_SERVICE_FACTORY_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_PREF_MAPPING_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_PREF_MAPPING_SERVICE_FACTORY_H_
#include "base/memory/singleton.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class SupervisedUserPrefMappingService;
@@ -30,4 +30,4 @@ class SupervisedUserPrefMappingServiceFactory
content::BrowserContext* profile) const OVERRIDE;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_SUPERVISED_USER_PREF_MAPPING_SERVICE_FACTORY_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_PREF_MAPPING_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/supervised_user_pref_mapping_service_unittest.cc b/chrome/browser/supervised_user/supervised_user_pref_mapping_service_unittest.cc
index 88e836f..4a553b9 100644
--- a/chrome/browser/managed_mode/supervised_user_pref_mapping_service_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_pref_mapping_service_unittest.cc
@@ -5,11 +5,11 @@
#include <string>
#include "base/prefs/pref_service.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/supervised_user_pref_mapping_service.h"
-#include "chrome/browser/managed_mode/supervised_user_pref_mapping_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_mapping_service.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_mapping_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,7 +22,7 @@ class SupervisedUserPrefMappingServiceTest : public ::testing::Test {
profile_.GetPrefs()->SetString(prefs::kSupervisedUserId,
kFakeSupervisedUserId);
shared_settings_service_ =
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
&profile_);
mapping_service_ =
SupervisedUserPrefMappingServiceFactory::GetForBrowserContext(
@@ -41,17 +41,17 @@ class SupervisedUserPrefMappingServiceTest : public ::testing::Test {
}
TestingProfile profile_;
- ManagedUserSharedSettingsService* shared_settings_service_;
+ SupervisedUserSharedSettingsService* shared_settings_service_;
SupervisedUserPrefMappingService* mapping_service_;
};
TEST_F(SupervisedUserPrefMappingServiceTest, CheckPrefUpdate) {
EXPECT_TRUE(shared_settings_service_->GetValue(
- kFakeSupervisedUserId, managed_users::kChromeAvatarIndex) ==
- NULL);
+ kFakeSupervisedUserId,
+ supervised_users::kChromeAvatarIndex) == NULL);
profile_.GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, 4);
const base::Value* value = shared_settings_service_->GetValue(
- kFakeSupervisedUserId, managed_users::kChromeAvatarIndex);
+ kFakeSupervisedUserId, supervised_users::kChromeAvatarIndex);
int avatar_index;
value->GetAsInteger(&avatar_index);
EXPECT_EQ(avatar_index, 4);
@@ -60,9 +60,10 @@ TEST_F(SupervisedUserPrefMappingServiceTest, CheckPrefUpdate) {
TEST_F(SupervisedUserPrefMappingServiceTest, CheckSharedSettingUpdate) {
EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), -1);
shared_settings_service_->SetValue(kFakeSupervisedUserId,
- managed_users::kChromeAvatarIndex,
+ supervised_users::kChromeAvatarIndex,
base::FundamentalValue(1));
- mapping_service_->OnSharedSettingChanged(kFakeSupervisedUserId,
- managed_users::kChromeAvatarIndex);
+ mapping_service_->OnSharedSettingChanged(
+ kFakeSupervisedUserId,
+ supervised_users::kChromeAvatarIndex);
EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), 1);
}
diff --git a/chrome/browser/managed_mode/supervised_user_pref_store.cc b/chrome/browser/supervised_user/supervised_user_pref_store.cc
index ceaeec2..5d0dab4 100644
--- a/chrome/browser/managed_mode/supervised_user_pref_store.cc
+++ b/chrome/browser/supervised_user/supervised_user_pref_store.cc
@@ -1,50 +1,50 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/supervised_user_pref_store.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_store.h"
#include "base/bind.h"
#include "base/prefs/pref_value_map.h"
#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "chrome/common/pref_names.h"
using base::FundamentalValue;
namespace {
-struct ManagedUserSettingsPrefMappingEntry {
+struct SupervisedUserSettingsPrefMappingEntry {
const char* settings_name;
const char* pref_name;
};
-ManagedUserSettingsPrefMappingEntry kManagedUserSettingsPrefMapping[] = {
+SupervisedUserSettingsPrefMappingEntry kSupervisedUserSettingsPrefMapping[] = {
{
- managed_users::kContentPackDefaultFilteringBehavior,
+ supervised_users::kContentPackDefaultFilteringBehavior,
prefs::kDefaultSupervisedUserFilteringBehavior,
},
{
- managed_users::kContentPackManualBehaviorHosts,
+ supervised_users::kContentPackManualBehaviorHosts,
prefs::kSupervisedUserManualHosts,
},
{
- managed_users::kContentPackManualBehaviorURLs,
+ supervised_users::kContentPackManualBehaviorURLs,
prefs::kSupervisedUserManualURLs,
},
{
- managed_users::kForceSafeSearch,
+ supervised_users::kForceSafeSearch,
prefs::kForceSafeSearch,
},
{
- managed_users::kSigninAllowed,
+ supervised_users::kSigninAllowed,
prefs::kSigninAllowed,
},
{
- managed_users::kUserName,
+ supervised_users::kUserName,
prefs::kProfileName,
},
};
@@ -52,9 +52,9 @@ ManagedUserSettingsPrefMappingEntry kManagedUserSettingsPrefMapping[] = {
} // namespace
SupervisedUserPrefStore::SupervisedUserPrefStore(
- ManagedUserSettingsService* managed_user_settings_service)
+ SupervisedUserSettingsService* supervised_user_settings_service)
: weak_ptr_factory_(this) {
- managed_user_settings_service->Subscribe(
+ supervised_user_settings_service->Subscribe(
base::Bind(&SupervisedUserPrefStore::OnNewSettingsAvailable,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -93,17 +93,17 @@ void SupervisedUserPrefStore::OnNewSettingsAvailable(
prefs_->SetValue(prefs::kAllowDeletingBrowserHistory,
new FundamentalValue(false));
prefs_->SetValue(prefs::kDefaultSupervisedUserFilteringBehavior,
- new FundamentalValue(ManagedModeURLFilter::ALLOW));
+ new FundamentalValue(SupervisedUserURLFilter::ALLOW));
prefs_->SetValue(prefs::kForceSafeSearch, new FundamentalValue(true));
prefs_->SetValue(prefs::kHideWebStoreIcon, new FundamentalValue(true));
prefs_->SetValue(prefs::kIncognitoModeAvailability,
new FundamentalValue(IncognitoModePrefs::DISABLED));
prefs_->SetValue(prefs::kSigninAllowed, new FundamentalValue(false));
- // Copy managed user settings to prefs.
- for (size_t i = 0; i < arraysize(kManagedUserSettingsPrefMapping); ++i) {
- const ManagedUserSettingsPrefMappingEntry& entry =
- kManagedUserSettingsPrefMapping[i];
+ // Copy supervised user settings to prefs.
+ for (size_t i = 0; i < arraysize(kSupervisedUserSettingsPrefMapping); ++i) {
+ const SupervisedUserSettingsPrefMappingEntry& entry =
+ kSupervisedUserSettingsPrefMapping[i];
const base::Value* value = NULL;
if (settings->GetWithoutPathExpansion(entry.settings_name, &value))
prefs_->SetValue(entry.pref_name, value->DeepCopy());
diff --git a/chrome/browser/managed_mode/supervised_user_pref_store.h b/chrome/browser/supervised_user/supervised_user_pref_store.h
index e4180f4..98df2c2 100644
--- a/chrome/browser/managed_mode/supervised_user_pref_store.h
+++ b/chrome/browser/supervised_user/supervised_user_pref_store.h
@@ -1,29 +1,29 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_SUPERVISED_USER_PREF_STORE_H_
-#define CHROME_BROWSER_MANAGED_MODE_SUPERVISED_USER_PREF_STORE_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_PREF_STORE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_PREF_STORE_H_
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/prefs/pref_store.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
namespace base {
class DictionaryValue;
class Value;
}
-class ManagedUserSettingsService;
class PrefValueMap;
+class SupervisedUserSettingsService;
-// A PrefStore that gets its values from managed user settings via the
-// ManagedUserSettingsService passed in at construction.
+// A PrefStore that gets its values from supervised user settings via the
+// SupervisedUserSettingsService passed in at construction.
class SupervisedUserPrefStore : public PrefStore {
public:
SupervisedUserPrefStore(
- ManagedUserSettingsService* managed_user_settings_service);
+ SupervisedUserSettingsService* supervised_user_settings_service);
// PrefStore overrides:
virtual bool GetValue(const std::string& key,
@@ -45,4 +45,4 @@ class SupervisedUserPrefStore : public PrefStore {
base::WeakPtrFactory<SupervisedUserPrefStore> weak_ptr_factory_;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_SUPERVISED_USER_PREF_STORE_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_PREF_STORE_H_
diff --git a/chrome/browser/managed_mode/supervised_user_pref_store_unittest.cc b/chrome/browser/supervised_user/supervised_user_pref_store_unittest.cc
index 4028b9d..ee0a001 100644
--- a/chrome/browser/managed_mode/supervised_user_pref_store_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_pref_store_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,9 +8,9 @@
#include "base/memory/ref_counted.h"
#include "base/prefs/testing_pref_store.h"
#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/managed_mode/supervised_user_pref_store.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_store.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
#include "chrome/common/pref_names.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,7 +22,7 @@ namespace {
class SupervisedUserPrefStoreFixture : public PrefStore::Observer {
public:
explicit SupervisedUserPrefStoreFixture(
- ManagedUserSettingsService* settings_service);
+ SupervisedUserSettingsService* settings_service);
virtual ~SupervisedUserPrefStoreFixture();
base::DictionaryValue* changed_prefs() {
@@ -37,14 +37,14 @@ class SupervisedUserPrefStoreFixture : public PrefStore::Observer {
virtual void OnPrefValueChanged(const std::string& key) OVERRIDE;
virtual void OnInitializationCompleted(bool succeeded) OVERRIDE;
-private:
+ private:
scoped_refptr<SupervisedUserPrefStore> pref_store_;
base::DictionaryValue changed_prefs_;
bool initialization_completed_;
};
SupervisedUserPrefStoreFixture::SupervisedUserPrefStoreFixture(
- ManagedUserSettingsService* settings_service)
+ SupervisedUserSettingsService* settings_service)
: pref_store_(new SupervisedUserPrefStore(settings_service)),
initialization_completed_(pref_store_->IsInitializationComplete()) {
pref_store_->AddObserver(this);
@@ -76,7 +76,7 @@ class SupervisedUserPrefStoreTest : public ::testing::Test {
virtual void TearDown() OVERRIDE;
protected:
- ManagedUserSettingsService service_;
+ SupervisedUserSettingsService service_;
scoped_refptr<TestingPrefStore> pref_store_;
};
@@ -101,18 +101,18 @@ TEST_F(SupervisedUserPrefStoreTest, ConfigureSettings) {
service_.SetActive(true);
- // kAllowDeletingBrowserHistory is hardcoded to false for managed users.
+ // kAllowDeletingBrowserHistory is hardcoded to false for supervised users.
bool allow_deleting_browser_history = true;
EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(
prefs::kAllowDeletingBrowserHistory, &allow_deleting_browser_history));
EXPECT_FALSE(allow_deleting_browser_history);
- // kManagedModeManualHosts does not have a hardcoded value.
+ // kSupervisedModeManualHosts does not have a hardcoded value.
base::DictionaryValue* manual_hosts = NULL;
EXPECT_FALSE(fixture.changed_prefs()->GetDictionary(
prefs::kSupervisedUserManualHosts, &manual_hosts));
- // kForceSafeSearch defaults to true for managed users.
+ // kForceSafeSearch defaults to true for supervised users.
bool force_safesearch = false;
EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceSafeSearch,
&force_safesearch));
@@ -123,12 +123,12 @@ TEST_F(SupervisedUserPrefStoreTest, ConfigureSettings) {
service_.SetActive(true);
EXPECT_EQ(0u, fixture.changed_prefs()->size());
- // kManagedModeManualHosts can be configured by the custodian.
+ // kSupervisedModeManualHosts can be configured by the custodian.
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
dict->SetBoolean("example.com", true);
dict->SetBoolean("moose.org", false);
service_.SetLocalSettingForTesting(
- managed_users::kContentPackManualBehaviorHosts,
+ supervised_users::kContentPackManualBehaviorHosts,
scoped_ptr<base::Value>(dict->DeepCopy()));
EXPECT_EQ(1u, fixture.changed_prefs()->size());
ASSERT_TRUE(fixture.changed_prefs()->GetDictionary(
@@ -139,7 +139,7 @@ TEST_F(SupervisedUserPrefStoreTest, ConfigureSettings) {
// hardcoded default.
fixture.changed_prefs()->Clear();
service_.SetLocalSettingForTesting(
- managed_users::kForceSafeSearch,
+ supervised_users::kForceSafeSearch,
scoped_ptr<base::Value>(new base::FundamentalValue(false)));
EXPECT_EQ(1u, fixture.changed_prefs()->size());
EXPECT_TRUE(fixture.changed_prefs()->GetBoolean(prefs::kForceSafeSearch,
diff --git a/chrome/browser/managed_mode/managed_user_refresh_token_fetcher.cc b/chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.cc
index 4c25d87..afbdfc0 100644
--- a/chrome/browser/managed_mode/managed_user_refresh_token_fetcher.cc
+++ b/chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h"
+#include "chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h"
#include "base/callback.h"
#include "base/json/json_reader.h"
@@ -45,19 +45,20 @@ static const char kAuthorizationHeaderFormat[] =
static const char kCodeKey[] = "code";
-class ManagedUserRefreshTokenFetcherImpl
- : public ManagedUserRefreshTokenFetcher,
+class SupervisedUserRefreshTokenFetcherImpl
+ : public SupervisedUserRefreshTokenFetcher,
public OAuth2TokenService::Consumer,
public URLFetcherDelegate,
public GaiaOAuthClient::Delegate {
public:
- ManagedUserRefreshTokenFetcherImpl(OAuth2TokenService* oauth2_token_service,
- const std::string& account_id,
- URLRequestContextGetter* context);
- virtual ~ManagedUserRefreshTokenFetcherImpl();
-
- // ManagedUserRefreshTokenFetcher implementation:
- virtual void Start(const std::string& managed_user_id,
+ SupervisedUserRefreshTokenFetcherImpl(
+ OAuth2TokenService* oauth2_token_service,
+ const std::string& account_id,
+ URLRequestContextGetter* context);
+ virtual ~SupervisedUserRefreshTokenFetcherImpl();
+
+ // SupervisedUserRefreshTokenFetcher implementation:
+ virtual void Start(const std::string& supervised_user_id,
const std::string& device_name,
const TokenCallback& callback) OVERRIDE;
@@ -94,7 +95,7 @@ class ManagedUserRefreshTokenFetcherImpl
URLRequestContextGetter* context_;
std::string device_name_;
- std::string managed_user_id_;
+ std::string supervised_user_id_;
TokenCallback callback_;
scoped_ptr<OAuth2TokenService::Request> access_token_request_;
@@ -104,37 +105,38 @@ class ManagedUserRefreshTokenFetcherImpl
scoped_ptr<GaiaOAuthClient> gaia_oauth_client_;
};
-ManagedUserRefreshTokenFetcherImpl::ManagedUserRefreshTokenFetcherImpl(
+SupervisedUserRefreshTokenFetcherImpl::SupervisedUserRefreshTokenFetcherImpl(
OAuth2TokenService* oauth2_token_service,
const std::string& account_id,
URLRequestContextGetter* context)
- : OAuth2TokenService::Consumer("managed_user"),
+ : OAuth2TokenService::Consumer("supervised_user"),
oauth2_token_service_(oauth2_token_service),
account_id_(account_id),
context_(context),
access_token_expired_(false) {}
-ManagedUserRefreshTokenFetcherImpl::~ManagedUserRefreshTokenFetcherImpl() {}
+SupervisedUserRefreshTokenFetcherImpl::
+~SupervisedUserRefreshTokenFetcherImpl() {}
-void ManagedUserRefreshTokenFetcherImpl::Start(
- const std::string& managed_user_id,
+void SupervisedUserRefreshTokenFetcherImpl::Start(
+ const std::string& supervised_user_id,
const std::string& device_name,
const TokenCallback& callback) {
DCHECK(callback_.is_null());
- managed_user_id_ = managed_user_id;
+ supervised_user_id_ = supervised_user_id;
device_name_ = device_name;
callback_ = callback;
StartFetching();
}
-void ManagedUserRefreshTokenFetcherImpl::StartFetching() {
+void SupervisedUserRefreshTokenFetcherImpl::StartFetching() {
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kOAuth1LoginScope);
access_token_request_ = oauth2_token_service_->StartRequest(
account_id_, scopes, this);
}
-void ManagedUserRefreshTokenFetcherImpl::OnGetTokenSuccess(
+void SupervisedUserRefreshTokenFetcherImpl::OnGetTokenSuccess(
const OAuth2TokenService::Request* request,
const std::string& access_token,
const Time& expiration_time) {
@@ -160,14 +162,14 @@ void ManagedUserRefreshTokenFetcherImpl::OnGetTokenSuccess(
net::EscapeUrlEncodedData(
GaiaUrls::GetInstance()->oauth2_chrome_client_id(), true).c_str(),
net::EscapeUrlEncodedData(kChromeSyncSupervisedOAuth2Scope, true).c_str(),
- net::EscapeUrlEncodedData(managed_user_id_, true).c_str(),
+ net::EscapeUrlEncodedData(supervised_user_id_, true).c_str(),
net::EscapeUrlEncodedData(device_name_, true).c_str());
url_fetcher_->SetUploadData("application/x-www-form-urlencoded", body);
url_fetcher_->Start();
}
-void ManagedUserRefreshTokenFetcherImpl::OnGetTokenFailure(
+void SupervisedUserRefreshTokenFetcherImpl::OnGetTokenFailure(
const OAuth2TokenService::Request* request,
const GoogleServiceAuthError& error) {
DCHECK_EQ(access_token_request_.get(), request);
@@ -175,7 +177,7 @@ void ManagedUserRefreshTokenFetcherImpl::OnGetTokenFailure(
callback_.Reset();
}
-void ManagedUserRefreshTokenFetcherImpl::OnURLFetchComplete(
+void SupervisedUserRefreshTokenFetcherImpl::OnURLFetchComplete(
const URLFetcher* source) {
const net::URLRequestStatus& status = source->GetStatus();
if (!status.is_success()) {
@@ -225,7 +227,7 @@ void ManagedUserRefreshTokenFetcherImpl::OnURLFetchComplete(
this);
}
-void ManagedUserRefreshTokenFetcherImpl::OnGetTokensResponse(
+void SupervisedUserRefreshTokenFetcherImpl::OnGetTokensResponse(
const std::string& refresh_token,
const std::string& access_token,
int expires_in_seconds) {
@@ -235,19 +237,19 @@ void ManagedUserRefreshTokenFetcherImpl::OnGetTokensResponse(
refresh_token);
}
-void ManagedUserRefreshTokenFetcherImpl::OnRefreshTokenResponse(
+void SupervisedUserRefreshTokenFetcherImpl::OnRefreshTokenResponse(
const std::string& access_token,
int expires_in_seconds) {
NOTREACHED();
}
-void ManagedUserRefreshTokenFetcherImpl::OnOAuthError() {
+void SupervisedUserRefreshTokenFetcherImpl::OnOAuthError() {
DispatchGoogleServiceAuthError(
GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED),
std::string());
}
-void ManagedUserRefreshTokenFetcherImpl::OnNetworkError(int response_code) {
+void SupervisedUserRefreshTokenFetcherImpl::OnNetworkError(int response_code) {
// TODO(bauerb): We should return the HTTP response code somehow.
DLOG(WARNING) << "HTTP error " << response_code;
DispatchGoogleServiceAuthError(
@@ -255,12 +257,13 @@ void ManagedUserRefreshTokenFetcherImpl::OnNetworkError(int response_code) {
std::string());
}
-void ManagedUserRefreshTokenFetcherImpl::DispatchNetworkError(int error_code) {
+void SupervisedUserRefreshTokenFetcherImpl::DispatchNetworkError(
+ int error_code) {
DispatchGoogleServiceAuthError(
GoogleServiceAuthError::FromConnectionError(error_code), std::string());
}
-void ManagedUserRefreshTokenFetcherImpl::DispatchGoogleServiceAuthError(
+void SupervisedUserRefreshTokenFetcherImpl::DispatchGoogleServiceAuthError(
const GoogleServiceAuthError& error,
const std::string& token) {
callback_.Run(error, token);
@@ -270,14 +273,16 @@ void ManagedUserRefreshTokenFetcherImpl::DispatchGoogleServiceAuthError(
} // namespace
// static
-scoped_ptr<ManagedUserRefreshTokenFetcher>
-ManagedUserRefreshTokenFetcher::Create(OAuth2TokenService* oauth2_token_service,
- const std::string& account_id,
- URLRequestContextGetter* context) {
- scoped_ptr<ManagedUserRefreshTokenFetcher> fetcher(
- new ManagedUserRefreshTokenFetcherImpl(oauth2_token_service, account_id,
- context));
+scoped_ptr<SupervisedUserRefreshTokenFetcher>
+SupervisedUserRefreshTokenFetcher::Create(
+ OAuth2TokenService* oauth2_token_service,
+ const std::string& account_id,
+ URLRequestContextGetter* context) {
+ scoped_ptr<SupervisedUserRefreshTokenFetcher> fetcher(
+ new SupervisedUserRefreshTokenFetcherImpl(oauth2_token_service,
+ account_id,
+ context));
return fetcher.Pass();
}
-ManagedUserRefreshTokenFetcher::~ManagedUserRefreshTokenFetcher() {}
+SupervisedUserRefreshTokenFetcher::~SupervisedUserRefreshTokenFetcher() {}
diff --git a/chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h b/chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h
index 3657f68..0e8a10d 100644
--- a/chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h
+++ b/chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REFRESH_TOKEN_FETCHER_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REFRESH_TOKEN_FETCHER_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_REFRESH_TOKEN_FETCHER_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_REFRESH_TOKEN_FETCHER_H_
#include <string>
@@ -19,32 +19,32 @@ namespace net {
class URLRequestContextGetter;
}
-// This class fetches an OAuth2 refresh token that is tied to a managed user ID
-// and downscoped to a special scope for Chrome Sync for managed users.
+// This class fetches an OAuth2 refresh token that is tied to a supervised user
+// ID and downscoped to a special scope for Chrome Sync for supervised users.
// Fetching the token consists of the following steps:
// 1. Get an access token for the custodian from OAuth2TokenService
// (either cached or fetched).
// 2. Call the IssueToken API to mint a scoped authorization code for a
-// refresh token for the managed user from the custodian's access token.
-// 3. Exchange the authorization code for a refresh token for the managed
+// refresh token for the supervised user from the custodian's access token.
+// 3. Exchange the authorization code for a refresh token for the supervised
// user and return it to the caller. The refresh token can only be used to
-// mint tokens with the special managed user Sync scope.
-class ManagedUserRefreshTokenFetcher {
+// mint tokens with the special supervised user Sync scope.
+class SupervisedUserRefreshTokenFetcher {
public:
typedef base::Callback<void(const GoogleServiceAuthError& /* error */,
const std::string& /* refresh_token */)>
TokenCallback;
- static scoped_ptr<ManagedUserRefreshTokenFetcher> Create(
+ static scoped_ptr<SupervisedUserRefreshTokenFetcher> Create(
OAuth2TokenService* oauth2_token_service,
const std::string& account_id,
net::URLRequestContextGetter* context);
- virtual ~ManagedUserRefreshTokenFetcher();
+ virtual ~SupervisedUserRefreshTokenFetcher();
- virtual void Start(const std::string& managed_user_id,
+ virtual void Start(const std::string& supervised_user_id,
const std::string& device_name,
const TokenCallback& callback) = 0;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_REFRESH_TOKEN_FETCHER_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_REFRESH_TOKEN_FETCHER_H_
diff --git a/chrome/browser/managed_mode/managed_user_refresh_token_fetcher_unittest.cc b/chrome/browser/supervised_user/supervised_user_refresh_token_fetcher_unittest.cc
index 9211a50..9f7b2b1 100644
--- a/chrome/browser/managed_mode/managed_user_refresh_token_fetcher_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_refresh_token_fetcher_unittest.cc
@@ -1,12 +1,12 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
-#include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
+#include "chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "google_apis/gaia/gaia_constants.h"
@@ -26,11 +26,11 @@ namespace {
const char kAccountId[] = "account_id";
const char kDeviceName[] = "Compy";
-const char kManagedUserId[] = "abcdef";
+const char kSupervisedUserId[] = "abcdef";
const char kAccessToken[] = "accesstoken";
const char kAuthorizationCode[] = "authorizationcode";
-const char kManagedUserToken[] = "managedusertoken";
+const char kSupervisedUserToken[] = "supervisedusertoken";
const char kOAuth2RefreshToken[] = "refreshtoken";
const char kIssueTokenResponseFormat[] =
@@ -85,10 +85,10 @@ void VerifyTokenRequest(
} // namespace
-class ManagedUserRefreshTokenFetcherTest : public testing::Test {
+class SupervisedUserRefreshTokenFetcherTest : public testing::Test {
public:
- ManagedUserRefreshTokenFetcherTest();
- virtual ~ManagedUserRefreshTokenFetcherTest() {}
+ SupervisedUserRefreshTokenFetcherTest();
+ virtual ~SupervisedUserRefreshTokenFetcherTest() {}
protected:
void StartFetching();
@@ -114,31 +114,33 @@ class ManagedUserRefreshTokenFetcherTest : public testing::Test {
TestingProfile profile_;
FakeProfileOAuth2TokenService oauth2_token_service_;
net::TestURLFetcherFactory url_fetcher_factory_;
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher_;
+ scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher_;
GoogleServiceAuthError error_;
std::string token_;
- base::WeakPtrFactory<ManagedUserRefreshTokenFetcherTest> weak_ptr_factory_;
+ base::WeakPtrFactory<SupervisedUserRefreshTokenFetcherTest> weak_ptr_factory_;
};
-ManagedUserRefreshTokenFetcherTest::ManagedUserRefreshTokenFetcherTest()
- : token_fetcher_(
- ManagedUserRefreshTokenFetcher::Create(&oauth2_token_service_,
- kAccountId,
- profile_.GetRequestContext())),
+SupervisedUserRefreshTokenFetcherTest::SupervisedUserRefreshTokenFetcherTest()
+ : token_fetcher_(SupervisedUserRefreshTokenFetcher::Create(
+ &oauth2_token_service_,
+ kAccountId,
+ profile_.GetRequestContext())),
error_(GoogleServiceAuthError::NONE),
weak_ptr_factory_(this) {}
-void ManagedUserRefreshTokenFetcherTest::StartFetching() {
+void SupervisedUserRefreshTokenFetcherTest::StartFetching() {
oauth2_token_service_.IssueRefreshToken(kOAuth2RefreshToken);
- token_fetcher_->Start(kManagedUserId, kDeviceName,
- base::Bind(
- &ManagedUserRefreshTokenFetcherTest::OnTokenFetched,
- weak_ptr_factory_.GetWeakPtr()));
+ token_fetcher_->Start(
+ kSupervisedUserId,
+ kDeviceName,
+ base::Bind(
+ &SupervisedUserRefreshTokenFetcherTest::OnTokenFetched,
+ weak_ptr_factory_.GetWeakPtr()));
}
net::TestURLFetcher*
-ManagedUserRefreshTokenFetcherTest::GetIssueTokenRequest() {
+SupervisedUserRefreshTokenFetcherTest::GetIssueTokenRequest() {
net::TestURLFetcher* url_fetcher = url_fetcher_factory_.GetFetcherByID(1);
if (!url_fetcher)
return NULL;
@@ -151,9 +153,9 @@ ManagedUserRefreshTokenFetcherTest::GetIssueTokenRequest() {
EXPECT_TRUE(headers.GetHeader("Authorization", &access_token));
EXPECT_EQ(std::string("Bearer ") + kAccessToken, access_token);
const std::string upload_data = url_fetcher->upload_data();
- std::string managed_user_id;
- EXPECT_TRUE(GetValueForKey(upload_data, "profile_id", &managed_user_id));
- EXPECT_EQ(kManagedUserId, managed_user_id);
+ std::string supervised_user_id;
+ EXPECT_TRUE(GetValueForKey(upload_data, "profile_id", &supervised_user_id));
+ EXPECT_EQ(kSupervisedUserId, supervised_user_id);
std::string device_name;
EXPECT_TRUE(GetValueForKey(upload_data, "device_name", &device_name));
EXPECT_EQ(kDeviceName, device_name);
@@ -161,7 +163,7 @@ ManagedUserRefreshTokenFetcherTest::GetIssueTokenRequest() {
}
net::TestURLFetcher*
-ManagedUserRefreshTokenFetcherTest::GetRefreshTokenRequest() {
+SupervisedUserRefreshTokenFetcherTest::GetRefreshTokenRequest() {
net::TestURLFetcher* url_fetcher = url_fetcher_factory_.GetFetcherByID(
gaia::GaiaOAuthClient::kUrlFetcherId);
if (!url_fetcher)
@@ -176,7 +178,7 @@ ManagedUserRefreshTokenFetcherTest::GetRefreshTokenRequest() {
}
void
-ManagedUserRefreshTokenFetcherTest::MakeOAuth2TokenServiceRequestSucceed() {
+SupervisedUserRefreshTokenFetcherTest::MakeOAuth2TokenServiceRequestSucceed() {
std::vector<FakeProfileOAuth2TokenService::PendingRequest> requests =
oauth2_token_service_.GetPendingRequests();
VerifyTokenRequest(requests);
@@ -188,7 +190,7 @@ ManagedUserRefreshTokenFetcherTest::MakeOAuth2TokenServiceRequestSucceed() {
}
void
-ManagedUserRefreshTokenFetcherTest::MakeOAuth2TokenServiceRequestFail(
+SupervisedUserRefreshTokenFetcherTest::MakeOAuth2TokenServiceRequestFail(
GoogleServiceAuthError::State error) {
std::vector<FakeProfileOAuth2TokenService::PendingRequest> requests =
oauth2_token_service_.GetPendingRequests();
@@ -197,23 +199,23 @@ ManagedUserRefreshTokenFetcherTest::MakeOAuth2TokenServiceRequestFail(
GoogleServiceAuthError(error));
}
-void ManagedUserRefreshTokenFetcherTest::MakeIssueTokenRequestSucceed() {
+void SupervisedUserRefreshTokenFetcherTest::MakeIssueTokenRequestSucceed() {
SendResponse(GetIssueTokenRequest(),
base::StringPrintf(kIssueTokenResponseFormat,
kAuthorizationCode));
}
-void ManagedUserRefreshTokenFetcherTest::MakeRefreshTokenFetchSucceed() {
+void SupervisedUserRefreshTokenFetcherTest::MakeRefreshTokenFetchSucceed() {
SendResponse(GetRefreshTokenRequest(),
base::StringPrintf(kGetRefreshTokenResponseFormat,
- kManagedUserToken));
+ kSupervisedUserToken));
}
-void ManagedUserRefreshTokenFetcherTest::Reset() {
+void SupervisedUserRefreshTokenFetcherTest::Reset() {
token_fetcher_.reset();
}
-void ManagedUserRefreshTokenFetcherTest::OnTokenFetched(
+void SupervisedUserRefreshTokenFetcherTest::OnTokenFetched(
const GoogleServiceAuthError& error,
const std::string& token) {
error_ = error;
@@ -222,17 +224,17 @@ void ManagedUserRefreshTokenFetcherTest::OnTokenFetched(
// Tests --------------------------------------------------------
-TEST_F(ManagedUserRefreshTokenFetcherTest, Success) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, Success) {
StartFetching();
MakeOAuth2TokenServiceRequestSucceed();
MakeIssueTokenRequestSucceed();
MakeRefreshTokenFetchSucceed();
EXPECT_EQ(GoogleServiceAuthError::NONE, error().state());
- EXPECT_EQ(kManagedUserToken, token());
+ EXPECT_EQ(kSupervisedUserToken, token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, ExpiredAccessToken) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, ExpiredAccessToken) {
StartFetching();
MakeOAuth2TokenServiceRequestSucceed();
SetHttpError(GetIssueTokenRequest(), net::HTTP_UNAUTHORIZED);
@@ -241,10 +243,10 @@ TEST_F(ManagedUserRefreshTokenFetcherTest, ExpiredAccessToken) {
MakeRefreshTokenFetchSucceed();
EXPECT_EQ(GoogleServiceAuthError::NONE, error().state());
- EXPECT_EQ(kManagedUserToken, token());
+ EXPECT_EQ(kSupervisedUserToken, token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, ExpiredAccessTokenRetry) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, ExpiredAccessTokenRetry) {
// If we get a 401 error for the second time, we should give up instead of
// retrying again.
StartFetching();
@@ -258,7 +260,7 @@ TEST_F(ManagedUserRefreshTokenFetcherTest, ExpiredAccessTokenRetry) {
EXPECT_EQ(std::string(), token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, MalformedIssueTokenResponse) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, MalformedIssueTokenResponse) {
StartFetching();
MakeOAuth2TokenServiceRequestSucceed();
SendResponse(GetIssueTokenRequest(), "choke");
@@ -268,7 +270,7 @@ TEST_F(ManagedUserRefreshTokenFetcherTest, MalformedIssueTokenResponse) {
EXPECT_EQ(std::string(), token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, FetchAccessTokenFailure) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, FetchAccessTokenFailure) {
StartFetching();
MakeOAuth2TokenServiceRequestFail(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
@@ -277,7 +279,7 @@ TEST_F(ManagedUserRefreshTokenFetcherTest, FetchAccessTokenFailure) {
EXPECT_EQ(std::string(), token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, IssueTokenNetworkError) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, IssueTokenNetworkError) {
StartFetching();
MakeOAuth2TokenServiceRequestSucceed();
SetNetworkError(GetIssueTokenRequest(), net::ERR_SSL_PROTOCOL_ERROR);
@@ -287,7 +289,7 @@ TEST_F(ManagedUserRefreshTokenFetcherTest, IssueTokenNetworkError) {
EXPECT_EQ(std::string(), token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, FetchRefreshTokenNetworkError) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, FetchRefreshTokenNetworkError) {
StartFetching();
MakeOAuth2TokenServiceRequestSucceed();
MakeIssueTokenRequestSucceed();
@@ -300,7 +302,7 @@ TEST_F(ManagedUserRefreshTokenFetcherTest, FetchRefreshTokenNetworkError) {
EXPECT_EQ(std::string(), token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest,
+TEST_F(SupervisedUserRefreshTokenFetcherTest,
FetchRefreshTokenTransientNetworkError) {
StartFetching();
MakeOAuth2TokenServiceRequestSucceed();
@@ -311,10 +313,10 @@ TEST_F(ManagedUserRefreshTokenFetcherTest,
MakeRefreshTokenFetchSucceed();
EXPECT_EQ(GoogleServiceAuthError::NONE, error().state());
- EXPECT_EQ(kManagedUserToken, token());
+ EXPECT_EQ(kSupervisedUserToken, token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, FetchRefreshTokenBadRequest) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, FetchRefreshTokenBadRequest) {
StartFetching();
MakeOAuth2TokenServiceRequestSucceed();
MakeIssueTokenRequestSucceed();
@@ -325,7 +327,7 @@ TEST_F(ManagedUserRefreshTokenFetcherTest, FetchRefreshTokenBadRequest) {
EXPECT_EQ(std::string(), token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, CancelWhileFetchingAccessToken) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, CancelWhileFetchingAccessToken) {
StartFetching();
Reset();
@@ -333,7 +335,7 @@ TEST_F(ManagedUserRefreshTokenFetcherTest, CancelWhileFetchingAccessToken) {
EXPECT_EQ(std::string(), token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, CancelWhileCallingIssueToken) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, CancelWhileCallingIssueToken) {
StartFetching();
MakeOAuth2TokenServiceRequestSucceed();
Reset();
@@ -342,7 +344,7 @@ TEST_F(ManagedUserRefreshTokenFetcherTest, CancelWhileCallingIssueToken) {
EXPECT_EQ(std::string(), token());
}
-TEST_F(ManagedUserRefreshTokenFetcherTest, CancelWhileFetchingRefreshToken) {
+TEST_F(SupervisedUserRefreshTokenFetcherTest, CancelWhileFetchingRefreshToken) {
StartFetching();
MakeOAuth2TokenServiceRequestSucceed();
MakeIssueTokenRequestSucceed();
diff --git a/chrome/browser/supervised_user/supervised_user_registration_utility.cc b/chrome/browser/supervised_user/supervised_user_registration_utility.cc
new file mode 100644
index 0000000..07c7b01
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_registration_utility.cc
@@ -0,0 +1,408 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
+
+#include "base/base64.h"
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/prefs/pref_service.h"
+#include "base/rand_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_update.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
+#include "chrome/browser/sync/glue/device_info.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
+#include "components/signin/core/browser/profile_oauth2_token_service.h"
+#include "components/signin/core/browser/signin_manager.h"
+#include "google_apis/gaia/gaia_urls.h"
+#include "google_apis/gaia/google_service_auth_error.h"
+
+using base::DictionaryValue;
+
+namespace {
+
+SupervisedUserRegistrationUtility* g_instance_for_tests = NULL;
+
+// Actual implementation of SupervisedUserRegistrationUtility.
+class SupervisedUserRegistrationUtilityImpl
+ : public SupervisedUserRegistrationUtility,
+ public SupervisedUserSyncServiceObserver {
+ public:
+ SupervisedUserRegistrationUtilityImpl(
+ PrefService* prefs,
+ scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher,
+ SupervisedUserSyncService* service,
+ SupervisedUserSharedSettingsService* shared_settings_service);
+
+ virtual ~SupervisedUserRegistrationUtilityImpl();
+
+ // Registers a new supervised user with the server. |supervised_user_id| is a
+ // new unique ID for the new supervised user. If its value is the same as that
+ // of one of the existing supervised users, then the same user will be created
+ // on this machine (and if he has no avatar in sync, his avatar will be
+ // updated). |info| contains necessary information like the display name of
+ // the user and his avatar. |callback| is called with the result of the
+ // registration. We use the info here and not the profile, because on Chrome
+ // OS the profile of the supervised user does not yet exist.
+ virtual void Register(const std::string& supervised_user_id,
+ const SupervisedUserRegistrationInfo& info,
+ const RegistrationCallback& callback) OVERRIDE;
+
+ // SupervisedUserSyncServiceObserver:
+ virtual void OnSupervisedUserAcknowledged(
+ const std::string& supervised_user_id) OVERRIDE;
+ virtual void OnSupervisedUsersSyncingStopped() OVERRIDE;
+ virtual void OnSupervisedUsersChanged() OVERRIDE;
+
+ private:
+ // Fetches the supervised user token when we have the device name.
+ void FetchToken(const std::string& client_name);
+
+ // Called when we have received a token for the supervised user.
+ void OnReceivedToken(const GoogleServiceAuthError& error,
+ const std::string& token);
+
+ // Dispatches the callback and cleans up if all the conditions have been met.
+ void CompleteRegistrationIfReady();
+
+ // Aborts any registration currently in progress. If |run_callback| is true,
+ // calls the callback specified in Register() with the given |error|.
+ void AbortPendingRegistration(bool run_callback,
+ const GoogleServiceAuthError& error);
+
+ // If |run_callback| is true, dispatches the callback with the saved token
+ // (which may be empty) and the given |error|. In any case, resets internal
+ // variables to be ready for the next registration.
+ void CompleteRegistration(bool run_callback,
+ const GoogleServiceAuthError& error);
+
+ // Cancels any registration currently in progress, without calling the
+ // callback or reporting an error.
+ void CancelPendingRegistration();
+
+ // SupervisedUserSharedSettingsUpdate acknowledgment callback for password
+ // data in shared settings.
+ void OnPasswordChangeAcknowledged(bool success);
+
+ PrefService* prefs_;
+ scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher_;
+
+ // A |KeyedService| owned by the custodian profile.
+ SupervisedUserSyncService* supervised_user_sync_service_;
+
+ // A |KeyedService| owned by the custodian profile.
+ SupervisedUserSharedSettingsService* supervised_user_shared_settings_service_;
+
+ std::string pending_supervised_user_id_;
+ std::string pending_supervised_user_token_;
+ bool pending_supervised_user_acknowledged_;
+ bool is_existing_supervised_user_;
+ bool avatar_updated_;
+ RegistrationCallback callback_;
+ scoped_ptr<SupervisedUserSharedSettingsUpdate> password_update_;
+
+ base::WeakPtrFactory<SupervisedUserRegistrationUtilityImpl> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserRegistrationUtilityImpl);
+};
+
+} // namespace
+
+SupervisedUserRegistrationInfo::SupervisedUserRegistrationInfo(
+ const base::string16& name,
+ int avatar_index)
+ : avatar_index(avatar_index),
+ name(name) {
+}
+
+SupervisedUserRegistrationInfo::~SupervisedUserRegistrationInfo() {}
+
+ScopedTestingSupervisedUserRegistrationUtility::
+ ScopedTestingSupervisedUserRegistrationUtility(
+ SupervisedUserRegistrationUtility* instance) {
+ SupervisedUserRegistrationUtility::SetUtilityForTests(instance);
+}
+
+ScopedTestingSupervisedUserRegistrationUtility::
+ ~ScopedTestingSupervisedUserRegistrationUtility() {
+ SupervisedUserRegistrationUtility::SetUtilityForTests(NULL);
+}
+
+// static
+scoped_ptr<SupervisedUserRegistrationUtility>
+SupervisedUserRegistrationUtility::Create(Profile* profile) {
+ if (g_instance_for_tests) {
+ SupervisedUserRegistrationUtility* result = g_instance_for_tests;
+ g_instance_for_tests = NULL;
+ return make_scoped_ptr(result);
+ }
+
+ ProfileOAuth2TokenService* token_service =
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
+ SigninManagerBase* signin_manager =
+ SigninManagerFactory::GetForProfile(profile);
+ scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher =
+ SupervisedUserRefreshTokenFetcher::Create(
+ token_service,
+ signin_manager->GetAuthenticatedAccountId(),
+ profile->GetRequestContext());
+ SupervisedUserSyncService* supervised_user_sync_service =
+ SupervisedUserSyncServiceFactory::GetForProfile(profile);
+ SupervisedUserSharedSettingsService* supervised_user_shared_settings_service =
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
+ return make_scoped_ptr(SupervisedUserRegistrationUtility::CreateImpl(
+ profile->GetPrefs(),
+ token_fetcher.Pass(),
+ supervised_user_sync_service,
+ supervised_user_shared_settings_service));
+}
+
+// static
+std::string SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId() {
+ std::string new_supervised_user_id;
+ base::Base64Encode(base::RandBytesAsString(8), &new_supervised_user_id);
+ return new_supervised_user_id;
+}
+
+// static
+void SupervisedUserRegistrationUtility::SetUtilityForTests(
+ SupervisedUserRegistrationUtility* utility) {
+ if (g_instance_for_tests)
+ delete g_instance_for_tests;
+ g_instance_for_tests = utility;
+}
+
+// static
+SupervisedUserRegistrationUtility*
+SupervisedUserRegistrationUtility::CreateImpl(
+ PrefService* prefs,
+ scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher,
+ SupervisedUserSyncService* service,
+ SupervisedUserSharedSettingsService* shared_settings_service) {
+ return new SupervisedUserRegistrationUtilityImpl(prefs,
+ token_fetcher.Pass(),
+ service,
+ shared_settings_service);
+}
+
+namespace {
+
+SupervisedUserRegistrationUtilityImpl::SupervisedUserRegistrationUtilityImpl(
+ PrefService* prefs,
+ scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher,
+ SupervisedUserSyncService* service,
+ SupervisedUserSharedSettingsService* shared_settings_service)
+ : prefs_(prefs),
+ token_fetcher_(token_fetcher.Pass()),
+ supervised_user_sync_service_(service),
+ supervised_user_shared_settings_service_(shared_settings_service),
+ pending_supervised_user_acknowledged_(false),
+ is_existing_supervised_user_(false),
+ avatar_updated_(false),
+ weak_ptr_factory_(this) {
+ supervised_user_sync_service_->AddObserver(this);
+}
+
+SupervisedUserRegistrationUtilityImpl::
+~SupervisedUserRegistrationUtilityImpl() {
+ supervised_user_sync_service_->RemoveObserver(this);
+ CancelPendingRegistration();
+}
+
+void SupervisedUserRegistrationUtilityImpl::Register(
+ const std::string& supervised_user_id,
+ const SupervisedUserRegistrationInfo& info,
+ const RegistrationCallback& callback) {
+ DCHECK(pending_supervised_user_id_.empty());
+ callback_ = callback;
+ pending_supervised_user_id_ = supervised_user_id;
+
+ bool need_password_update = !info.password_data.empty();
+ const base::DictionaryValue* dict =
+ prefs_->GetDictionary(prefs::kSupervisedUsers);
+ is_existing_supervised_user_ = dict->HasKey(supervised_user_id);
+ if (!is_existing_supervised_user_) {
+ supervised_user_sync_service_->AddSupervisedUser(
+ pending_supervised_user_id_,
+ base::UTF16ToUTF8(info.name),
+ info.master_key,
+ info.password_signature_key,
+ info.password_encryption_key,
+ info.avatar_index);
+ } else {
+ const base::DictionaryValue* value = NULL;
+ bool success =
+ dict->GetDictionaryWithoutPathExpansion(supervised_user_id, &value);
+ DCHECK(success);
+ std::string key;
+ bool need_keys = !info.password_signature_key.empty() ||
+ !info.password_encryption_key.empty();
+ bool have_keys =
+ value->GetString(SupervisedUserSyncService::kPasswordSignatureKey,
+ &key) &&
+ !key.empty() &&
+ value->GetString(SupervisedUserSyncService::kPasswordEncryptionKey,
+ &key) &&
+ !key.empty();
+
+ bool keys_need_update = need_keys && !have_keys;
+
+ if (keys_need_update) {
+ supervised_user_sync_service_->UpdateSupervisedUser(
+ pending_supervised_user_id_,
+ base::UTF16ToUTF8(info.name),
+ info.master_key,
+ info.password_signature_key,
+ info.password_encryption_key,
+ info.avatar_index);
+ } else {
+ // The user already exists and does not need to be updated.
+ need_password_update = false;
+ OnSupervisedUserAcknowledged(supervised_user_id);
+ }
+ avatar_updated_ =
+ supervised_user_sync_service_->UpdateSupervisedUserAvatarIfNeeded(
+ supervised_user_id,
+ info.avatar_index);
+ }
+#if defined(OS_CHROMEOS)
+ const char* kAvatarKey = supervised_users::kChromeOSAvatarIndex;
+#else
+ const char* kAvatarKey = supervised_users::kChromeAvatarIndex;
+#endif
+ supervised_user_shared_settings_service_->SetValue(
+ pending_supervised_user_id_, kAvatarKey,
+ base::FundamentalValue(info.avatar_index));
+ if (need_password_update) {
+ password_update_.reset(new SupervisedUserSharedSettingsUpdate(
+ supervised_user_shared_settings_service_,
+ pending_supervised_user_id_,
+ supervised_users::kChromeOSPasswordData,
+ scoped_ptr<base::Value>(info.password_data.DeepCopy()),
+ base::Bind(
+ &SupervisedUserRegistrationUtilityImpl::
+ OnPasswordChangeAcknowledged,
+ weak_ptr_factory_.GetWeakPtr())));
+ }
+
+ browser_sync::DeviceInfo::GetClientName(
+ base::Bind(&SupervisedUserRegistrationUtilityImpl::FetchToken,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void SupervisedUserRegistrationUtilityImpl::CancelPendingRegistration() {
+ AbortPendingRegistration(
+ false, // Don't run the callback. The error will be ignored.
+ GoogleServiceAuthError(GoogleServiceAuthError::NONE));
+}
+
+void SupervisedUserRegistrationUtilityImpl::OnSupervisedUserAcknowledged(
+ const std::string& supervised_user_id) {
+ DCHECK_EQ(pending_supervised_user_id_, supervised_user_id);
+ DCHECK(!pending_supervised_user_acknowledged_);
+ pending_supervised_user_acknowledged_ = true;
+ CompleteRegistrationIfReady();
+}
+
+void SupervisedUserRegistrationUtilityImpl::OnPasswordChangeAcknowledged(
+ bool success) {
+ DCHECK(password_update_);
+ DCHECK(success);
+ password_update_.reset();
+ CompleteRegistrationIfReady();
+}
+
+void SupervisedUserRegistrationUtilityImpl::OnSupervisedUsersSyncingStopped() {
+ AbortPendingRegistration(
+ true, // Run the callback.
+ GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED));
+}
+
+void SupervisedUserRegistrationUtilityImpl::OnSupervisedUsersChanged() {}
+
+void SupervisedUserRegistrationUtilityImpl::FetchToken(
+ const std::string& client_name) {
+ token_fetcher_->Start(
+ pending_supervised_user_id_, client_name,
+ base::Bind(&SupervisedUserRegistrationUtilityImpl::OnReceivedToken,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void SupervisedUserRegistrationUtilityImpl::OnReceivedToken(
+ const GoogleServiceAuthError& error,
+ const std::string& token) {
+ if (error.state() != GoogleServiceAuthError::NONE) {
+ CompleteRegistration(true, error);
+ return;
+ }
+
+ DCHECK(!token.empty());
+ pending_supervised_user_token_ = token;
+ CompleteRegistrationIfReady();
+}
+
+void SupervisedUserRegistrationUtilityImpl::CompleteRegistrationIfReady() {
+ bool skip_check = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kNoSupervisedUserAcknowledgmentCheck);
+
+ if (!pending_supervised_user_acknowledged_ && !skip_check)
+ return;
+ if (password_update_ && !skip_check)
+ return;
+ if (pending_supervised_user_token_.empty())
+ return;
+
+ GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
+ CompleteRegistration(true, error);
+}
+
+void SupervisedUserRegistrationUtilityImpl::AbortPendingRegistration(
+ bool run_callback,
+ const GoogleServiceAuthError& error) {
+ pending_supervised_user_token_.clear();
+ CompleteRegistration(run_callback, error);
+}
+
+void SupervisedUserRegistrationUtilityImpl::CompleteRegistration(
+ bool run_callback,
+ const GoogleServiceAuthError& error) {
+ if (callback_.is_null())
+ return;
+
+ if (pending_supervised_user_token_.empty()) {
+ DCHECK(!pending_supervised_user_id_.empty());
+
+ if (!is_existing_supervised_user_) {
+ // Remove the pending supervised user if we weren't successful.
+ // However, check that we are not importing a supervised user
+ // before deleting it from sync to avoid accidental deletion of
+ // existing supervised users by just canceling the registration for
+ // example.
+ supervised_user_sync_service_->DeleteSupervisedUser(
+ pending_supervised_user_id_);
+ } else if (avatar_updated_) {
+ // Canceling (or failing) a supervised user import that did set the avatar
+ // should undo this change.
+ supervised_user_sync_service_->ClearSupervisedUserAvatar(
+ pending_supervised_user_id_);
+ }
+ }
+
+ if (run_callback)
+ callback_.Run(error, pending_supervised_user_token_);
+ callback_.Reset();
+}
+
+} // namespace
diff --git a/chrome/browser/supervised_user/supervised_user_registration_utility.h b/chrome/browser/supervised_user/supervised_user_registration_utility.h
new file mode 100644
index 0000000..67dcaa9
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_registration_utility.h
@@ -0,0 +1,110 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_REGISTRATION_UTILITY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_REGISTRATION_UTILITY_H_
+
+#include <map>
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/gtest_prod_util.h"
+#include "base/memory/weak_ptr.h"
+#include "base/prefs/pref_change_registrar.h"
+#include "base/strings/string16.h"
+#include "base/values.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_observer.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
+#include "components/keyed_service/core/keyed_service.h"
+
+class GoogleServiceAuthError;
+class PrefService;
+class Profile;
+class SupervisedUserRefreshTokenFetcher;
+class SupervisedUserRegistrationUtilityTest;
+class SupervisedUserSharedSettingsService;
+
+namespace browser_sync {
+class DeviceInfo;
+}
+
+// Structure to store registration information.
+struct SupervisedUserRegistrationInfo {
+ SupervisedUserRegistrationInfo(const base::string16& name, int avatar_index);
+ ~SupervisedUserRegistrationInfo();
+ int avatar_index;
+ base::string16 name;
+ std::string master_key;
+ std::string password_signature_key;
+ std::string password_encryption_key;
+ base::DictionaryValue password_data;
+};
+
+// Holds the state necessary for registering a new supervised user with the
+// management server and associating it with its custodian. Each instance
+// of this class handles registering a single supervised user and should not
+// be used afterwards.
+class SupervisedUserRegistrationUtility {
+ public:
+ // Callback for Register() below. If registration is successful, |token| will
+ // contain an OAuth2 refresh token for the newly registered supervised user,
+ // otherwise |token| will be empty and |error| will contain the authentication
+ // error for the custodian.
+ typedef base::Callback<void(const GoogleServiceAuthError& /* error */,
+ const std::string& /* token */)>
+ RegistrationCallback;
+
+ virtual ~SupervisedUserRegistrationUtility() {}
+
+ // Creates SupervisedUserRegistrationUtility for a given |profile|.
+ static scoped_ptr<SupervisedUserRegistrationUtility> Create(Profile* profile);
+
+ static std::string GenerateNewSupervisedUserId();
+
+ // Registers a new supervised user with the server. |supervised_user_id| is a
+ // new unique ID for the new supervised user. If its value is the same as that
+ // of one of the existing supervised users, then the same user will be created
+ // on this machine (and if he has no avatar in sync, his avatar will be
+ // updated). |info| contains necessary information like the display name of
+ // the user and his avatar. |callback| is called with the result of the
+ // registration. We use the info here and not the profile, because on Chrome
+ // OS the profile of the supervised user does not yet exist.
+ virtual void Register(const std::string& supervised_user_id,
+ const SupervisedUserRegistrationInfo& info,
+ const RegistrationCallback& callback) = 0;
+
+ protected:
+ SupervisedUserRegistrationUtility() {}
+
+ private:
+ friend class ScopedTestingSupervisedUserRegistrationUtility;
+ friend class SupervisedUserRegistrationUtilityTest;
+
+ // Creates implementation with explicit dependencies, can be used for testing.
+ static SupervisedUserRegistrationUtility* CreateImpl(
+ PrefService* prefs,
+ scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher,
+ SupervisedUserSyncService* service,
+ SupervisedUserSharedSettingsService* shared_settings_service);
+
+ // Set the instance of SupervisedUserRegistrationUtility that will be returned
+ // by next Create() call. Takes ownership of the |utility|.
+ static void SetUtilityForTests(SupervisedUserRegistrationUtility* utility);
+};
+
+// Class that sets the instance of SupervisedUserRegistrationUtility that will
+// be returned by next Create() call, and correctly destroys it if Create() was
+// not called.
+class ScopedTestingSupervisedUserRegistrationUtility {
+ public:
+ // Delegates ownership of the |instance| to SupervisedUserRegistrationUtility.
+ ScopedTestingSupervisedUserRegistrationUtility(
+ SupervisedUserRegistrationUtility* instance);
+
+ ~ScopedTestingSupervisedUserRegistrationUtility();
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_REGISTRATION_UTILITY_H_
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility_stub.cc b/chrome/browser/supervised_user/supervised_user_registration_utility_stub.cc
index 1149649..4236000 100644
--- a/chrome/browser/managed_mode/managed_user_registration_utility_stub.cc
+++ b/chrome/browser/supervised_user/supervised_user_registration_utility_stub.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_user_registration_utility_stub.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility_stub.h"
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
@@ -10,26 +10,27 @@
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
-ManagedUserRegistrationUtilityStub::ManagedUserRegistrationUtilityStub()
+SupervisedUserRegistrationUtilityStub::SupervisedUserRegistrationUtilityStub()
: register_was_called_(false) {
}
-ManagedUserRegistrationUtilityStub::~ManagedUserRegistrationUtilityStub() {
+SupervisedUserRegistrationUtilityStub::
+~SupervisedUserRegistrationUtilityStub() {
}
-void ManagedUserRegistrationUtilityStub::Register(
- const std::string& managed_user_id,
- const ManagedUserRegistrationInfo& info,
+void SupervisedUserRegistrationUtilityStub::Register(
+ const std::string& supervised_user_id,
+ const SupervisedUserRegistrationInfo& info,
const RegistrationCallback& callback) {
DCHECK(!register_was_called_);
register_was_called_ = true;
callback_ = callback;
- managed_user_id_ = managed_user_id;
+ supervised_user_id_ = supervised_user_id;
display_name_ = info.name;
master_key_ = info.master_key;
}
-void ManagedUserRegistrationUtilityStub::RunSuccessCallback(
+void SupervisedUserRegistrationUtilityStub::RunSuccessCallback(
const std::string& token) {
if (callback_.is_null())
return;
@@ -37,7 +38,7 @@ void ManagedUserRegistrationUtilityStub::RunSuccessCallback(
callback_.Reset();
}
-void ManagedUserRegistrationUtilityStub::RunFailureCallback(
+void SupervisedUserRegistrationUtilityStub::RunFailureCallback(
const GoogleServiceAuthError::State state) {
if (callback_.is_null())
return;
diff --git a/chrome/browser/supervised_user/supervised_user_registration_utility_stub.h b/chrome/browser/supervised_user/supervised_user_registration_utility_stub.h
new file mode 100644
index 0000000..969b558
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_registration_utility_stub.h
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_REGISTRATION_UTILITY_STUB_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_REGISTRATION_UTILITY_STUB_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/strings/string16.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
+#include "google_apis/gaia/google_service_auth_error.h"
+
+class SupervisedUserRegistrationUtilityStub
+ : public SupervisedUserRegistrationUtility {
+ public:
+ SupervisedUserRegistrationUtilityStub();
+ virtual ~SupervisedUserRegistrationUtilityStub();
+
+ virtual void Register(const std::string& supervised_user_id,
+ const SupervisedUserRegistrationInfo& info,
+ const RegistrationCallback& callback) OVERRIDE;
+
+ bool register_was_called() { return register_was_called_; }
+
+ std::string supervised_user_id() { return supervised_user_id_; }
+
+ base::string16 display_name() { return display_name_; }
+
+ std::string master_key() { return master_key_; }
+
+ void RunSuccessCallback(const std::string& token);
+ void RunFailureCallback(GoogleServiceAuthError::State error);
+
+ private:
+ RegistrationCallback callback_;
+ bool register_was_called_;
+ std::string supervised_user_id_;
+ base::string16 display_name_;
+ std::string master_key_;
+
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserRegistrationUtilityStub);
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_REGISTRATION_UTILITY_STUB_H_
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc b/chrome/browser/supervised_user/supervised_user_registration_utility_unittest.cc
index ed33dcd..99435a52 100644
--- a/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_registration_utility_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,12 +8,12 @@
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
-#include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
@@ -69,14 +69,14 @@ SyncError MockChangeProcessor::ProcessSyncChanges(
return SyncError();
}
-class MockManagedUserRefreshTokenFetcher
- : public ManagedUserRefreshTokenFetcher {
+class MockSupervisedUserRefreshTokenFetcher
+ : public SupervisedUserRefreshTokenFetcher {
public:
- MockManagedUserRefreshTokenFetcher() {}
- virtual ~MockManagedUserRefreshTokenFetcher() {}
+ MockSupervisedUserRefreshTokenFetcher() {}
+ virtual ~MockSupervisedUserRefreshTokenFetcher() {}
- // ManagedUserRefreshTokenFetcher implementation:
- virtual void Start(const std::string& managed_user_id,
+ // SupervisedUserRefreshTokenFetcher implementation:
+ virtual void Start(const std::string& supervised_user_id,
const std::string& device_name,
const TokenCallback& callback) OVERRIDE {
GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
@@ -86,10 +86,10 @@ class MockManagedUserRefreshTokenFetcher
} // namespace
-class ManagedUserRegistrationUtilityTest : public ::testing::Test {
+class SupervisedUserRegistrationUtilityTest : public ::testing::Test {
public:
- ManagedUserRegistrationUtilityTest();
- virtual ~ManagedUserRegistrationUtilityTest();
+ SupervisedUserRegistrationUtilityTest();
+ virtual ~SupervisedUserRegistrationUtilityTest();
virtual void TearDown() OVERRIDE;
@@ -100,16 +100,16 @@ class ManagedUserRegistrationUtilityTest : public ::testing::Test {
SyncMergeResult StartInitialSync();
- ManagedUserRegistrationUtility::RegistrationCallback
+ SupervisedUserRegistrationUtility::RegistrationCallback
GetRegistrationCallback();
- ManagedUserRegistrationUtility* GetRegistrationUtility();
+ SupervisedUserRegistrationUtility* GetRegistrationUtility();
void Acknowledge();
PrefService* prefs() { return profile_.GetTestingPrefService(); }
- ManagedUserSyncService* service() { return service_; }
- ManagedUserSharedSettingsService* shared_settings_service() {
+ SupervisedUserSyncService* service() { return service_; }
+ SupervisedUserSharedSettingsService* shared_settings_service() {
return shared_settings_service_;
}
MockChangeProcessor* change_processor() { return change_processor_; }
@@ -119,65 +119,67 @@ class ManagedUserRegistrationUtilityTest : public ::testing::Test {
const std::string& token() const { return token_; }
private:
- void OnManagedUserRegistered(const GoogleServiceAuthError& error,
- const std::string& token);
+ void OnSupervisedUserRegistered(const GoogleServiceAuthError& error,
+ const std::string& token);
base::MessageLoop message_loop_;
base::RunLoop run_loop_;
TestingProfile profile_;
- ManagedUserSyncService* service_;
- ManagedUserSharedSettingsService* shared_settings_service_;
- scoped_ptr<ManagedUserRegistrationUtility> registration_utility_;
+ SupervisedUserSyncService* service_;
+ SupervisedUserSharedSettingsService* shared_settings_service_;
+ scoped_ptr<SupervisedUserRegistrationUtility> registration_utility_;
- // Owned by the ManagedUserSyncService.
+ // Owned by the SupervisedUserSyncService.
MockChangeProcessor* change_processor_;
// A unique ID for creating "remote" Sync data.
int64 sync_data_id_;
- // Whether OnManagedUserRegistered has been called.
+ // Whether OnSupervisedUserRegistered has been called.
bool received_callback_;
// Hold the registration result (either an error, or a token).
GoogleServiceAuthError error_;
std::string token_;
- base::WeakPtrFactory<ManagedUserRegistrationUtilityTest> weak_ptr_factory_;
+ base::WeakPtrFactory<SupervisedUserRegistrationUtilityTest> weak_ptr_factory_;
};
-ManagedUserRegistrationUtilityTest::ManagedUserRegistrationUtilityTest()
+SupervisedUserRegistrationUtilityTest::SupervisedUserRegistrationUtilityTest()
: change_processor_(NULL),
sync_data_id_(0),
received_callback_(false),
error_(GoogleServiceAuthError::NUM_STATES),
weak_ptr_factory_(this) {
- service_ = ManagedUserSyncServiceFactory::GetForProfile(&profile_);
+ service_ = SupervisedUserSyncServiceFactory::GetForProfile(&profile_);
shared_settings_service_ =
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(&profile_);
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ &profile_);
}
-ManagedUserRegistrationUtilityTest::~ManagedUserRegistrationUtilityTest() {
+SupervisedUserRegistrationUtilityTest::
+ ~SupervisedUserRegistrationUtilityTest() {
EXPECT_FALSE(weak_ptr_factory_.HasWeakPtrs());
}
-void ManagedUserRegistrationUtilityTest::TearDown() {
+void SupervisedUserRegistrationUtilityTest::TearDown() {
content::BrowserThread::GetBlockingPool()->FlushForTesting();
base::RunLoop().RunUntilIdle();
}
scoped_ptr<SyncChangeProcessor>
-ManagedUserRegistrationUtilityTest::CreateChangeProcessor() {
+SupervisedUserRegistrationUtilityTest::CreateChangeProcessor() {
EXPECT_FALSE(change_processor_);
change_processor_ = new MockChangeProcessor();
return scoped_ptr<SyncChangeProcessor>(change_processor_);
}
scoped_ptr<SyncErrorFactory>
-ManagedUserRegistrationUtilityTest::CreateErrorFactory() {
+SupervisedUserRegistrationUtilityTest::CreateErrorFactory() {
return scoped_ptr<SyncErrorFactory>(new syncer::SyncErrorFactoryMock());
}
-SyncMergeResult ManagedUserRegistrationUtilityTest::StartInitialSync() {
+SyncMergeResult SupervisedUserRegistrationUtilityTest::StartInitialSync() {
SyncDataList initial_sync_data;
SyncMergeResult result =
service()->MergeDataAndStartSyncing(SUPERVISED_USERS,
@@ -188,29 +190,29 @@ SyncMergeResult ManagedUserRegistrationUtilityTest::StartInitialSync() {
return result;
}
-ManagedUserRegistrationUtility::RegistrationCallback
-ManagedUserRegistrationUtilityTest::GetRegistrationCallback() {
+SupervisedUserRegistrationUtility::RegistrationCallback
+SupervisedUserRegistrationUtilityTest::GetRegistrationCallback() {
return base::Bind(
- &ManagedUserRegistrationUtilityTest::OnManagedUserRegistered,
+ &SupervisedUserRegistrationUtilityTest::OnSupervisedUserRegistered,
weak_ptr_factory_.GetWeakPtr());
}
-ManagedUserRegistrationUtility*
-ManagedUserRegistrationUtilityTest::GetRegistrationUtility() {
+SupervisedUserRegistrationUtility*
+SupervisedUserRegistrationUtilityTest::GetRegistrationUtility() {
if (registration_utility_.get())
return registration_utility_.get();
- scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher(
- new MockManagedUserRefreshTokenFetcher);
+ scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher(
+ new MockSupervisedUserRefreshTokenFetcher);
registration_utility_.reset(
- ManagedUserRegistrationUtility::CreateImpl(prefs(),
- token_fetcher.Pass(),
- service(),
- shared_settings_service()));
+ SupervisedUserRegistrationUtility::CreateImpl(prefs(),
+ token_fetcher.Pass(),
+ service(),
+ shared_settings_service()));
return registration_utility_.get();
}
-void ManagedUserRegistrationUtilityTest::Acknowledge() {
+void SupervisedUserRegistrationUtilityTest::Acknowledge() {
SyncChangeList new_changes;
const SyncChangeList& changes = change_processor()->changes();
for (SyncChangeList::const_iterator it = changes.begin(); it != changes.end();
@@ -234,7 +236,7 @@ void ManagedUserRegistrationUtilityTest::Acknowledge() {
run_loop_.Run();
}
-void ManagedUserRegistrationUtilityTest::OnManagedUserRegistered(
+void SupervisedUserRegistrationUtilityTest::OnSupervisedUserRegistered(
const GoogleServiceAuthError& error,
const std::string& token) {
received_callback_ = true;
@@ -243,11 +245,11 @@ void ManagedUserRegistrationUtilityTest::OnManagedUserRegistered(
run_loop_.Quit();
}
-TEST_F(ManagedUserRegistrationUtilityTest, Register) {
+TEST_F(SupervisedUserRegistrationUtilityTest, Register) {
StartInitialSync();
GetRegistrationUtility()->Register(
- ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
- ManagedUserRegistrationInfo(base::ASCIIToUTF16("Dug"), 0),
+ SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(),
+ SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Dug"), 0),
GetRegistrationCallback());
EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
Acknowledge();
@@ -257,10 +259,10 @@ TEST_F(ManagedUserRegistrationUtilityTest, Register) {
EXPECT_FALSE(token().empty());
}
-TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
+TEST_F(SupervisedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
GetRegistrationUtility()->Register(
- ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
- ManagedUserRegistrationInfo(base::ASCIIToUTF16("Nemo"), 5),
+ SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(),
+ SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Nemo"), 5),
GetRegistrationCallback());
EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
StartInitialSync();
@@ -271,11 +273,12 @@ TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
EXPECT_FALSE(token().empty());
}
-TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) {
+TEST_F(SupervisedUserRegistrationUtilityTest,
+ SyncServiceShutdownBeforeRegFinish) {
StartInitialSync();
GetRegistrationUtility()->Register(
- ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
- ManagedUserRegistrationInfo(base::ASCIIToUTF16("Remy"), 12),
+ SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(),
+ SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Remy"), 12),
GetRegistrationCallback());
EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
service()->Shutdown();
@@ -285,11 +288,11 @@ TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) {
EXPECT_EQ(std::string(), token());
}
-TEST_F(ManagedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) {
+TEST_F(SupervisedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) {
StartInitialSync();
GetRegistrationUtility()->Register(
- ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
- ManagedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17),
+ SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(),
+ SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17),
GetRegistrationCallback());
EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size());
service()->StopSyncing(SUPERVISED_USERS);
diff --git a/chrome/browser/supervised_user/supervised_user_resource_throttle.cc b/chrome/browser/supervised_user/supervised_user_resource_throttle.cc
new file mode 100644
index 0000000..8cf1ceb
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_resource_throttle.cc
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/supervised_user/supervised_user_resource_throttle.h"
+
+#include "base/bind.h"
+#include "chrome/browser/supervised_user/supervised_user_interstitial.h"
+#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/resource_controller.h"
+#include "content/public/browser/resource_request_info.h"
+#include "net/url_request/url_request.h"
+
+using content::BrowserThread;
+
+SupervisedUserResourceThrottle::SupervisedUserResourceThrottle(
+ const net::URLRequest* request,
+ bool is_main_frame,
+ const SupervisedUserURLFilter* url_filter)
+ : request_(request),
+ is_main_frame_(is_main_frame),
+ url_filter_(url_filter),
+ weak_ptr_factory_(this) {}
+
+SupervisedUserResourceThrottle::~SupervisedUserResourceThrottle() {}
+
+void SupervisedUserResourceThrottle::ShowInterstitialIfNeeded(bool is_redirect,
+ const GURL& url,
+ bool* defer) {
+ // Only treat main frame requests for now (ignoring subresources).
+ if (!is_main_frame_)
+ return;
+
+ if (url_filter_->GetFilteringBehaviorForURL(url) !=
+ SupervisedUserURLFilter::BLOCK) {
+ return;
+ }
+
+ *defer = true;
+ const content::ResourceRequestInfo* info =
+ content::ResourceRequestInfo::ForRequest(request_);
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&SupervisedUserNavigationObserver::OnRequestBlocked,
+ info->GetChildID(), info->GetRouteID(), url,
+ base::Bind(
+ &SupervisedUserResourceThrottle::OnInterstitialResult,
+ weak_ptr_factory_.GetWeakPtr())));
+}
+
+void SupervisedUserResourceThrottle::WillStartRequest(bool* defer) {
+ ShowInterstitialIfNeeded(false, request_->url(), defer);
+}
+
+void SupervisedUserResourceThrottle::WillRedirectRequest(const GURL& new_url,
+ bool* defer) {
+ ShowInterstitialIfNeeded(true, new_url, defer);
+}
+
+const char* SupervisedUserResourceThrottle::GetNameForLogging() const {
+ return "SupervisedUserResourceThrottle";
+}
+
+void SupervisedUserResourceThrottle::OnInterstitialResult(
+ bool continue_request) {
+ if (continue_request)
+ controller()->Resume();
+ else
+ controller()->Cancel();
+}
diff --git a/chrome/browser/supervised_user/supervised_user_resource_throttle.h b/chrome/browser/supervised_user/supervised_user_resource_throttle.h
new file mode 100644
index 0000000..f43b42d
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_resource_throttle.h
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_RESOURCE_THROTTLE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_RESOURCE_THROTTLE_H_
+
+#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
+#include "content/public/browser/resource_throttle.h"
+
+class SupervisedUserURLFilter;
+
+namespace net {
+class URLRequest;
+}
+
+class SupervisedUserResourceThrottle : public content::ResourceThrottle {
+ public:
+ SupervisedUserResourceThrottle(const net::URLRequest* request,
+ bool is_main_frame,
+ const SupervisedUserURLFilter* url_filter);
+ virtual ~SupervisedUserResourceThrottle();
+
+ // content::ResourceThrottle implementation:
+ virtual void WillStartRequest(bool* defer) OVERRIDE;
+
+ virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE;
+
+ virtual const char* GetNameForLogging() const OVERRIDE;
+
+ private:
+ void ShowInterstitialIfNeeded(bool is_redirect,
+ const GURL& url,
+ bool* defer);
+ void OnInterstitialResult(bool continue_request);
+
+ const net::URLRequest* request_;
+ bool is_main_frame_;
+ const SupervisedUserURLFilter* url_filter_;
+ base::WeakPtrFactory<SupervisedUserResourceThrottle> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserResourceThrottle);
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_RESOURCE_THROTTLE_H_
diff --git a/chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc b/chrome/browser/supervised_user/supervised_user_resource_throttle_browsertest.cc
index 5b5baf8..d8d8a4a 100644
--- a/chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc
+++ b/chrome/browser/supervised_user/supervised_user_resource_throttle_browsertest.cc
@@ -1,18 +1,18 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_mode_resource_throttle.h"
+#include "chrome/browser/supervised_user/supervised_user_resource_throttle.h"
#include "base/command_line.h"
#include "base/prefs/pref_service.h"
#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -22,45 +22,44 @@
#include "content/public/common/page_type.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
-#include "content/public/test/test_utils.h"
using content::MessageLoopRunner;
using content::NavigationController;
using content::WebContents;
-class ManagedModeResourceThrottleTest : public InProcessBrowserTest {
+class SupervisedUserResourceThrottleTest : public InProcessBrowserTest {
protected:
- ManagedModeResourceThrottleTest() : managed_user_service_(NULL) {}
- virtual ~ManagedModeResourceThrottleTest() {}
+ SupervisedUserResourceThrottleTest() : supervised_user_service_(NULL) {}
+ virtual ~SupervisedUserResourceThrottleTest() {}
private:
virtual void SetUpOnMainThread() OVERRIDE;
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
- ManagedUserService* managed_user_service_;
+ SupervisedUserService* supervised_user_service_;
};
-void ManagedModeResourceThrottleTest::SetUpOnMainThread() {
- managed_user_service_ =
- ManagedUserServiceFactory::GetForProfile(browser()->profile());
+void SupervisedUserResourceThrottleTest::SetUpOnMainThread() {
+ supervised_user_service_ =
+ SupervisedUserServiceFactory::GetForProfile(browser()->profile());
}
-void ManagedModeResourceThrottleTest::SetUpCommandLine(
+void SupervisedUserResourceThrottleTest::SetUpCommandLine(
CommandLine* command_line) {
command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf");
}
// Tests that showing the blocking interstitial for a WebContents without a
-// ManagedModeNavigationObserver doesn't crash.
-IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest,
+// SupervisedUserNavigationObserver doesn't crash.
+IN_PROC_BROWSER_TEST_F(SupervisedUserResourceThrottleTest,
NoNavigationObserverBlock) {
Profile* profile = browser()->profile();
- ManagedUserSettingsService* managed_user_settings_service =
- ManagedUserSettingsServiceFactory::GetForProfile(profile);
- managed_user_settings_service->SetLocalSettingForTesting(
- managed_users::kContentPackDefaultFilteringBehavior,
+ SupervisedUserSettingsService* supervised_user_settings_service =
+ SupervisedUserSettingsServiceFactory::GetForProfile(profile);
+ supervised_user_settings_service->SetLocalSettingForTesting(
+ supervised_users::kContentPackDefaultFilteringBehavior,
scoped_ptr<base::Value>(
- new base::FundamentalValue(ManagedModeURLFilter::BLOCK)));
+ new base::FundamentalValue(SupervisedUserURLFilter::BLOCK)));
scoped_ptr<WebContents> web_contents(
WebContents::Create(WebContents::CreateParams(profile)));
diff --git a/chrome/browser/managed_mode/managed_user_service.cc b/chrome/browser/supervised_user/supervised_user_service.cc
index dab571a..d20661e 100644
--- a/chrome/browser/managed_mode/managed_user_service.cc
+++ b/chrome/browser/supervised_user/supervised_user_service.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "base/command_line.h"
#include "base/memory/ref_counted.h"
@@ -11,25 +11,25 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/managed_mode/custodian_profile_downloader_service.h"
-#include "chrome/browser/managed_mode/custodian_profile_downloader_service_factory.h"
-#include "chrome/browser/managed_mode/managed_mode_site_list.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
-#include "chrome/browser/managed_mode/permission_request_creator_apiary.h"
-#include "chrome/browser/managed_mode/permission_request_creator_sync.h"
-#include "chrome/browser/managed_mode/supervised_user_pref_mapping_service.h"
-#include "chrome/browser/managed_mode/supervised_user_pref_mapping_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/supervised_user/custodian_profile_downloader_service.h"
+#include "chrome/browser/supervised_user/custodian_profile_downloader_service_factory.h"
+#include "chrome/browser/supervised_user/permission_request_creator_apiary.h"
+#include "chrome/browser/supervised_user/permission_request_creator_sync.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_mapping_service.h"
+#include "chrome/browser/supervised_user/supervised_user_pref_mapping_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_site_list.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
@@ -65,38 +65,38 @@ using base::DictionaryValue;
using base::UserMetricsAction;
using content::BrowserThread;
-ManagedUserService::URLFilterContext::URLFilterContext()
- : ui_url_filter_(new ManagedModeURLFilter),
- io_url_filter_(new ManagedModeURLFilter) {}
-ManagedUserService::URLFilterContext::~URLFilterContext() {}
+SupervisedUserService::URLFilterContext::URLFilterContext()
+ : ui_url_filter_(new SupervisedUserURLFilter),
+ io_url_filter_(new SupervisedUserURLFilter) {}
+SupervisedUserService::URLFilterContext::~URLFilterContext() {}
-ManagedModeURLFilter*
-ManagedUserService::URLFilterContext::ui_url_filter() const {
+SupervisedUserURLFilter*
+SupervisedUserService::URLFilterContext::ui_url_filter() const {
return ui_url_filter_.get();
}
-ManagedModeURLFilter*
-ManagedUserService::URLFilterContext::io_url_filter() const {
+SupervisedUserURLFilter*
+SupervisedUserService::URLFilterContext::io_url_filter() const {
return io_url_filter_.get();
}
-void ManagedUserService::URLFilterContext::SetDefaultFilteringBehavior(
- ManagedModeURLFilter::FilteringBehavior behavior) {
+void SupervisedUserService::URLFilterContext::SetDefaultFilteringBehavior(
+ SupervisedUserURLFilter::FilteringBehavior behavior) {
ui_url_filter_->SetDefaultFilteringBehavior(behavior);
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
- base::Bind(&ManagedModeURLFilter::SetDefaultFilteringBehavior,
+ base::Bind(&SupervisedUserURLFilter::SetDefaultFilteringBehavior,
io_url_filter_.get(), behavior));
}
-void ManagedUserService::URLFilterContext::LoadWhitelists(
- ScopedVector<ManagedModeSiteList> site_lists) {
- // ManagedModeURLFilter::LoadWhitelists takes ownership of |site_lists|,
+void SupervisedUserService::URLFilterContext::LoadWhitelists(
+ ScopedVector<SupervisedUserSiteList> site_lists) {
+ // SupervisedUserURLFilter::LoadWhitelists takes ownership of |site_lists|,
// so we make an additional copy of it.
/// TODO(bauerb): This is kinda ugly.
- ScopedVector<ManagedModeSiteList> site_lists_copy;
- for (ScopedVector<ManagedModeSiteList>::iterator it = site_lists.begin();
+ ScopedVector<SupervisedUserSiteList> site_lists_copy;
+ for (ScopedVector<SupervisedUserSiteList>::iterator it = site_lists.begin();
it != site_lists.end(); ++it) {
site_lists_copy.push_back((*it)->Clone());
}
@@ -104,31 +104,31 @@ void ManagedUserService::URLFilterContext::LoadWhitelists(
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
- base::Bind(&ManagedModeURLFilter::LoadWhitelists,
+ base::Bind(&SupervisedUserURLFilter::LoadWhitelists,
io_url_filter_, base::Passed(&site_lists_copy)));
}
-void ManagedUserService::URLFilterContext::SetManualHosts(
+void SupervisedUserService::URLFilterContext::SetManualHosts(
scoped_ptr<std::map<std::string, bool> > host_map) {
ui_url_filter_->SetManualHosts(host_map.get());
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
- base::Bind(&ManagedModeURLFilter::SetManualHosts,
+ base::Bind(&SupervisedUserURLFilter::SetManualHosts,
io_url_filter_, base::Owned(host_map.release())));
}
-void ManagedUserService::URLFilterContext::SetManualURLs(
+void SupervisedUserService::URLFilterContext::SetManualURLs(
scoped_ptr<std::map<GURL, bool> > url_map) {
ui_url_filter_->SetManualURLs(url_map.get());
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
- base::Bind(&ManagedModeURLFilter::SetManualURLs,
+ base::Bind(&SupervisedUserURLFilter::SetManualURLs,
io_url_filter_, base::Owned(url_map.release())));
}
-ManagedUserService::ManagedUserService(Profile* profile)
+SupervisedUserService::SupervisedUserService(Profile* profile)
: profile_(profile),
active_(false),
delegate_(NULL),
@@ -141,24 +141,24 @@ ManagedUserService::ManagedUserService(Profile* profile)
weak_ptr_factory_(this) {
}
-ManagedUserService::~ManagedUserService() {
+SupervisedUserService::~SupervisedUserService() {
DCHECK(did_shutdown_);
}
-void ManagedUserService::Shutdown() {
+void SupervisedUserService::Shutdown() {
did_shutdown_ = true;
- if (ProfileIsManaged()) {
+ if (ProfileIsSupervised()) {
content::RecordAction(UserMetricsAction("ManagedUsers_QuitBrowser"));
}
SetActive(false);
}
-bool ManagedUserService::ProfileIsManaged() const {
+bool SupervisedUserService::ProfileIsSupervised() const {
return profile_->IsSupervised();
}
// static
-void ManagedUserService::RegisterProfilePrefs(
+void SupervisedUserService::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(
prefs::kSupervisedUserManualHosts,
@@ -168,7 +168,7 @@ void ManagedUserService::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterIntegerPref(
prefs::kDefaultSupervisedUserFilteringBehavior,
- ManagedModeURLFilter::ALLOW,
+ SupervisedUserURLFilter::ALLOW,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterStringPref(
prefs::kSupervisedUserCustodianEmail, std::string(),
@@ -181,24 +181,24 @@ void ManagedUserService::RegisterProfilePrefs(
}
// static
-void ManagedUserService::MigrateUserPrefs(PrefService* prefs) {
+void SupervisedUserService::MigrateUserPrefs(PrefService* prefs) {
if (!prefs->HasPrefPath(prefs::kProfileIsSupervised))
return;
- bool is_managed = prefs->GetBoolean(prefs::kProfileIsSupervised);
+ bool is_supervised = prefs->GetBoolean(prefs::kProfileIsSupervised);
prefs->ClearPref(prefs::kProfileIsSupervised);
- if (!is_managed)
+ if (!is_supervised)
return;
- std::string managed_user_id = prefs->GetString(prefs::kSupervisedUserId);
- if (!managed_user_id.empty())
+ std::string supervised_user_id = prefs->GetString(prefs::kSupervisedUserId);
+ if (!supervised_user_id.empty())
return;
prefs->SetString(prefs::kSupervisedUserId, "Dummy ID");
}
-void ManagedUserService::SetDelegate(Delegate* delegate) {
+void SupervisedUserService::SetDelegate(Delegate* delegate) {
if (delegate_ == delegate)
return;
// If the delegate changed, deactivate first to give the old delegate a chance
@@ -207,12 +207,12 @@ void ManagedUserService::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
-scoped_refptr<const ManagedModeURLFilter>
-ManagedUserService::GetURLFilterForIOThread() {
+scoped_refptr<const SupervisedUserURLFilter>
+SupervisedUserService::GetURLFilterForIOThread() {
return url_filter_context_.io_url_filter();
}
-ManagedModeURLFilter* ManagedUserService::GetURLFilterForUIThread() {
+SupervisedUserURLFilter* SupervisedUserService::GetURLFilterForUIThread() {
return url_filter_context_.ui_url_filter();
}
@@ -221,8 +221,8 @@ ManagedModeURLFilter* ManagedUserService::GetURLFilterForUIThread() {
#define CATEGORY_NOT_ON_LIST -1;
#define CATEGORY_OTHER 0;
-int ManagedUserService::GetCategory(const GURL& url) {
- std::vector<ManagedModeSiteList::Site*> sites;
+int SupervisedUserService::GetCategory(const GURL& url) {
+ std::vector<SupervisedUserSiteList::Site*> sites;
GetURLFilterForUIThread()->GetSites(url, &sites);
if (sites.empty())
return CATEGORY_NOT_ON_LIST;
@@ -231,11 +231,11 @@ int ManagedUserService::GetCategory(const GURL& url) {
}
// static
-void ManagedUserService::GetCategoryNames(CategoryList* list) {
- ManagedModeSiteList::GetCategoryNames(list);
+void SupervisedUserService::GetCategoryNames(CategoryList* list) {
+ SupervisedUserSiteList::GetCategoryNames(list);
}
-std::string ManagedUserService::GetCustodianEmailAddress() const {
+std::string SupervisedUserService::GetCustodianEmailAddress() const {
#if defined(OS_CHROMEOS)
return chromeos::UserManager::Get()->GetSupervisedUserManager()->
GetManagerDisplayEmail(
@@ -245,7 +245,7 @@ std::string ManagedUserService::GetCustodianEmailAddress() const {
#endif
}
-std::string ManagedUserService::GetCustodianName() const {
+std::string SupervisedUserService::GetCustodianName() const {
#if defined(OS_CHROMEOS)
return base::UTF16ToUTF8(chromeos::UserManager::Get()->
GetSupervisedUserManager()->GetManagerDisplayName(
@@ -257,12 +257,12 @@ std::string ManagedUserService::GetCustodianName() const {
#endif
}
-void ManagedUserService::AddNavigationBlockedCallback(
+void SupervisedUserService::AddNavigationBlockedCallback(
const NavigationBlockedCallback& callback) {
navigation_blocked_callbacks_.push_back(callback);
}
-void ManagedUserService::DidBlockNavigation(
+void SupervisedUserService::DidBlockNavigation(
content::WebContents* web_contents) {
for (std::vector<NavigationBlockedCallback>::iterator it =
navigation_blocked_callbacks_.begin();
@@ -271,18 +271,18 @@ void ManagedUserService::DidBlockNavigation(
}
}
-std::string ManagedUserService::GetDebugPolicyProviderName() const {
+std::string SupervisedUserService::GetDebugPolicyProviderName() const {
// Save the string space in official builds.
#ifdef NDEBUG
NOTREACHED();
return std::string();
#else
- return "Managed User Service";
+ return "Supervised User Service";
#endif
}
-bool ManagedUserService::UserMayLoad(const extensions::Extension* extension,
- base::string16* error) const {
+bool SupervisedUserService::UserMayLoad(const extensions::Extension* extension,
+ base::string16* error) const {
base::string16 tmp_error;
if (ExtensionManagementPolicyImpl(extension, &tmp_error))
return true;
@@ -318,13 +318,13 @@ bool ManagedUserService::UserMayLoad(const extensions::Extension* extension,
return false;
}
-bool ManagedUserService::UserMayModifySettings(
+bool SupervisedUserService::UserMayModifySettings(
const extensions::Extension* extension,
base::string16* error) const {
return ExtensionManagementPolicyImpl(extension, error);
}
-void ManagedUserService::OnStateChanged() {
+void SupervisedUserService::OnStateChanged() {
ProfileSyncService* service =
ProfileSyncServiceFactory::GetForProfile(profile_);
if (waiting_for_sync_initialization_ && service->sync_initialized()) {
@@ -339,14 +339,14 @@ void ManagedUserService::OnStateChanged() {
<< "Credentials rejected";
}
-void ManagedUserService::OnExtensionLoaded(
+void SupervisedUserService::OnExtensionLoaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension) {
if (!extensions::ManagedModeInfo::GetContentPackSiteList(extension).empty()) {
UpdateSiteLists();
}
}
-void ManagedUserService::OnExtensionUnloaded(
+void SupervisedUserService::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension,
extensions::UnloadedExtensionInfo::Reason reason) {
@@ -355,7 +355,7 @@ void ManagedUserService::OnExtensionUnloaded(
}
}
-void ManagedUserService::SetupSync() {
+void SupervisedUserService::SetupSync() {
ProfileSyncService* service =
ProfileSyncServiceFactory::GetForProfile(profile_);
DCHECK(service->sync_initialized());
@@ -370,11 +370,11 @@ void ManagedUserService::SetupSync() {
service->SetSyncSetupCompleted();
}
-bool ManagedUserService::ExtensionManagementPolicyImpl(
+bool SupervisedUserService::ExtensionManagementPolicyImpl(
const extensions::Extension* extension,
base::string16* error) const {
// |extension| can be NULL in unit_tests.
- if (!ProfileIsManaged() || (extension && extension->is_theme()))
+ if (!ProfileIsSupervised() || (extension && extension->is_theme()))
return true;
if (elevated_for_testing_)
@@ -385,8 +385,9 @@ bool ManagedUserService::ExtensionManagementPolicyImpl(
return false;
}
-ScopedVector<ManagedModeSiteList> ManagedUserService::GetActiveSiteLists() {
- ScopedVector<ManagedModeSiteList> site_lists;
+ScopedVector<SupervisedUserSiteList>
+SupervisedUserService::GetActiveSiteLists() {
+ ScopedVector<SupervisedUserSiteList> site_lists;
ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
// Can be NULL in unit tests.
@@ -403,39 +404,39 @@ ScopedVector<ManagedModeSiteList> ManagedUserService::GetActiveSiteLists() {
extensions::ExtensionResource site_list =
extensions::ManagedModeInfo::GetContentPackSiteList(extension);
if (!site_list.empty()) {
- site_lists.push_back(new ManagedModeSiteList(extension->id(),
- site_list.GetFilePath()));
+ site_lists.push_back(new SupervisedUserSiteList(extension->id(),
+ site_list.GetFilePath()));
}
}
return site_lists.Pass();
}
-ManagedUserSettingsService* ManagedUserService::GetSettingsService() {
- return ManagedUserSettingsServiceFactory::GetForProfile(profile_);
+SupervisedUserSettingsService* SupervisedUserService::GetSettingsService() {
+ return SupervisedUserSettingsServiceFactory::GetForProfile(profile_);
}
-void ManagedUserService::OnManagedUserIdChanged() {
- std::string managed_user_id =
+void SupervisedUserService::OnSupervisedUserIdChanged() {
+ std::string supervised_user_id =
profile_->GetPrefs()->GetString(prefs::kSupervisedUserId);
- SetActive(!managed_user_id.empty());
+ SetActive(!supervised_user_id.empty());
}
-void ManagedUserService::OnDefaultFilteringBehaviorChanged() {
- DCHECK(ProfileIsManaged());
+void SupervisedUserService::OnDefaultFilteringBehaviorChanged() {
+ DCHECK(ProfileIsSupervised());
int behavior_value = profile_->GetPrefs()->GetInteger(
prefs::kDefaultSupervisedUserFilteringBehavior);
- ManagedModeURLFilter::FilteringBehavior behavior =
- ManagedModeURLFilter::BehaviorFromInt(behavior_value);
+ SupervisedUserURLFilter::FilteringBehavior behavior =
+ SupervisedUserURLFilter::BehaviorFromInt(behavior_value);
url_filter_context_.SetDefaultFilteringBehavior(behavior);
}
-void ManagedUserService::UpdateSiteLists() {
+void SupervisedUserService::UpdateSiteLists() {
url_filter_context_.LoadWhitelists(GetActiveSiteLists());
}
-bool ManagedUserService::AccessRequestsEnabled() {
+bool SupervisedUserService::AccessRequestsEnabled() {
if (waiting_for_permissions_)
return false;
@@ -448,16 +449,16 @@ bool ManagedUserService::AccessRequestsEnabled() {
state == GoogleServiceAuthError::SERVICE_UNAVAILABLE);
}
-void ManagedUserService::OnPermissionRequestIssued() {
+void SupervisedUserService::OnPermissionRequestIssued() {
waiting_for_permissions_ = false;
// TODO(akuegel): Figure out how to show the result of issuing the permission
// request in the UI. Currently, we assume the permission request was created
// successfully.
}
-void ManagedUserService::AddAccessRequest(const GURL& url) {
+void SupervisedUserService::AddAccessRequest(const GURL& url) {
// Normalize the URL.
- GURL normalized_url = ManagedModeURLFilter::Normalize(url);
+ GURL normalized_url = SupervisedUserURLFilter::Normalize(url);
// Escape the URL.
std::string output(net::EscapeQueryParamValue(normalized_url.spec(), true));
@@ -465,11 +466,12 @@ void ManagedUserService::AddAccessRequest(const GURL& url) {
waiting_for_permissions_ = true;
permissions_creator_->CreatePermissionRequest(
output,
- base::Bind(&ManagedUserService::OnPermissionRequestIssued,
+ base::Bind(&SupervisedUserService::OnPermissionRequestIssued,
weak_ptr_factory_.GetWeakPtr()));
}
-ManagedUserService::ManualBehavior ManagedUserService::GetManualBehaviorForHost(
+SupervisedUserService::ManualBehavior
+SupervisedUserService::GetManualBehaviorForHost(
const std::string& hostname) {
const base::DictionaryValue* dict =
profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualHosts);
@@ -480,11 +482,12 @@ ManagedUserService::ManualBehavior ManagedUserService::GetManualBehaviorForHost(
return allow ? MANUAL_ALLOW : MANUAL_BLOCK;
}
-ManagedUserService::ManualBehavior ManagedUserService::GetManualBehaviorForURL(
+SupervisedUserService::ManualBehavior
+SupervisedUserService::GetManualBehaviorForURL(
const GURL& url) {
const base::DictionaryValue* dict =
profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualURLs);
- GURL normalized_url = ManagedModeURLFilter::Normalize(url);
+ GURL normalized_url = SupervisedUserURLFilter::Normalize(url);
bool allow = false;
if (!dict->GetBooleanWithoutPathExpansion(normalized_url.spec(), &allow))
return MANUAL_NONE;
@@ -492,8 +495,9 @@ ManagedUserService::ManualBehavior ManagedUserService::GetManualBehaviorForURL(
return allow ? MANUAL_ALLOW : MANUAL_BLOCK;
}
-void ManagedUserService::GetManualExceptionsForHost(const std::string& host,
- std::vector<GURL>* urls) {
+void SupervisedUserService::GetManualExceptionsForHost(
+ const std::string& host,
+ std::vector<GURL>* urls) {
const base::DictionaryValue* dict =
profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualURLs);
for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
@@ -503,7 +507,7 @@ void ManagedUserService::GetManualExceptionsForHost(const std::string& host,
}
}
-void ManagedUserService::InitSync(const std::string& refresh_token) {
+void SupervisedUserService::InitSync(const std::string& refresh_token) {
ProfileSyncService* service =
ProfileSyncServiceFactory::GetForProfile(profile_);
// Tell the sync service that setup is in progress so we don't start syncing
@@ -512,7 +516,7 @@ void ManagedUserService::InitSync(const std::string& refresh_token) {
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
- token_service->UpdateCredentials(managed_users::kManagedUserPseudoEmail,
+ token_service->UpdateCredentials(supervised_users::kSupervisedUserPseudoEmail,
refresh_token);
// Continue in SetupSync() once the Sync backend has been initialized.
@@ -524,19 +528,19 @@ void ManagedUserService::InitSync(const std::string& refresh_token) {
}
}
-void ManagedUserService::Init() {
+void SupervisedUserService::Init() {
DCHECK(GetSettingsService()->IsReady());
pref_change_registrar_.Init(profile_->GetPrefs());
pref_change_registrar_.Add(
prefs::kSupervisedUserId,
- base::Bind(&ManagedUserService::OnManagedUserIdChanged,
+ base::Bind(&SupervisedUserService::OnSupervisedUserIdChanged,
base::Unretained(this)));
- SetActive(ProfileIsManaged());
+ SetActive(ProfileIsSupervised());
}
-void ManagedUserService::SetActive(bool active) {
+void SupervisedUserService::SetActive(bool active) {
if (active_ == active)
return;
active_ = active;
@@ -555,7 +559,8 @@ void ManagedUserService::SetActive(bool active) {
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
- token_service->LoadCredentials(managed_users::kManagedUserPseudoEmail);
+ token_service->LoadCredentials(
+ supervised_users::kSupervisedUserPseudoEmail);
}
}
@@ -569,7 +574,7 @@ void ManagedUserService::SetActive(bool active) {
}
#endif
- ManagedUserSettingsService* settings_service = GetSettingsService();
+ SupervisedUserSettingsService* settings_service = GetSettingsService();
settings_service->SetActive(active_);
extensions::ExtensionSystem* extension_system =
@@ -586,7 +591,7 @@ void ManagedUserService::SetActive(bool active) {
PrefService* pref_service = profile_->GetPrefs();
permissions_creator_.reset(new PermissionRequestCreatorSync(
settings_service,
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
profile_),
pref_service->GetString(prefs::kProfileName),
pref_service->GetString(prefs::kSupervisedUserId)));
@@ -600,13 +605,13 @@ void ManagedUserService::SetActive(bool active) {
pref_change_registrar_.Add(
prefs::kDefaultSupervisedUserFilteringBehavior,
- base::Bind(&ManagedUserService::OnDefaultFilteringBehaviorChanged,
+ base::Bind(&SupervisedUserService::OnDefaultFilteringBehaviorChanged,
base::Unretained(this)));
pref_change_registrar_.Add(prefs::kSupervisedUserManualHosts,
- base::Bind(&ManagedUserService::UpdateManualHosts,
+ base::Bind(&SupervisedUserService::UpdateManualHosts,
base::Unretained(this)));
pref_change_registrar_.Add(prefs::kSupervisedUserManualURLs,
- base::Bind(&ManagedUserService::UpdateManualURLs,
+ base::Bind(&SupervisedUserService::UpdateManualURLs,
base::Unretained(this)));
// Initialize the filter.
@@ -647,23 +652,23 @@ void ManagedUserService::SetActive(bool active) {
}
}
-void ManagedUserService::RegisterAndInitSync(
- ManagedUserRegistrationUtility* registration_utility,
+void SupervisedUserService::RegisterAndInitSync(
+ SupervisedUserRegistrationUtility* registration_utility,
Profile* custodian_profile,
- const std::string& managed_user_id,
+ const std::string& supervised_user_id,
const AuthErrorCallback& callback) {
- DCHECK(ProfileIsManaged());
+ DCHECK(ProfileIsSupervised());
DCHECK(!custodian_profile->IsSupervised());
base::string16 name = base::UTF8ToUTF16(
profile_->GetPrefs()->GetString(prefs::kProfileName));
int avatar_index = profile_->GetPrefs()->GetInteger(
prefs::kProfileAvatarIndex);
- ManagedUserRegistrationInfo info(name, avatar_index);
+ SupervisedUserRegistrationInfo info(name, avatar_index);
registration_utility->Register(
- managed_user_id,
+ supervised_user_id,
info,
- base::Bind(&ManagedUserService::OnManagedUserRegistered,
+ base::Bind(&SupervisedUserService::OnSupervisedUserRegistered,
weak_ptr_factory_.GetWeakPtr(), callback, custodian_profile));
// Fetch the custodian's profile information, to store the name.
@@ -673,17 +678,17 @@ void ManagedUserService::RegisterAndInitSync(
CustodianProfileDownloaderServiceFactory::GetForProfile(
custodian_profile);
profile_downloader_service->DownloadProfile(
- base::Bind(&ManagedUserService::OnCustodianProfileDownloaded,
+ base::Bind(&SupervisedUserService::OnCustodianProfileDownloaded,
weak_ptr_factory_.GetWeakPtr()));
}
-void ManagedUserService::OnCustodianProfileDownloaded(
+void SupervisedUserService::OnCustodianProfileDownloaded(
const base::string16& full_name) {
profile_->GetPrefs()->SetString(prefs::kSupervisedUserCustodianName,
base::UTF16ToUTF8(full_name));
}
-void ManagedUserService::OnManagedUserRegistered(
+void SupervisedUserService::OnSupervisedUserRegistered(
const AuthErrorCallback& callback,
Profile* custodian_profile,
const GoogleServiceAuthError& auth_error,
@@ -695,7 +700,7 @@ void ManagedUserService::OnManagedUserRegistered(
profile_->GetPrefs()->SetString(prefs::kSupervisedUserCustodianEmail,
signin->GetAuthenticatedUsername());
- // The managed-user profile is now ready for use.
+ // The supervised user profile is now ready for use.
ProfileManager* profile_manager = g_browser_process->profile_manager();
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
size_t index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
@@ -707,7 +712,7 @@ void ManagedUserService::OnManagedUserRegistered(
callback.Run(auth_error);
}
-void ManagedUserService::UpdateManualHosts() {
+void SupervisedUserService::UpdateManualHosts() {
const base::DictionaryValue* dict =
profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualHosts);
scoped_ptr<std::map<std::string, bool> > host_map(
@@ -721,7 +726,7 @@ void ManagedUserService::UpdateManualHosts() {
url_filter_context_.SetManualHosts(host_map.Pass());
}
-void ManagedUserService::UpdateManualURLs() {
+void SupervisedUserService::UpdateManualURLs() {
const base::DictionaryValue* dict =
profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualURLs);
scoped_ptr<std::map<GURL, bool> > url_map(new std::map<GURL, bool>());
@@ -734,7 +739,7 @@ void ManagedUserService::UpdateManualURLs() {
url_filter_context_.SetManualURLs(url_map.Pass());
}
-void ManagedUserService::OnBrowserSetLastActive(Browser* browser) {
+void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) {
bool profile_became_active = profile_->IsSameProfile(browser->profile());
if (!is_profile_active_ && profile_became_active)
content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile"));
diff --git a/chrome/browser/managed_mode/managed_user_service.h b/chrome/browser/supervised_user/supervised_user_service.h
index 730f021..ae20046 100644
--- a/chrome/browser/managed_mode/managed_user_service.h
+++ b/chrome/browser/supervised_user/supervised_user_service.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_
#include <set>
#include <vector>
@@ -14,8 +14,8 @@
#include "base/prefs/pref_change_registrar.h"
#include "base/scoped_observer.h"
#include "base/strings/string16.h"
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -25,12 +25,12 @@
class Browser;
class GoogleServiceAuthError;
-class ManagedModeURLFilter;
-class ManagedModeSiteList;
-class ManagedUserRegistrationUtility;
-class ManagedUserSettingsService;
class PermissionRequestCreator;
class Profile;
+class SupervisedUserRegistrationUtility;
+class SupervisedUserSettingsService;
+class SupervisedUserSiteList;
+class SupervisedUserURLFilter;
namespace extensions {
class ExtensionRegistry;
@@ -40,14 +40,14 @@ namespace user_prefs {
class PrefRegistrySyncable;
}
-// This class handles all the information related to a given managed profile
+// This class handles all the information related to a given supervised profile
// (e.g. the installed content packs, the default URL filtering behavior, or
// manual whitelist/blacklist overrides).
-class ManagedUserService : public KeyedService,
- public extensions::ManagementPolicy::Provider,
- public ProfileSyncServiceObserver,
- public extensions::ExtensionRegistryObserver,
- public chrome::BrowserListObserver {
+class SupervisedUserService : public KeyedService,
+ public extensions::ManagementPolicy::Provider,
+ public ProfileSyncServiceObserver,
+ public extensions::ExtensionRegistryObserver,
+ public chrome::BrowserListObserver {
public:
typedef std::vector<base::string16> CategoryList;
typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback;
@@ -63,11 +63,11 @@ class ManagedUserService : public KeyedService,
public:
virtual ~Delegate() {}
// Returns true to indicate that the delegate handled the (de)activation, or
- // false to indicate that the ManagedUserService itself should handle it.
+ // false to indicate that the SupervisedUserService itself should handle it.
virtual bool SetActive(bool active) = 0;
};
- virtual ~ManagedUserService();
+ virtual ~SupervisedUserService();
// ProfileKeyedService override:
virtual void Shutdown() OVERRIDE;
@@ -79,12 +79,12 @@ class ManagedUserService : public KeyedService,
void SetDelegate(Delegate* delegate);
// Returns the URL filter for the IO thread, for filtering network requests
- // (in ManagedModeResourceThrottle).
- scoped_refptr<const ManagedModeURLFilter> GetURLFilterForIOThread();
+ // (in SupervisedUserResourceThrottle).
+ scoped_refptr<const SupervisedUserURLFilter> GetURLFilterForIOThread();
// Returns the URL filter for the UI thread, for filtering navigations and
// classifying sites in the history view.
- ManagedModeURLFilter* GetURLFilterForUIThread();
+ SupervisedUserURLFilter* GetURLFilterForUIThread();
// Returns the URL's category, obtained from the installed content packs.
int GetCategory(const GURL& url);
@@ -126,22 +126,23 @@ class ManagedUserService : public KeyedService,
std::vector<GURL>* urls);
// Initializes this object. This method does nothing if the profile is not
- // managed.
+ // supervised.
void Init();
// Initializes this profile for syncing, using the provided |refresh_token| to
// mint access tokens for Sync.
void InitSync(const std::string& refresh_token);
- // Convenience method that registers this managed user using
+ // Convenience method that registers this supervised user using
// |registration_utility| and initializes sync with the returned token.
// The |callback| will be called when registration is complete,
// whether it suceeded or not -- unless registration was cancelled manually,
// in which case the callback will be ignored.
- void RegisterAndInitSync(ManagedUserRegistrationUtility* registration_utility,
- Profile* custodian_profile,
- const std::string& managed_user_id,
- const AuthErrorCallback& callback);
+ void RegisterAndInitSync(
+ SupervisedUserRegistrationUtility* registration_utility,
+ Profile* custodian_profile,
+ const std::string& supervised_user_id,
+ const AuthErrorCallback& callback);
void set_elevated_for_testing(bool skip) {
elevated_for_testing_ = skip;
@@ -173,56 +174,56 @@ class ManagedUserService : public KeyedService,
virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE;
private:
- friend class ManagedUserServiceExtensionTestBase;
- friend class ManagedUserServiceFactory;
- FRIEND_TEST_ALL_PREFIXES(ManagedUserServiceTest, ClearOmitOnRegistration);
+ friend class SupervisedUserServiceExtensionTestBase;
+ friend class SupervisedUserServiceFactory;
+ FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration);
- // A bridge from ManagedMode (which lives on the UI thread) to the
- // ManagedModeURLFilters, one of which lives on the IO thread. This class
- // mediates access to them and makes sure they are kept in sync.
+ // A bridge from the UI thread to the SupervisedUserURLFilters, one of which
+ // lives on the IO thread. This class mediates access to them and makes sure
+ // they are kept in sync.
class URLFilterContext {
public:
URLFilterContext();
~URLFilterContext();
- ManagedModeURLFilter* ui_url_filter() const;
- ManagedModeURLFilter* io_url_filter() const;
+ SupervisedUserURLFilter* ui_url_filter() const;
+ SupervisedUserURLFilter* io_url_filter() const;
void SetDefaultFilteringBehavior(
- ManagedModeURLFilter::FilteringBehavior behavior);
- void LoadWhitelists(ScopedVector<ManagedModeSiteList> site_lists);
+ SupervisedUserURLFilter::FilteringBehavior behavior);
+ void LoadWhitelists(ScopedVector<SupervisedUserSiteList> site_lists);
void SetManualHosts(scoped_ptr<std::map<std::string, bool> > host_map);
void SetManualURLs(scoped_ptr<std::map<GURL, bool> > url_map);
private:
- // ManagedModeURLFilter is refcounted because the IO thread filter is used
- // both by ProfileImplIOData and OffTheRecordProfileIOData (to filter
+ // SupervisedUserURLFilter is refcounted because the IO thread filter is
+ // used both by ProfileImplIOData and OffTheRecordProfileIOData (to filter
// network requests), so they both keep a reference to it.
// Clients should not keep references to the UI thread filter, however
// (the filter will live as long as the profile lives, and afterwards it
// should not be used anymore either).
- scoped_refptr<ManagedModeURLFilter> ui_url_filter_;
- scoped_refptr<ManagedModeURLFilter> io_url_filter_;
+ scoped_refptr<SupervisedUserURLFilter> ui_url_filter_;
+ scoped_refptr<SupervisedUserURLFilter> io_url_filter_;
DISALLOW_COPY_AND_ASSIGN(URLFilterContext);
};
- // Use |ManagedUserServiceFactory::GetForProfile(..)| to get
+ // Use |SupervisedUserServiceFactory::GetForProfile(..)| to get
// an instance of this service.
- explicit ManagedUserService(Profile* profile);
+ explicit SupervisedUserService(Profile* profile);
void SetActive(bool active);
void OnCustodianProfileDownloaded(const base::string16& full_name);
- void OnManagedUserRegistered(const AuthErrorCallback& callback,
- Profile* custodian_profile,
- const GoogleServiceAuthError& auth_error,
- const std::string& token);
+ void OnSupervisedUserRegistered(const AuthErrorCallback& callback,
+ Profile* custodian_profile,
+ const GoogleServiceAuthError& auth_error,
+ const std::string& token);
void SetupSync();
- bool ProfileIsManaged() const;
+ bool ProfileIsSupervised() const;
// Internal implementation for ExtensionManagementPolicy::Delegate methods.
// If |error| is not NULL, it will be filled with an error message if the
@@ -231,12 +232,12 @@ class ManagedUserService : public KeyedService,
base::string16* error) const;
// Returns a list of all installed and enabled site lists in the current
- // managed profile.
- ScopedVector<ManagedModeSiteList> GetActiveSiteLists();
+ // supervised profile.
+ ScopedVector<SupervisedUserSiteList> GetActiveSiteLists();
- ManagedUserSettingsService* GetSettingsService();
+ SupervisedUserSettingsService* GetSettingsService();
- void OnManagedUserIdChanged();
+ void OnSupervisedUserIdChanged();
void OnDefaultFilteringBehaviorChanged();
@@ -283,7 +284,7 @@ class ManagedUserService : public KeyedService,
// True iff we are waiting for a permission request to be issued.
bool waiting_for_permissions_;
- base::WeakPtrFactory<ManagedUserService> weak_ptr_factory_;
+ base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_
diff --git a/chrome/browser/managed_mode/managed_user_service_browsertest.cc b/chrome/browser/supervised_user/supervised_user_service_browsertest.cc
index 7702154..a652e8d 100644
--- a/chrome/browser/managed_mode/managed_user_service_browsertest.cc
+++ b/chrome/browser/supervised_user/supervised_user_service_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,14 +7,14 @@
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -26,7 +26,7 @@ namespace {
void TestAuthErrorCallback(const GoogleServiceAuthError& error) {}
-class ManagedUserServiceTestManaged : public InProcessBrowserTest {
+class SupervisedUserServiceTestSupervised : public InProcessBrowserTest {
public:
// content::BrowserTestBase:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
@@ -36,7 +36,7 @@ class ManagedUserServiceTestManaged : public InProcessBrowserTest {
} // namespace
-typedef InProcessBrowserTest ManagedUserServiceTest;
+typedef InProcessBrowserTest SupervisedUserServiceTest;
// Crashes on Mac.
// http://crbug.com/339501
@@ -47,7 +47,8 @@ typedef InProcessBrowserTest ManagedUserServiceTest;
#endif
// Ensure that a profile that has completed registration is included in the
// list shown in the avatar menu.
-IN_PROC_BROWSER_TEST_F(ManagedUserServiceTest, MAYBE_ClearOmitOnRegistration) {
+IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTest,
+ MAYBE_ClearOmitOnRegistration) {
// Artificially mark the profile as omitted.
ProfileManager* profile_manager = g_browser_process->profile_manager();
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
@@ -56,12 +57,12 @@ IN_PROC_BROWSER_TEST_F(ManagedUserServiceTest, MAYBE_ClearOmitOnRegistration) {
cache.SetIsOmittedProfileAtIndex(index, true);
ASSERT_TRUE(cache.IsOmittedProfileAtIndex(index));
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile);
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile);
// A registration error does not clear the flag (the profile should be deleted
// anyway).
- managed_user_service->OnManagedUserRegistered(
+ supervised_user_service->OnSupervisedUserRegistered(
base::Bind(&TestAuthErrorCallback),
profile,
GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED),
@@ -69,7 +70,7 @@ IN_PROC_BROWSER_TEST_F(ManagedUserServiceTest, MAYBE_ClearOmitOnRegistration) {
ASSERT_TRUE(cache.IsOmittedProfileAtIndex(index));
// Successfully completing registration clears the flag.
- managed_user_service->OnManagedUserRegistered(
+ supervised_user_service->OnSupervisedUserRegistered(
base::Bind(&TestAuthErrorCallback),
profile,
GoogleServiceAuthError(GoogleServiceAuthError::NONE),
@@ -77,14 +78,14 @@ IN_PROC_BROWSER_TEST_F(ManagedUserServiceTest, MAYBE_ClearOmitOnRegistration) {
EXPECT_FALSE(cache.IsOmittedProfileAtIndex(index));
}
-IN_PROC_BROWSER_TEST_F(ManagedUserServiceTest, LocalPolicies) {
+IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTest, LocalPolicies) {
Profile* profile = browser()->profile();
PrefService* prefs = profile->GetPrefs();
EXPECT_FALSE(prefs->GetBoolean(prefs::kForceSafeSearch));
EXPECT_TRUE(prefs->IsUserModifiablePreference(prefs::kForceSafeSearch));
}
-IN_PROC_BROWSER_TEST_F(ManagedUserServiceTest, ProfileName) {
+IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTest, ProfileName) {
Profile* profile = browser()->profile();
PrefService* prefs = profile->GetPrefs();
EXPECT_TRUE(prefs->IsUserModifiablePreference(prefs::kProfileName));
@@ -97,26 +98,26 @@ IN_PROC_BROWSER_TEST_F(ManagedUserServiceTest, ProfileName) {
base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_index)));
}
-IN_PROC_BROWSER_TEST_F(ManagedUserServiceTestManaged, LocalPolicies) {
+IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTestSupervised, LocalPolicies) {
Profile* profile = browser()->profile();
PrefService* prefs = profile->GetPrefs();
EXPECT_TRUE(prefs->GetBoolean(prefs::kForceSafeSearch));
EXPECT_FALSE(prefs->IsUserModifiablePreference(prefs::kForceSafeSearch));
}
-IN_PROC_BROWSER_TEST_F(ManagedUserServiceTestManaged, ProfileName) {
+IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTestSupervised, ProfileName) {
Profile* profile = browser()->profile();
PrefService* prefs = profile->GetPrefs();
std::string original_name = prefs->GetString(prefs::kProfileName);
ProfileManager* profile_manager = g_browser_process->profile_manager();
const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
- ManagedUserSettingsService* settings =
- ManagedUserSettingsServiceFactory::GetForProfile(profile);
+ SupervisedUserSettingsService* settings =
+ SupervisedUserSettingsServiceFactory::GetForProfile(profile);
- std::string name = "Managed User Test Name";
+ std::string name = "Supervised User Test Name";
settings->SetLocalSettingForTesting(
- managed_users::kUserName,
+ supervised_users::kUserName,
scoped_ptr<base::Value>(new base::StringValue(name)));
EXPECT_FALSE(prefs->IsUserModifiablePreference(prefs::kProfileName));
EXPECT_EQ(name, prefs->GetString(prefs::kProfileName));
@@ -125,9 +126,9 @@ IN_PROC_BROWSER_TEST_F(ManagedUserServiceTestManaged, ProfileName) {
base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_index)));
// Change the name once more.
- std::string new_name = "New Managed User Test Name";
+ std::string new_name = "New Supervised User Test Name";
settings->SetLocalSettingForTesting(
- managed_users::kUserName,
+ supervised_users::kUserName,
scoped_ptr<base::Value>(new base::StringValue(new_name)));
EXPECT_EQ(new_name, prefs->GetString(prefs::kProfileName));
profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath());
@@ -135,7 +136,7 @@ IN_PROC_BROWSER_TEST_F(ManagedUserServiceTestManaged, ProfileName) {
base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_index)));
// Remove the setting.
- settings->SetLocalSettingForTesting(managed_users::kUserName,
+ settings->SetLocalSettingForTesting(supervised_users::kUserName,
scoped_ptr<base::Value>());
EXPECT_EQ(original_name, prefs->GetString(prefs::kProfileName));
profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath());
diff --git a/chrome/browser/managed_mode/managed_user_service_factory.cc b/chrome/browser/supervised_user/supervised_user_service_factory.cc
index 249adaa..715ef2a 100644
--- a/chrome/browser/managed_mode/managed_user_service_factory.cc
+++ b/chrome/browser/supervised_user/supervised_user_service_factory.cc
@@ -1,50 +1,51 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/extension_system_provider.h"
#include "extensions/browser/extensions_browser_client.h"
// static
-ManagedUserService* ManagedUserServiceFactory::GetForProfile(Profile* profile) {
- return static_cast<ManagedUserService*>(
+SupervisedUserService* SupervisedUserServiceFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<SupervisedUserService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
// static
-ManagedUserServiceFactory* ManagedUserServiceFactory::GetInstance() {
- return Singleton<ManagedUserServiceFactory>::get();
+SupervisedUserServiceFactory* SupervisedUserServiceFactory::GetInstance() {
+ return Singleton<SupervisedUserServiceFactory>::get();
}
// static
-KeyedService* ManagedUserServiceFactory::BuildInstanceFor(Profile* profile) {
- return new ManagedUserService(profile);
+KeyedService* SupervisedUserServiceFactory::BuildInstanceFor(Profile* profile) {
+ return new SupervisedUserService(profile);
}
-ManagedUserServiceFactory::ManagedUserServiceFactory()
+SupervisedUserServiceFactory::SupervisedUserServiceFactory()
: BrowserContextKeyedServiceFactory(
- "ManagedUserService",
+ "SupervisedUserService",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
}
-ManagedUserServiceFactory::~ManagedUserServiceFactory() {}
+SupervisedUserServiceFactory::~SupervisedUserServiceFactory() {}
-content::BrowserContext* ManagedUserServiceFactory::GetBrowserContextToUse(
+content::BrowserContext* SupervisedUserServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context);
}
-KeyedService* ManagedUserServiceFactory::BuildServiceInstanceFor(
+KeyedService* SupervisedUserServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
return BuildInstanceFor(static_cast<Profile*>(profile));
}
diff --git a/chrome/browser/supervised_user/supervised_user_service_factory.h b/chrome/browser/supervised_user/supervised_user_service_factory.h
new file mode 100644
index 0000000..a5c2884
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_service_factory.h
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_FACTORY_H_
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+
+class Profile;
+class SupervisedUserService;
+
+class SupervisedUserServiceFactory : public BrowserContextKeyedServiceFactory {
+ public:
+ static SupervisedUserService* GetForProfile(Profile* profile);
+
+ static SupervisedUserServiceFactory* GetInstance();
+
+ // Used to create instances for testing.
+ static KeyedService* BuildInstanceFor(Profile* profile);
+
+ private:
+ friend struct DefaultSingletonTraits<SupervisedUserServiceFactory>;
+
+ SupervisedUserServiceFactory();
+ virtual ~SupervisedUserServiceFactory();
+
+ // BrowserContextKeyedServiceFactory:
+ virtual content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const OVERRIDE;
+ virtual KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const OVERRIDE;
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/managed_user_service_unittest.cc b/chrome/browser/supervised_user/supervised_user_service_unittest.cc
index 862bf69..33418999 100644
--- a/chrome/browser/managed_mode/managed_user_service_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_service_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,14 +9,14 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/browser/extensions/unpacked_installer.h"
-#include "chrome/browser/managed_mode/custodian_profile_downloader_service.h"
-#include "chrome/browser/managed_mode/custodian_profile_downloader_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/supervised_user/custodian_profile_downloader_service.h"
+#include "chrome/browser/supervised_user/custodian_profile_downloader_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/features/feature_channel.h"
@@ -37,15 +37,16 @@ void OnProfileDownloadedFail(const base::string16& full_name) {
ASSERT_TRUE(false) << "Profile download should not have succeeded.";
}
-class ManagedModeURLFilterObserver : public ManagedModeURLFilter::Observer {
+class SupervisedUserURLFilterObserver :
+ public SupervisedUserURLFilter::Observer {
public:
- explicit ManagedModeURLFilterObserver(ManagedModeURLFilter* url_filter)
+ explicit SupervisedUserURLFilterObserver(SupervisedUserURLFilter* url_filter)
: url_filter_(url_filter) {
Reset();
url_filter_->AddObserver(this);
}
- ~ManagedModeURLFilterObserver() {
+ ~SupervisedUserURLFilterObserver() {
url_filter_->RemoveObserver(this);
}
@@ -54,7 +55,7 @@ class ManagedModeURLFilterObserver : public ManagedModeURLFilter::Observer {
Reset();
}
- // ManagedModeURLFilter::Observer
+ // SupervisedUserURLFilter::Observer
virtual void OnSiteListUpdated() OVERRIDE {
message_loop_runner_->Quit();
}
@@ -64,38 +65,38 @@ class ManagedModeURLFilterObserver : public ManagedModeURLFilter::Observer {
message_loop_runner_ = new MessageLoopRunner;
}
- ManagedModeURLFilter* url_filter_;
+ SupervisedUserURLFilter* url_filter_;
scoped_refptr<MessageLoopRunner> message_loop_runner_;
};
-class ManagedUserServiceTest : public ::testing::Test {
+class SupervisedUserServiceTest : public ::testing::Test {
public:
- ManagedUserServiceTest() {}
+ SupervisedUserServiceTest() {}
virtual void SetUp() OVERRIDE {
TestingProfile::Builder builder;
builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
BuildFakeProfileOAuth2TokenService);
profile_ = builder.Build();
- managed_user_service_ =
- ManagedUserServiceFactory::GetForProfile(profile_.get());
+ supervised_user_service_ =
+ SupervisedUserServiceFactory::GetForProfile(profile_.get());
}
virtual void TearDown() OVERRIDE {
profile_.reset();
}
- virtual ~ManagedUserServiceTest() {}
+ virtual ~SupervisedUserServiceTest() {}
protected:
content::TestBrowserThreadBundle thread_bundle_;
scoped_ptr<TestingProfile> profile_;
- ManagedUserService* managed_user_service_;
+ SupervisedUserService* supervised_user_service_;
};
} // namespace
-TEST_F(ManagedUserServiceTest, GetManualExceptionsForHost) {
+TEST_F(SupervisedUserServiceTest, GetManualExceptionsForHost) {
GURL kExampleFooURL("http://www.example.com/foo");
GURL kExampleBarURL("http://www.example.com/bar");
GURL kExampleFooNoWWWURL("http://example.com/foo");
@@ -111,20 +112,20 @@ TEST_F(ManagedUserServiceTest, GetManualExceptionsForHost) {
dict->SetBooleanWithoutPathExpansion(kBlurpURL.spec(), true);
}
- EXPECT_EQ(ManagedUserService::MANUAL_ALLOW,
- managed_user_service_->GetManualBehaviorForURL(kExampleFooURL));
- EXPECT_EQ(ManagedUserService::MANUAL_BLOCK,
- managed_user_service_->GetManualBehaviorForURL(kExampleBarURL));
- EXPECT_EQ(ManagedUserService::MANUAL_ALLOW,
- managed_user_service_->GetManualBehaviorForURL(
+ EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW,
+ supervised_user_service_->GetManualBehaviorForURL(kExampleFooURL));
+ EXPECT_EQ(SupervisedUserService::MANUAL_BLOCK,
+ supervised_user_service_->GetManualBehaviorForURL(kExampleBarURL));
+ EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW,
+ supervised_user_service_->GetManualBehaviorForURL(
kExampleFooNoWWWURL));
- EXPECT_EQ(ManagedUserService::MANUAL_ALLOW,
- managed_user_service_->GetManualBehaviorForURL(kBlurpURL));
- EXPECT_EQ(ManagedUserService::MANUAL_NONE,
- managed_user_service_->GetManualBehaviorForURL(kMooseURL));
+ EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW,
+ supervised_user_service_->GetManualBehaviorForURL(kBlurpURL));
+ EXPECT_EQ(SupervisedUserService::MANUAL_NONE,
+ supervised_user_service_->GetManualBehaviorForURL(kMooseURL));
std::vector<GURL> exceptions;
- managed_user_service_->GetManualExceptionsForHost("www.example.com",
- &exceptions);
+ supervised_user_service_->GetManualExceptionsForHost("www.example.com",
+ &exceptions);
ASSERT_EQ(2u, exceptions.size());
EXPECT_EQ(kExampleBarURL, exceptions[0]);
EXPECT_EQ(kExampleFooURL, exceptions[1]);
@@ -139,22 +140,22 @@ TEST_F(ManagedUserServiceTest, GetManualExceptionsForHost) {
}
}
- EXPECT_EQ(ManagedUserService::MANUAL_NONE,
- managed_user_service_->GetManualBehaviorForURL(kExampleFooURL));
- EXPECT_EQ(ManagedUserService::MANUAL_NONE,
- managed_user_service_->GetManualBehaviorForURL(kExampleBarURL));
- EXPECT_EQ(ManagedUserService::MANUAL_ALLOW,
- managed_user_service_->GetManualBehaviorForURL(
+ EXPECT_EQ(SupervisedUserService::MANUAL_NONE,
+ supervised_user_service_->GetManualBehaviorForURL(kExampleFooURL));
+ EXPECT_EQ(SupervisedUserService::MANUAL_NONE,
+ supervised_user_service_->GetManualBehaviorForURL(kExampleBarURL));
+ EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW,
+ supervised_user_service_->GetManualBehaviorForURL(
kExampleFooNoWWWURL));
- EXPECT_EQ(ManagedUserService::MANUAL_ALLOW,
- managed_user_service_->GetManualBehaviorForURL(kBlurpURL));
- EXPECT_EQ(ManagedUserService::MANUAL_NONE,
- managed_user_service_->GetManualBehaviorForURL(kMooseURL));
+ EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW,
+ supervised_user_service_->GetManualBehaviorForURL(kBlurpURL));
+ EXPECT_EQ(SupervisedUserService::MANUAL_NONE,
+ supervised_user_service_->GetManualBehaviorForURL(kMooseURL));
}
// Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no
// DCHECK is hit when the service is destroyed, this test passed.
-TEST_F(ManagedUserServiceTest, ShutDownCustodianProfileDownloader) {
+TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) {
CustodianProfileDownloaderService* downloader_service =
CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get());
@@ -165,27 +166,27 @@ TEST_F(ManagedUserServiceTest, ShutDownCustodianProfileDownloader) {
}
#if !defined(OS_ANDROID)
-class ManagedUserServiceExtensionTestBase
+class SupervisedUserServiceExtensionTestBase
: public extensions::ExtensionServiceTestBase {
public:
- explicit ManagedUserServiceExtensionTestBase(bool is_managed)
- : is_managed_(is_managed),
+ explicit SupervisedUserServiceExtensionTestBase(bool is_supervised)
+ : is_supervised_(is_supervised),
channel_(chrome::VersionInfo::CHANNEL_DEV) {}
- virtual ~ManagedUserServiceExtensionTestBase() {}
+ virtual ~SupervisedUserServiceExtensionTestBase() {}
virtual void SetUp() OVERRIDE {
ExtensionServiceTestBase::SetUp();
ExtensionServiceTestBase::ExtensionServiceInitParams params =
CreateDefaultInitParams();
- params.profile_is_supervised = is_managed_;
+ params.profile_is_supervised = is_supervised_;
InitializeExtensionService(params);
- ManagedUserServiceFactory::GetForProfile(profile_.get())->Init();
+ SupervisedUserServiceFactory::GetForProfile(profile_.get())->Init();
}
protected:
- ScopedVector<ManagedModeSiteList> GetActiveSiteLists(
- ManagedUserService* managed_user_service) {
- return managed_user_service->GetActiveSiteLists();
+ ScopedVector<SupervisedUserSiteList> GetActiveSiteLists(
+ SupervisedUserService* supervised_user_service) {
+ return supervised_user_service->GetActiveSiteLists();
}
scoped_refptr<extensions::Extension> MakeThemeExtension() {
@@ -210,46 +211,47 @@ class ManagedUserServiceExtensionTestBase
return extension;
}
- bool is_managed_;
+ bool is_supervised_;
extensions::ScopedCurrentChannel channel_;
};
-class ManagedUserServiceExtensionTestUnmanaged
- : public ManagedUserServiceExtensionTestBase {
+class SupervisedUserServiceExtensionTestUnsupervised
+ : public SupervisedUserServiceExtensionTestBase {
public:
- ManagedUserServiceExtensionTestUnmanaged()
- : ManagedUserServiceExtensionTestBase(false) {}
+ SupervisedUserServiceExtensionTestUnsupervised()
+ : SupervisedUserServiceExtensionTestBase(false) {}
};
-class ManagedUserServiceExtensionTest
- : public ManagedUserServiceExtensionTestBase {
+class SupervisedUserServiceExtensionTest
+ : public SupervisedUserServiceExtensionTestBase {
public:
- ManagedUserServiceExtensionTest()
- : ManagedUserServiceExtensionTestBase(true) {}
+ SupervisedUserServiceExtensionTest()
+ : SupervisedUserServiceExtensionTestBase(true) {}
};
-TEST_F(ManagedUserServiceExtensionTestUnmanaged,
+TEST_F(SupervisedUserServiceExtensionTestUnsupervised,
ExtensionManagementPolicyProvider) {
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile_.get());
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile_.get());
EXPECT_FALSE(profile_->IsSupervised());
scoped_refptr<extensions::Extension> extension = MakeExtension();
base::string16 error_1;
- EXPECT_TRUE(managed_user_service->UserMayLoad(extension.get(), &error_1));
+ EXPECT_TRUE(supervised_user_service->UserMayLoad(extension.get(), &error_1));
EXPECT_EQ(base::string16(), error_1);
base::string16 error_2;
EXPECT_TRUE(
- managed_user_service->UserMayModifySettings(extension.get(), &error_2));
+ supervised_user_service->UserMayModifySettings(extension.get(),
+ &error_2));
EXPECT_EQ(base::string16(), error_2);
}
-TEST_F(ManagedUserServiceExtensionTest, ExtensionManagementPolicyProvider) {
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile_.get());
- ManagedModeURLFilterObserver observer(
- managed_user_service->GetURLFilterForUIThread());
+TEST_F(SupervisedUserServiceExtensionTest, ExtensionManagementPolicyProvider) {
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile_.get());
+ SupervisedUserURLFilterObserver observer(
+ supervised_user_service->GetURLFilterForUIThread());
ASSERT_TRUE(profile_->IsSupervised());
// Wait for the initial update to finish (otherwise we'll get leaks).
observer.Wait();
@@ -257,67 +259,68 @@ TEST_F(ManagedUserServiceExtensionTest, ExtensionManagementPolicyProvider) {
// Check that a supervised user can install a theme.
scoped_refptr<extensions::Extension> theme = MakeThemeExtension();
base::string16 error_1;
- EXPECT_TRUE(managed_user_service->UserMayLoad(theme.get(), &error_1));
+ EXPECT_TRUE(supervised_user_service->UserMayLoad(theme.get(), &error_1));
EXPECT_TRUE(error_1.empty());
EXPECT_TRUE(
- managed_user_service->UserMayModifySettings(theme.get(), &error_1));
+ supervised_user_service->UserMayModifySettings(theme.get(), &error_1));
EXPECT_TRUE(error_1.empty());
// Now check a different kind of extension.
scoped_refptr<extensions::Extension> extension = MakeExtension();
- EXPECT_FALSE(managed_user_service->UserMayLoad(extension.get(), &error_1));
+ EXPECT_FALSE(supervised_user_service->UserMayLoad(extension.get(), &error_1));
EXPECT_FALSE(error_1.empty());
base::string16 error_2;
EXPECT_FALSE(
- managed_user_service->UserMayModifySettings(extension.get(), &error_2));
+ supervised_user_service->UserMayModifySettings(extension.get(),
+ &error_2));
EXPECT_FALSE(error_2.empty());
#ifndef NDEBUG
- EXPECT_FALSE(managed_user_service->GetDebugPolicyProviderName().empty());
+ EXPECT_FALSE(supervised_user_service->GetDebugPolicyProviderName().empty());
#endif
}
-TEST_F(ManagedUserServiceExtensionTest, NoContentPacks) {
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile_.get());
- ManagedModeURLFilter* url_filter =
- managed_user_service->GetURLFilterForUIThread();
+TEST_F(SupervisedUserServiceExtensionTest, NoContentPacks) {
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile_.get());
+ SupervisedUserURLFilter* url_filter =
+ supervised_user_service->GetURLFilterForUIThread();
GURL url("http://youtube.com");
- ScopedVector<ManagedModeSiteList> site_lists =
- GetActiveSiteLists(managed_user_service);
+ ScopedVector<SupervisedUserSiteList> site_lists =
+ GetActiveSiteLists(supervised_user_service);
ASSERT_EQ(0u, site_lists.size());
- EXPECT_EQ(ManagedModeURLFilter::ALLOW,
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
url_filter->GetFilteringBehaviorForURL(url));
}
-TEST_F(ManagedUserServiceExtensionTest, InstallContentPacks) {
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile_.get());
- ManagedModeURLFilter* url_filter =
- managed_user_service->GetURLFilterForUIThread();
- ManagedModeURLFilterObserver observer(url_filter);
+TEST_F(SupervisedUserServiceExtensionTest, InstallContentPacks) {
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile_.get());
+ SupervisedUserURLFilter* url_filter =
+ supervised_user_service->GetURLFilterForUIThread();
+ SupervisedUserURLFilterObserver observer(url_filter);
observer.Wait();
GURL example_url("http://example.com");
GURL moose_url("http://moose.org");
- EXPECT_EQ(ManagedModeURLFilter::ALLOW,
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
url_filter->GetFilteringBehaviorForURL(example_url));
profile_->GetPrefs()->SetInteger(
prefs::kDefaultSupervisedUserFilteringBehavior,
- ManagedModeURLFilter::BLOCK);
- EXPECT_EQ(ManagedModeURLFilter::BLOCK,
+ SupervisedUserURLFilter::BLOCK);
+ EXPECT_EQ(SupervisedUserURLFilter::BLOCK,
url_filter->GetFilteringBehaviorForURL(example_url));
profile_->GetPrefs()->SetInteger(
prefs::kDefaultSupervisedUserFilteringBehavior,
- ManagedModeURLFilter::WARN);
- EXPECT_EQ(ManagedModeURLFilter::WARN,
+ SupervisedUserURLFilter::WARN);
+ EXPECT_EQ(SupervisedUserURLFilter::WARN,
url_filter->GetFilteringBehaviorForURL(example_url));
- managed_user_service->set_elevated_for_testing(true);
+ supervised_user_service->set_elevated_for_testing(true);
// Load a content pack.
scoped_refptr<extensions::UnpackedInstaller> installer(
@@ -339,19 +342,19 @@ TEST_F(ManagedUserServiceExtensionTest, InstallContentPacks) {
make_scoped_refptr(details.ptr());
ASSERT_TRUE(extension.get());
- ScopedVector<ManagedModeSiteList> site_lists =
- GetActiveSiteLists(managed_user_service);
+ ScopedVector<SupervisedUserSiteList> site_lists =
+ GetActiveSiteLists(supervised_user_service);
ASSERT_EQ(1u, site_lists.size());
- std::vector<ManagedModeSiteList::Site> sites;
+ std::vector<SupervisedUserSiteList::Site> sites;
site_lists[0]->GetSites(&sites);
ASSERT_EQ(3u, sites.size());
EXPECT_EQ(base::ASCIIToUTF16("YouTube"), sites[0].name);
EXPECT_EQ(base::ASCIIToUTF16("Homestar Runner"), sites[1].name);
EXPECT_EQ(base::string16(), sites[2].name);
- EXPECT_EQ(ManagedModeURLFilter::ALLOW,
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
url_filter->GetFilteringBehaviorForURL(example_url));
- EXPECT_EQ(ManagedModeURLFilter::WARN,
+ EXPECT_EQ(SupervisedUserURLFilter::WARN,
url_filter->GetFilteringBehaviorForURL(moose_url));
// Load a second content pack.
@@ -361,7 +364,7 @@ TEST_F(ManagedUserServiceExtensionTest, InstallContentPacks) {
installer->Load(extension_path);
observer.Wait();
- site_lists = GetActiveSiteLists(managed_user_service);
+ site_lists = GetActiveSiteLists(supervised_user_service);
ASSERT_EQ(2u, site_lists.size());
sites.clear();
site_lists[0]->GetSites(&sites);
@@ -369,7 +372,7 @@ TEST_F(ManagedUserServiceExtensionTest, InstallContentPacks) {
ASSERT_EQ(4u, sites.size());
// The site lists might be returned in any order, so we put them into a set.
std::set<std::string> site_names;
- for (std::vector<ManagedModeSiteList::Site>::const_iterator it =
+ for (std::vector<SupervisedUserSiteList::Site>::const_iterator it =
sites.begin(); it != sites.end(); ++it) {
site_names.insert(base::UTF16ToUTF8(it->name));
}
@@ -378,9 +381,9 @@ TEST_F(ManagedUserServiceExtensionTest, InstallContentPacks) {
EXPECT_TRUE(site_names.count(std::string()) == 1u);
EXPECT_TRUE(site_names.count("Moose") == 1u);
- EXPECT_EQ(ManagedModeURLFilter::ALLOW,
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
url_filter->GetFilteringBehaviorForURL(example_url));
- EXPECT_EQ(ManagedModeURLFilter::ALLOW,
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
url_filter->GetFilteringBehaviorForURL(moose_url));
// Disable the first content pack.
@@ -388,16 +391,16 @@ TEST_F(ManagedUserServiceExtensionTest, InstallContentPacks) {
extensions::Extension::DISABLE_USER_ACTION);
observer.Wait();
- site_lists = GetActiveSiteLists(managed_user_service);
+ site_lists = GetActiveSiteLists(supervised_user_service);
ASSERT_EQ(1u, site_lists.size());
sites.clear();
site_lists[0]->GetSites(&sites);
ASSERT_EQ(1u, sites.size());
EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name);
- EXPECT_EQ(ManagedModeURLFilter::WARN,
+ EXPECT_EQ(SupervisedUserURLFilter::WARN,
url_filter->GetFilteringBehaviorForURL(example_url));
- EXPECT_EQ(ManagedModeURLFilter::ALLOW,
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
url_filter->GetFilteringBehaviorForURL(moose_url));
}
#endif // !defined(OS_ANDROID)
diff --git a/chrome/browser/managed_mode/managed_user_settings_service.cc b/chrome/browser/supervised_user/supervised_user_settings_service.cc
index 4708aae..8bf0930 100644
--- a/chrome/browser/managed_mode/managed_user_settings_service.cc
+++ b/chrome/browser/supervised_user/supervised_user_settings_service.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
#include "base/callback.h"
#include "base/json/json_reader.h"
@@ -11,7 +11,7 @@
#include "base/prefs/pref_filter.h"
#include "base/strings/string_util.h"
#include "base/threading/sequenced_worker_pool.h"
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "chrome/common/chrome_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/user_metrics.h"
@@ -36,7 +36,7 @@ using syncer::SyncErrorFactory;
using syncer::SyncMergeResult;
const char kAtomicSettings[] = "atomic_settings";
-const char kManagedUserInternalItemPrefix[] = "X-";
+const char kSupervisedUserInternalItemPrefix[] = "X-";
const char kQueuedItems[] = "queued_items";
const char kSplitSettingKeySeparator = ':';
const char kSplitSettings[] = "split_settings";
@@ -44,17 +44,17 @@ const char kSplitSettings[] = "split_settings";
namespace {
bool SettingShouldApplyToPrefs(const std::string& name) {
- return !StartsWithASCII(name, kManagedUserInternalItemPrefix, false);
+ return !StartsWithASCII(name, kSupervisedUserInternalItemPrefix, false);
}
} // namespace
-ManagedUserSettingsService::ManagedUserSettingsService()
+SupervisedUserSettingsService::SupervisedUserSettingsService()
: active_(false), local_settings_(new base::DictionaryValue) {}
-ManagedUserSettingsService::~ManagedUserSettingsService() {}
+SupervisedUserSettingsService::~SupervisedUserSettingsService() {}
-void ManagedUserSettingsService::Init(
+void SupervisedUserSettingsService::Init(
base::FilePath profile_path,
base::SequencedTaskRunner* sequenced_task_runner,
bool load_synchronously) {
@@ -69,14 +69,15 @@ void ManagedUserSettingsService::Init(
store_->ReadPrefsAsync(NULL);
}
-void ManagedUserSettingsService::Init(
+void SupervisedUserSettingsService::Init(
scoped_refptr<PersistentPrefStore> store) {
DCHECK(!store_);
store_ = store;
store_->AddObserver(this);
}
-void ManagedUserSettingsService::Subscribe(const SettingsCallback& callback) {
+void SupervisedUserSettingsService::Subscribe(
+ const SettingsCallback& callback) {
if (IsReady()) {
scoped_ptr<base::DictionaryValue> settings = GetSettings();
callback.Run(settings.get());
@@ -85,29 +86,29 @@ void ManagedUserSettingsService::Subscribe(const SettingsCallback& callback) {
subscribers_.push_back(callback);
}
-void ManagedUserSettingsService::SetActive(bool active) {
+void SupervisedUserSettingsService::SetActive(bool active) {
active_ = active;
InformSubscribers();
}
-bool ManagedUserSettingsService::IsReady() {
+bool SupervisedUserSettingsService::IsReady() {
return store_->IsInitializationComplete();
}
-void ManagedUserSettingsService::Clear() {
+void SupervisedUserSettingsService::Clear() {
store_->RemoveValue(kAtomicSettings);
store_->RemoveValue(kSplitSettings);
}
// static
-std::string ManagedUserSettingsService::MakeSplitSettingKey(
+std::string SupervisedUserSettingsService::MakeSplitSettingKey(
const std::string& prefix,
const std::string& key) {
return prefix + kSplitSettingKeySeparator + key;
}
-void ManagedUserSettingsService::UploadItem(const std::string& key,
- scoped_ptr<base::Value> value) {
+void SupervisedUserSettingsService::UploadItem(const std::string& key,
+ scoped_ptr<base::Value> value) {
DCHECK(!SettingShouldApplyToPrefs(key));
std::string key_suffix = key;
@@ -134,7 +135,7 @@ void ManagedUserSettingsService::UploadItem(const std::string& key,
dict->SetWithoutPathExpansion(key_suffix, value.release());
}
-void ManagedUserSettingsService::SetLocalSettingForTesting(
+void SupervisedUserSettingsService::SetLocalSettingForTesting(
const std::string& key,
scoped_ptr<base::Value> value) {
if (value)
@@ -146,7 +147,7 @@ void ManagedUserSettingsService::SetLocalSettingForTesting(
}
// static
-SyncData ManagedUserSettingsService::CreateSyncDataForSetting(
+SyncData SupervisedUserSettingsService::CreateSyncDataForSetting(
const std::string& name,
const base::Value& value) {
std::string json_value;
@@ -157,11 +158,11 @@ SyncData ManagedUserSettingsService::CreateSyncDataForSetting(
return SyncData::CreateLocalData(name, name, specifics);
}
-void ManagedUserSettingsService::Shutdown() {
+void SupervisedUserSettingsService::Shutdown() {
store_->RemoveObserver(this);
}
-SyncMergeResult ManagedUserSettingsService::MergeDataAndStartSyncing(
+SyncMergeResult SupervisedUserSettingsService::MergeDataAndStartSyncing(
ModelType type,
const SyncDataList& initial_sync_data,
scoped_ptr<SyncChangeProcessor> sync_processor,
@@ -175,11 +176,11 @@ SyncMergeResult ManagedUserSettingsService::MergeDataAndStartSyncing(
for (SyncDataList::const_iterator it = initial_sync_data.begin();
it != initial_sync_data.end(); ++it) {
DCHECK_EQ(SUPERVISED_USER_SETTINGS, it->GetDataType());
- const ::sync_pb::ManagedUserSettingSpecifics& managed_user_setting =
+ const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting =
it->GetSpecifics().managed_user_setting();
scoped_ptr<base::Value> value(
- JSONReader::Read(managed_user_setting.value()));
- std::string name_suffix = managed_user_setting.name();
+ JSONReader::Read(supervised_user_setting.value()));
+ std::string name_suffix = supervised_user_setting.name();
base::DictionaryValue* dict = GetDictionaryAndSplitKey(&name_suffix);
dict->SetWithoutPathExpansion(name_suffix, value.release());
}
@@ -216,13 +217,13 @@ SyncMergeResult ManagedUserSettingsService::MergeDataAndStartSyncing(
return result;
}
-void ManagedUserSettingsService::StopSyncing(ModelType type) {
+void SupervisedUserSettingsService::StopSyncing(ModelType type) {
DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type);
sync_processor_.reset();
error_handler_.reset();
}
-SyncDataList ManagedUserSettingsService::GetAllSyncData(
+SyncDataList SupervisedUserSettingsService::GetAllSyncData(
ModelType type) const {
DCHECK_EQ(syncer::SUPERVISED_USER_SETTINGS, type);
SyncDataList data;
@@ -244,22 +245,22 @@ SyncDataList ManagedUserSettingsService::GetAllSyncData(
return data;
}
-SyncError ManagedUserSettingsService::ProcessSyncChanges(
+SyncError SupervisedUserSettingsService::ProcessSyncChanges(
const tracked_objects::Location& from_here,
const SyncChangeList& change_list) {
for (SyncChangeList::const_iterator it = change_list.begin();
it != change_list.end(); ++it) {
SyncData data = it->sync_data();
DCHECK_EQ(SUPERVISED_USER_SETTINGS, data.GetDataType());
- const ::sync_pb::ManagedUserSettingSpecifics& managed_user_setting =
+ const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting =
data.GetSpecifics().managed_user_setting();
- std::string key = managed_user_setting.name();
+ std::string key = supervised_user_setting.name();
base::DictionaryValue* dict = GetDictionaryAndSplitKey(&key);
switch (it->change_type()) {
case SyncChange::ACTION_ADD:
case SyncChange::ACTION_UPDATE: {
scoped_ptr<base::Value> value(
- JSONReader::Read(managed_user_setting.value()));
+ JSONReader::Read(supervised_user_setting.value()));
if (dict->HasKey(key)) {
DLOG_IF(WARNING, it->change_type() == SyncChange::ACTION_ADD)
<< "Value for key " << key << " already exists";
@@ -290,15 +291,16 @@ SyncError ManagedUserSettingsService::ProcessSyncChanges(
return error;
}
-void ManagedUserSettingsService::OnPrefValueChanged(const std::string& key) {}
+void SupervisedUserSettingsService::OnPrefValueChanged(const std::string& key) {
+}
-void ManagedUserSettingsService::OnInitializationCompleted(bool success) {
+void SupervisedUserSettingsService::OnInitializationCompleted(bool success) {
DCHECK(success);
DCHECK(IsReady());
InformSubscribers();
}
-base::DictionaryValue* ManagedUserSettingsService::GetOrCreateDictionary(
+base::DictionaryValue* SupervisedUserSettingsService::GetOrCreateDictionary(
const std::string& key) const {
base::Value* value = NULL;
base::DictionaryValue* dict = NULL;
@@ -313,19 +315,20 @@ base::DictionaryValue* ManagedUserSettingsService::GetOrCreateDictionary(
return dict;
}
-base::DictionaryValue* ManagedUserSettingsService::GetAtomicSettings() const {
+base::DictionaryValue*
+SupervisedUserSettingsService::GetAtomicSettings() const {
return GetOrCreateDictionary(kAtomicSettings);
}
-base::DictionaryValue* ManagedUserSettingsService::GetSplitSettings() const {
+base::DictionaryValue* SupervisedUserSettingsService::GetSplitSettings() const {
return GetOrCreateDictionary(kSplitSettings);
}
-base::DictionaryValue* ManagedUserSettingsService::GetQueuedItems() const {
+base::DictionaryValue* SupervisedUserSettingsService::GetQueuedItems() const {
return GetOrCreateDictionary(kQueuedItems);
}
-base::DictionaryValue* ManagedUserSettingsService::GetDictionaryAndSplitKey(
+base::DictionaryValue* SupervisedUserSettingsService::GetDictionaryAndSplitKey(
std::string* key) const {
size_t pos = key->find_first_of(kSplitSettingKeySeparator);
if (pos == std::string::npos)
@@ -343,7 +346,7 @@ base::DictionaryValue* ManagedUserSettingsService::GetDictionaryAndSplitKey(
return dict;
}
-scoped_ptr<base::DictionaryValue> ManagedUserSettingsService::GetSettings() {
+scoped_ptr<base::DictionaryValue> SupervisedUserSettingsService::GetSettings() {
DCHECK(IsReady());
if (!active_)
return scoped_ptr<base::DictionaryValue>();
@@ -371,7 +374,7 @@ scoped_ptr<base::DictionaryValue> ManagedUserSettingsService::GetSettings() {
return settings.Pass();
}
-void ManagedUserSettingsService::InformSubscribers() {
+void SupervisedUserSettingsService::InformSubscribers() {
if (!IsReady())
return;
diff --git a/chrome/browser/managed_mode/managed_user_settings_service.h b/chrome/browser/supervised_user/supervised_user_settings_service.h
index fdf789c..0d4b11b 100644
--- a/chrome/browser/managed_mode/managed_user_settings_service.h
+++ b/chrome/browser/supervised_user/supervised_user_settings_service.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_
#include <string>
#include <vector>
@@ -13,7 +13,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_store.h"
#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "components/keyed_service/core/keyed_service.h"
#include "sync/api/syncable_service.h"
@@ -25,7 +25,7 @@ class FilePath;
class SequencedTaskRunner;
}
-// This class syncs managed user settings from a server, which are mapped to
+// This class syncs supervised user settings from a server, which are mapped to
// preferences. The downloaded settings are persisted in a PrefStore (which is
// not directly hooked up to the PrefService; it's just used internally).
// Settings are key-value pairs, where the key uniquely identifies the setting.
@@ -49,17 +49,17 @@ class SequencedTaskRunner;
// }
// would be encoded as two sync items, one with key "Moose:foo" and value "bar",
// and one with key "Moose:baz" and value "blurp".
-class ManagedUserSettingsService : public KeyedService,
- public syncer::SyncableService,
- public PrefStore::Observer {
+class SupervisedUserSettingsService : public KeyedService,
+ public syncer::SyncableService,
+ public PrefStore::Observer {
public:
- // A callback whose first parameter is a dictionary containing all managed
+ // A callback whose first parameter is a dictionary containing all supervised
// user settings. If the dictionary is NULL, it means that the service is
- // inactive, i.e. the user is not managed.
+ // inactive, i.e. the user is not supervised.
typedef base::Callback<void(const base::DictionaryValue*)> SettingsCallback;
- ManagedUserSettingsService();
- virtual ~ManagedUserSettingsService();
+ SupervisedUserSettingsService();
+ virtual ~SupervisedUserSettingsService();
// Initializes the service by loading its settings from a file underneath the
// |profile_path|. File I/O will be serialized via the
@@ -74,28 +74,28 @@ class ManagedUserSettingsService : public KeyedService,
// default one.
void Init(scoped_refptr<PersistentPrefStore> pref_store);
- // Adds a callback to be called when managed user settings are initially
+ // Adds a callback to be called when supervised user settings are initially
// available, or when they change.
void Subscribe(const SettingsCallback& callback);
- // Activates/deactivates the service. This is called by the ManagedUserService
- // when it is (de)activated.
+ // Activates/deactivates the service. This is called by the
+ // SupervisedUserService when it is (de)activated.
void SetActive(bool active);
- // Whether managed user settings are available.
+ // Whether supervised user settings are available.
bool IsReady();
- // Clears all managed user settings and items.
+ // Clears all supervised user settings and items.
void Clear();
- // Constructs a key for a split managed user setting from a prefix and a
+ // Constructs a key for a split supervised user setting from a prefix and a
// variable key.
static std::string MakeSplitSettingKey(const std::string& prefix,
const std::string& key);
// Uploads an item to the Sync server. Items are the same data structure as
- // managed user settings (i.e. key-value pairs, as described at the top of
- // the file), but they are only uploaded (whereas managed user settings are
+ // supervised user settings (i.e. key-value pairs, as described at the top of
+ // the file), but they are only uploaded (whereas supervised user settings are
// only downloaded), and never passed to the preference system.
// An example of an uploaded item is an access request to a blocked URL.
void UploadItem(const std::string& key, scoped_ptr<base::Value> value);
@@ -135,12 +135,12 @@ class ManagedUserSettingsService : public KeyedService,
base::DictionaryValue* GetQueuedItems() const;
// Returns the dictionary where a given Sync item should be stored, depending
- // on whether the managed user setting is atomic or split. In case of a split
- // setting, the split setting prefix of |key| is removed, so that |key| can
- // be used to update the returned dictionary.
+ // on whether the supervised user setting is atomic or split. In case of a
+ // split setting, the split setting prefix of |key| is removed, so that |key|
+ // can be used to update the returned dictionary.
base::DictionaryValue* GetDictionaryAndSplitKey(std::string* key) const;
- // Returns a dictionary with all managed user settings if the service is
+ // Returns a dictionary with all supervised user settings if the service is
// active, or NULL otherwise.
scoped_ptr<base::DictionaryValue> GetSettings();
@@ -162,7 +162,7 @@ class ManagedUserSettingsService : public KeyedService,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
scoped_ptr<syncer::SyncErrorFactory> error_handler_;
- DISALLOW_COPY_AND_ASSIGN(ManagedUserSettingsService);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserSettingsService);
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_H_
diff --git a/chrome/browser/supervised_user/supervised_user_settings_service_factory.cc b/chrome/browser/supervised_user/supervised_user_settings_service_factory.cc
new file mode 100644
index 0000000..41ca720
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_settings_service_factory.cc
@@ -0,0 +1,43 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
+
+#include "chrome/browser/profiles/incognito_helpers.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+
+// static
+SupervisedUserSettingsService*
+SupervisedUserSettingsServiceFactory::GetForProfile(Profile* profile) {
+ return static_cast<SupervisedUserSettingsService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+// static
+SupervisedUserSettingsServiceFactory*
+SupervisedUserSettingsServiceFactory::GetInstance() {
+ return Singleton<SupervisedUserSettingsServiceFactory>::get();
+}
+
+SupervisedUserSettingsServiceFactory::SupervisedUserSettingsServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "SupervisedUserSettingsService",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+SupervisedUserSettingsServiceFactory::
+ ~SupervisedUserSettingsServiceFactory() {}
+
+KeyedService* SupervisedUserSettingsServiceFactory::BuildServiceInstanceFor(
+ content::BrowserContext* profile) const {
+ return new SupervisedUserSettingsService();
+}
+
+content::BrowserContext*
+SupervisedUserSettingsServiceFactory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return chrome::GetBrowserContextRedirectedInIncognito(context);
+}
diff --git a/chrome/browser/supervised_user/supervised_user_settings_service_factory.h b/chrome/browser/supervised_user/supervised_user_settings_service_factory.h
new file mode 100644
index 0000000..fd0316e
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_settings_service_factory.h
@@ -0,0 +1,35 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_FACTORY_H_
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+
+class Profile;
+class SupervisedUserSettingsService;
+
+class SupervisedUserSettingsServiceFactory
+ : public BrowserContextKeyedServiceFactory {
+ public:
+ static SupervisedUserSettingsService* GetForProfile(Profile* profile);
+
+ static SupervisedUserSettingsServiceFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<SupervisedUserSettingsServiceFactory>;
+
+ SupervisedUserSettingsServiceFactory();
+ virtual ~SupervisedUserSettingsServiceFactory();
+
+ // BrowserContextKeyedServiceFactory:
+ virtual KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const OVERRIDE;
+ virtual content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const OVERRIDE;
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SETTINGS_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/managed_user_settings_service_unittest.cc b/chrome/browser/supervised_user/supervised_user_settings_service_unittest.cc
index 70dbc2b..6ff1e4f 100644
--- a/chrome/browser/managed_mode/managed_user_settings_service_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_settings_service_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,7 +7,7 @@
#include "base/json/json_reader.h"
#include "base/prefs/testing_pref_store.h"
#include "base/strings/string_util.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
#include "sync/api/fake_sync_change_processor.h"
#include "sync/api/sync_change.h"
#include "sync/api/sync_change_processor_wrapper_for_test.h"
@@ -54,10 +54,10 @@ const char kSettingsName[] = "TestingSetting";
const char kSettingsValue[] = "SettingsValue";
const char kSplitItemName[] = "X-SuperMoosePowers";
-class ManagedUserSettingsServiceTest : public ::testing::Test {
+class SupervisedUserSettingsServiceTest : public ::testing::Test {
protected:
- ManagedUserSettingsServiceTest() {}
- virtual ~ManagedUserSettingsServiceTest() {}
+ SupervisedUserSettingsServiceTest() {}
+ virtual ~SupervisedUserSettingsServiceTest() {}
scoped_ptr<syncer::SyncChangeProcessor> CreateSyncProcessor() {
sync_processor_.reset(new syncer::FakeSyncChangeProcessor);
@@ -79,8 +79,8 @@ class ManagedUserSettingsServiceTest : public ::testing::Test {
void UploadSplitItem(const std::string& key, const std::string& value) {
split_items_.SetStringWithoutPathExpansion(key, value);
settings_service_.UploadItem(
- ManagedUserSettingsService::MakeSplitSettingKey(kSplitItemName,
- key),
+ SupervisedUserSettingsService::MakeSplitSettingKey(kSplitItemName,
+ key),
scoped_ptr<base::Value>(new base::StringValue(value)));
}
@@ -92,22 +92,22 @@ class ManagedUserSettingsServiceTest : public ::testing::Test {
}
void VerifySyncDataItem(syncer::SyncData sync_data) {
- const sync_pb::ManagedUserSettingSpecifics& managed_user_setting =
+ const sync_pb::ManagedUserSettingSpecifics& supervised_user_setting =
sync_data.GetSpecifics().managed_user_setting();
base::Value* expected_value = NULL;
- if (managed_user_setting.name() == kAtomicItemName) {
+ if (supervised_user_setting.name() == kAtomicItemName) {
expected_value = atomic_setting_value_.get();
} else {
- EXPECT_TRUE(StartsWithASCII(managed_user_setting.name(),
+ EXPECT_TRUE(StartsWithASCII(supervised_user_setting.name(),
std::string(kSplitItemName) + ':',
true));
std::string key =
- managed_user_setting.name().substr(strlen(kSplitItemName) + 1);
+ supervised_user_setting.name().substr(strlen(kSplitItemName) + 1);
EXPECT_TRUE(split_items_.GetWithoutPathExpansion(key, &expected_value));
}
scoped_ptr<base::Value> value(
- base::JSONReader::Read(managed_user_setting.value()));
+ base::JSONReader::Read(supervised_user_setting.value()));
EXPECT_TRUE(expected_value->Equals(value.get()));
}
@@ -123,7 +123,7 @@ class ManagedUserSettingsServiceTest : public ::testing::Test {
TestingPrefStore* pref_store = new TestingPrefStore;
settings_service_.Init(pref_store);
settings_service_.Subscribe(
- base::Bind(&ManagedUserSettingsServiceTest::OnNewSettingsAvailable,
+ base::Bind(&SupervisedUserSettingsServiceTest::OnNewSettingsAvailable,
base::Unretained(this)));
pref_store->SetInitializationCompleted();
ASSERT_FALSE(settings_);
@@ -137,13 +137,13 @@ class ManagedUserSettingsServiceTest : public ::testing::Test {
base::DictionaryValue split_items_;
scoped_ptr<base::Value> atomic_setting_value_;
- ManagedUserSettingsService settings_service_;
+ SupervisedUserSettingsService settings_service_;
scoped_ptr<base::DictionaryValue> settings_;
scoped_ptr<syncer::FakeSyncChangeProcessor> sync_processor_;
};
-TEST_F(ManagedUserSettingsServiceTest, ProcessAtomicSetting) {
+TEST_F(SupervisedUserSettingsServiceTest, ProcessAtomicSetting) {
StartSyncing(syncer::SyncDataList());
ASSERT_TRUE(settings_);
const base::Value* value = NULL;
@@ -151,7 +151,7 @@ TEST_F(ManagedUserSettingsServiceTest, ProcessAtomicSetting) {
settings_.reset();
syncer::SyncData data =
- ManagedUserSettingsService::CreateSyncDataForSetting(
+ SupervisedUserSettingsService::CreateSyncDataForSetting(
kSettingsName, base::StringValue(kSettingsValue));
syncer::SyncChangeList change_list;
change_list.push_back(
@@ -166,7 +166,7 @@ TEST_F(ManagedUserSettingsServiceTest, ProcessAtomicSetting) {
EXPECT_EQ(kSettingsValue, string_value);
}
-TEST_F(ManagedUserSettingsServiceTest, ProcessSplitSetting) {
+TEST_F(SupervisedUserSettingsServiceTest, ProcessSplitSetting) {
StartSyncing(syncer::SyncDataList());
ASSERT_TRUE(settings_);
const base::Value* value = NULL;
@@ -181,9 +181,9 @@ TEST_F(ManagedUserSettingsServiceTest, ProcessSplitSetting) {
syncer::SyncChangeList change_list;
for (base::DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) {
syncer::SyncData data =
- ManagedUserSettingsService::CreateSyncDataForSetting(
- ManagedUserSettingsService::MakeSplitSettingKey(kSettingsName,
- it.key()),
+ SupervisedUserSettingsService::CreateSyncDataForSetting(
+ SupervisedUserSettingsService::MakeSplitSettingKey(kSettingsName,
+ it.key()),
it.value());
change_list.push_back(
syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_ADD, data));
@@ -198,7 +198,7 @@ TEST_F(ManagedUserSettingsServiceTest, ProcessSplitSetting) {
EXPECT_TRUE(dict_value->Equals(&dict));
}
-TEST_F(ManagedUserSettingsServiceTest, SetLocalSetting) {
+TEST_F(SupervisedUserSettingsServiceTest, SetLocalSetting) {
const base::Value* value = NULL;
EXPECT_FALSE(settings_->GetWithoutPathExpansion(kSettingsName, &value));
@@ -213,7 +213,7 @@ TEST_F(ManagedUserSettingsServiceTest, SetLocalSetting) {
EXPECT_EQ(kSettingsValue, string_value);
}
-TEST_F(ManagedUserSettingsServiceTest, UploadItem) {
+TEST_F(SupervisedUserSettingsServiceTest, UploadItem) {
UploadSplitItem("foo", "bar");
UploadSplitItem("blurp", "baz");
UploadAtomicItem("hurdle");
diff --git a/chrome/browser/managed_mode/managed_user_shared_settings_service.cc b/chrome/browser/supervised_user/supervised_user_shared_settings_service.cc
index 74c0b77..042654a 100644
--- a/chrome/browser/managed_mode/managed_user_shared_settings_service.cc
+++ b/chrome/browser/supervised_user/supervised_user_shared_settings_service.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
@@ -46,29 +46,29 @@ DictionaryValue* FindOrCreateDictionary(DictionaryValue* parent,
return dict;
}
-class ScopedManagedUserSharedSettingsUpdate {
+class ScopedSupervisedUserSharedSettingsUpdate {
public:
- ScopedManagedUserSharedSettingsUpdate(PrefService* prefs,
- const std::string& mu_id)
- : update_(prefs, prefs::kSupervisedUserSharedSettings), mu_id_(mu_id) {
- DCHECK(!mu_id.empty());
+ ScopedSupervisedUserSharedSettingsUpdate(PrefService* prefs,
+ const std::string& su_id)
+ : update_(prefs, prefs::kSupervisedUserSharedSettings), su_id_(su_id) {
+ DCHECK(!su_id.empty());
// A supervised user can only modify their own settings.
std::string id = prefs->GetString(prefs::kSupervisedUserId);
- DCHECK(id.empty() || id == mu_id);
+ DCHECK(id.empty() || id == su_id);
}
DictionaryValue* Get() {
- return FindOrCreateDictionary(update_.Get(), mu_id_);
+ return FindOrCreateDictionary(update_.Get(), su_id_);
}
private:
DictionaryPrefUpdate update_;
- std::string mu_id_;
+ std::string su_id_;
};
SyncData CreateSyncDataForValue(
- const std::string& mu_id,
+ const std::string& su_id,
const std::string& key,
const Value& dict_value) {
const DictionaryValue* dict = NULL;
@@ -82,25 +82,25 @@ SyncData CreateSyncDataForValue(
bool acknowledged = false;
dict->GetBoolean(kAcknowledged, &acknowledged);
- return ManagedUserSharedSettingsService::CreateSyncDataForSetting(
- mu_id, key, *value, acknowledged);
+ return SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
+ su_id, key, *value, acknowledged);
}
} // namespace
-ManagedUserSharedSettingsService::ManagedUserSharedSettingsService(
+SupervisedUserSharedSettingsService::SupervisedUserSharedSettingsService(
PrefService* prefs)
: prefs_(prefs) {}
-ManagedUserSharedSettingsService::~ManagedUserSharedSettingsService() {}
+SupervisedUserSharedSettingsService::~SupervisedUserSharedSettingsService() {}
-void ManagedUserSharedSettingsService::SetValueInternal(
- const std::string& mu_id,
+void SupervisedUserSharedSettingsService::SetValueInternal(
+ const std::string& su_id,
const std::string& key,
const Value& value,
bool acknowledged) {
- ScopedManagedUserSharedSettingsUpdate update(prefs_, mu_id);
+ ScopedSupervisedUserSharedSettingsUpdate update(prefs_, su_id);
DictionaryValue* update_dict = update.Get();
DictionaryValue* dict = NULL;
@@ -115,7 +115,7 @@ void ManagedUserSharedSettingsService::SetValueInternal(
if (!sync_processor_)
return;
- SyncData data = CreateSyncDataForSetting(mu_id, key, value, acknowledged);
+ SyncData data = CreateSyncDataForSetting(su_id, key, value, acknowledged);
SyncChange::SyncChangeType change_type =
has_key ? SyncChange::ACTION_UPDATE : SyncChange::ACTION_ADD;
SyncChangeList changes;
@@ -124,13 +124,13 @@ void ManagedUserSharedSettingsService::SetValueInternal(
DCHECK(!error.IsSet()) << error.ToString();
}
-const Value* ManagedUserSharedSettingsService::GetValue(
- const std::string& mu_id,
+const Value* SupervisedUserSharedSettingsService::GetValue(
+ const std::string& su_id,
const std::string& key) {
const DictionaryValue* data =
prefs_->GetDictionary(prefs::kSupervisedUserSharedSettings);
const DictionaryValue* dict = NULL;
- if (!data->GetDictionaryWithoutPathExpansion(mu_id, &dict))
+ if (!data->GetDictionaryWithoutPathExpansion(su_id, &dict))
return NULL;
const DictionaryValue* settings = NULL;
@@ -144,21 +144,22 @@ const Value* ManagedUserSharedSettingsService::GetValue(
return value;
}
-void ManagedUserSharedSettingsService::SetValue(
- const std::string& mu_id,
+void SupervisedUserSharedSettingsService::SetValue(
+ const std::string& su_id,
const std::string& key,
const Value& value) {
- SetValueInternal(mu_id, key, value, true);
+ SetValueInternal(su_id, key, value, true);
}
-scoped_ptr<ManagedUserSharedSettingsService::ChangeCallbackList::Subscription>
-ManagedUserSharedSettingsService::Subscribe(
- const ManagedUserSharedSettingsService::ChangeCallback& cb) {
+scoped_ptr<
+ SupervisedUserSharedSettingsService::ChangeCallbackList::Subscription>
+SupervisedUserSharedSettingsService::Subscribe(
+ const SupervisedUserSharedSettingsService::ChangeCallback& cb) {
return callbacks_.Add(cb);
}
// static
-void ManagedUserSharedSettingsService::RegisterProfilePrefs(
+void SupervisedUserSharedSettingsService::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(
prefs::kSupervisedUserSharedSettings,
@@ -166,27 +167,27 @@ void ManagedUserSharedSettingsService::RegisterProfilePrefs(
}
// static
-SyncData ManagedUserSharedSettingsService::CreateSyncDataForSetting(
- const std::string& mu_id,
+SyncData SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
+ const std::string& su_id,
const std::string& key,
const Value& value,
bool acknowledged) {
std::string json_value;
base::JSONWriter::Write(&value, &json_value);
::sync_pb::EntitySpecifics specifics;
- specifics.mutable_managed_user_shared_setting()->set_mu_id(mu_id);
+ specifics.mutable_managed_user_shared_setting()->set_mu_id(su_id);
specifics.mutable_managed_user_shared_setting()->set_key(key);
specifics.mutable_managed_user_shared_setting()->set_value(json_value);
specifics.mutable_managed_user_shared_setting()->set_acknowledged(
acknowledged);
- std::string title = mu_id + ":" + key;
+ std::string title = su_id + ":" + key;
return SyncData::CreateLocalData(title, title, specifics);
}
-void ManagedUserSharedSettingsService::Shutdown() {}
+void SupervisedUserSharedSettingsService::Shutdown() {}
syncer::SyncMergeResult
-ManagedUserSharedSettingsService::MergeDataAndStartSyncing(
+SupervisedUserSharedSettingsService::MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
@@ -206,24 +207,24 @@ ManagedUserSharedSettingsService::MergeDataAndStartSyncing(
++it) {
DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, it->GetDataType());
const ::sync_pb::ManagedUserSharedSettingSpecifics&
- managed_user_shared_setting =
+ supervised_user_shared_setting =
it->GetSpecifics().managed_user_shared_setting();
scoped_ptr<Value> value(
- base::JSONReader::Read(managed_user_shared_setting.value()));
- const std::string& mu_id = managed_user_shared_setting.mu_id();
- ScopedManagedUserSharedSettingsUpdate update(prefs_, mu_id);
- const std::string& key = managed_user_shared_setting.key();
+ base::JSONReader::Read(supervised_user_shared_setting.value()));
+ const std::string& su_id = supervised_user_shared_setting.mu_id();
+ ScopedSupervisedUserSharedSettingsUpdate update(prefs_, su_id);
+ const std::string& key = supervised_user_shared_setting.key();
DictionaryValue* dict = FindOrCreateDictionary(update.Get(), key);
dict->SetWithoutPathExpansion(kValue, value.release());
// Every setting we get from the server should have the acknowledged flag
// set.
- DCHECK(managed_user_shared_setting.acknowledged());
+ DCHECK(supervised_user_shared_setting.acknowledged());
dict->SetBooleanWithoutPathExpansion(
- kAcknowledged, managed_user_shared_setting.acknowledged());
- callbacks_.Notify(mu_id, key);
+ kAcknowledged, supervised_user_shared_setting.acknowledged());
+ callbacks_.Notify(su_id, key);
- seen_keys[mu_id].insert(key);
+ seen_keys[su_id].insert(key);
}
// Iterate over all settings that we have locally, which includes settings
@@ -262,13 +263,13 @@ ManagedUserSharedSettingsService::MergeDataAndStartSyncing(
return result;
}
-void ManagedUserSharedSettingsService::StopSyncing(syncer::ModelType type) {
+void SupervisedUserSharedSettingsService::StopSyncing(syncer::ModelType type) {
DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, type);
sync_processor_.reset();
error_handler_.reset();
}
-syncer::SyncDataList ManagedUserSharedSettingsService::GetAllSyncData(
+syncer::SyncDataList SupervisedUserSharedSettingsService::GetAllSyncData(
syncer::ModelType type) const {
DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, type);
SyncDataList data;
@@ -286,7 +287,7 @@ syncer::SyncDataList ManagedUserSharedSettingsService::GetAllSyncData(
return data;
}
-syncer::SyncError ManagedUserSharedSettingsService::ProcessSyncChanges(
+syncer::SyncError SupervisedUserSharedSettingsService::ProcessSyncChanges(
const tracked_objects::Location& from_here,
const syncer::SyncChangeList& change_list) {
for (SyncChangeList::const_iterator it = change_list.begin();
@@ -295,11 +296,11 @@ syncer::SyncError ManagedUserSharedSettingsService::ProcessSyncChanges(
SyncData data = it->sync_data();
DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, data.GetDataType());
const ::sync_pb::ManagedUserSharedSettingSpecifics&
- managed_user_shared_setting =
+ supervised_user_shared_setting =
data.GetSpecifics().managed_user_shared_setting();
- const std::string& key = managed_user_shared_setting.key();
- const std::string& mu_id = managed_user_shared_setting.mu_id();
- ScopedManagedUserSharedSettingsUpdate update(prefs_, mu_id);
+ const std::string& key = supervised_user_shared_setting.key();
+ const std::string& su_id = supervised_user_shared_setting.mu_id();
+ ScopedSupervisedUserSharedSettingsUpdate update(prefs_, su_id);
DictionaryValue* update_dict = update.Get();
DictionaryValue* dict = NULL;
bool has_key = update_dict->GetDictionaryWithoutPathExpansion(key, &dict);
@@ -308,10 +309,11 @@ syncer::SyncError ManagedUserSharedSettingsService::ProcessSyncChanges(
case SyncChange::ACTION_UPDATE: {
// Every setting we get from the server should have the acknowledged
// flag set.
- DCHECK(managed_user_shared_setting.acknowledged());
+ DCHECK(supervised_user_shared_setting.acknowledged());
if (has_key) {
- // If the managed user already exists, it should be an update action.
+ // If the supervised user already exists, it should be an update
+ // action.
DCHECK_EQ(SyncChange::ACTION_UPDATE, it->change_type());
} else {
// Otherwise, it should be an add action.
@@ -320,10 +322,10 @@ syncer::SyncError ManagedUserSharedSettingsService::ProcessSyncChanges(
update_dict->SetWithoutPathExpansion(key, dict);
}
scoped_ptr<Value> value(
- base::JSONReader::Read(managed_user_shared_setting.value()));
+ base::JSONReader::Read(supervised_user_shared_setting.value()));
dict->SetWithoutPathExpansion(kValue, value.release());
dict->SetBooleanWithoutPathExpansion(
- kAcknowledged, managed_user_shared_setting.acknowledged());
+ kAcknowledged, supervised_user_shared_setting.acknowledged());
break;
}
case SyncChange::ACTION_DELETE: {
@@ -338,7 +340,7 @@ syncer::SyncError ManagedUserSharedSettingsService::ProcessSyncChanges(
break;
}
}
- callbacks_.Notify(mu_id, key);
+ callbacks_.Notify(su_id, key);
}
SyncError error;
diff --git a/chrome/browser/managed_mode/managed_user_shared_settings_service.h b/chrome/browser/supervised_user/supervised_user_shared_settings_service.h
index dcae009..4a54f78 100644
--- a/chrome/browser/managed_mode/managed_user_shared_settings_service.h
+++ b/chrome/browser/supervised_user/supervised_user_shared_settings_service.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_SERVICE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_SERVICE_H_
#include "base/callback.h"
#include "base/callback_list.h"
#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "components/keyed_service/core/keyed_service.h"
#include "sync/api/syncable_service.h"
@@ -23,64 +23,65 @@ namespace user_prefs {
class PrefRegistrySyncable;
}
-// ManagedUserSharedSettingsService syncs settings (as key-value pairs) that can
-// be modified both by a supervised user and their manager.
+// SupervisedUserSharedSettingsService syncs settings (as key-value pairs) that
+// can be modified both by a supervised user and their manager.
// A supervised user can only modify their own settings, whereas a manager can
// modify settings for all their supervised users.
//
// The shared settings are stored in the user preferences in a multi-level
-// dictionary. The first level is the MU ID, the second level is the key for the
-// setting, and the third level is a dictionary with a "value" key for the value
-// and an "acknowledged" flag, which is used to wait for the Sync server to
-// acknowledge that it has seen a setting change (see
-// ManagedUserSharedSettingsUpdate for how to use this).
-class ManagedUserSharedSettingsService : public KeyedService,
- public syncer::SyncableService {
+// dictionary. The first level is the SU ID (called "managed user ID" on the
+// server for historic reasons), the second level is the key for the setting,
+// and the third level is a dictionary with a "value" key for the value and an
+// "acknowledged" flag, which is used to wait for the Sync server to acknowledge
+// that it has seen a setting change (see SupervisedUserSharedSettingsUpdate for
+// how to use this).
+class SupervisedUserSharedSettingsService : public KeyedService,
+ public syncer::SyncableService {
public:
// Called whenever a setting changes (see Subscribe() below).
- typedef base::Callback<void(const std::string& /* mu_id */,
+ typedef base::Callback<void(const std::string& /* su_id */,
const std::string& /* key */)> ChangeCallback;
typedef base::CallbackList<
- void(const std::string& /* mu_id */, const std::string& /* key */)>
+ void(const std::string& /* su_id */, const std::string& /* key */)>
ChangeCallbackList;
// This constructor is public only for testing. Use
- // |ManagedUserSyncServiceFactory::GetForProfile(...)| instead to get an
- // instance of this service in production code.
- explicit ManagedUserSharedSettingsService(PrefService* prefs);
- virtual ~ManagedUserSharedSettingsService();
+ // |SupervisedUserSharedSettingsServiceFactory::GetForProfile(...)| instead to
+ // get an instance of this service in production code.
+ explicit SupervisedUserSharedSettingsService(PrefService* prefs);
+ virtual ~SupervisedUserSharedSettingsService();
// Returns the value for the given |key| and the supervised user identified by
- // |mu_id|. If either the supervised user or the key does not exist, NULL is
+ // |su_id|. If either the supervised user or the key does not exist, NULL is
// returned. Note that if the profile that owns this service belongs to a
- // supervised user, callers will only see settings for their own |mu_id|, i.e.
- // a non-matching |mu_id| is treated as non-existent.
- const base::Value* GetValue(const std::string& mu_id, const std::string& key);
+ // supervised user, callers will only see settings for their own |su_id|, i.e.
+ // a non-matching |su_id| is treated as non-existent.
+ const base::Value* GetValue(const std::string& su_id, const std::string& key);
// Sets the value for the given |key| and the supervised user identified by
- // |mu_id|. If the profile that owns this service belongs to a supervised
- // user, |mu_id| must be their own.
- void SetValue(const std::string& mu_id,
+ // |su_id|. If the profile that owns this service belongs to a supervised
+ // user, |su_id| must be their own.
+ void SetValue(const std::string& su_id,
const std::string& key,
const base::Value& value);
// Subscribes to changes in the synced settings. The callback will be notified
// whenever any setting for any supervised user is changed via Sync (but not
// for local changes). Subscribers should filter the settings and users they
- // are interested in with the |mu_id| and |key| parameters to the callback.
+ // are interested in with the |su_id| and |key| parameters to the callback.
scoped_ptr<ChangeCallbackList::Subscription> Subscribe(
const ChangeCallback& cb);
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
// Public for testing.
- void SetValueInternal(const std::string& mu_id,
+ void SetValueInternal(const std::string& su_id,
const std::string& key,
const base::Value& value,
bool acknowledged);
// Public for testing.
- static syncer::SyncData CreateSyncDataForSetting(const std::string& mu_id,
+ static syncer::SyncData CreateSyncDataForSetting(const std::string& su_id,
const std::string& key,
const base::Value& value,
bool acknowledged);
@@ -102,8 +103,6 @@ class ManagedUserSharedSettingsService : public KeyedService,
const syncer::SyncChangeList& change_list) OVERRIDE;
private:
- friend class ManagedUserSharedSettingsUpdate;
-
scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
scoped_ptr<syncer::SyncErrorFactory> error_handler_;
@@ -112,4 +111,4 @@ class ManagedUserSharedSettingsService : public KeyedService,
PrefService* prefs_;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_SERVICE_H_
diff --git a/chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.cc b/chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.cc
new file mode 100644
index 0000000..317cc3d
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.cc
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "components/user_prefs/user_prefs.h"
+#include "content/public/browser/browser_context.h"
+
+// static
+SupervisedUserSharedSettingsService*
+SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ content::BrowserContext* profile) {
+ return static_cast<SupervisedUserSharedSettingsService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+// static
+SupervisedUserSharedSettingsServiceFactory*
+SupervisedUserSharedSettingsServiceFactory::GetInstance() {
+ return Singleton<SupervisedUserSharedSettingsServiceFactory>::get();
+}
+
+SupervisedUserSharedSettingsServiceFactory::
+ SupervisedUserSharedSettingsServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "SupervisedUserSharedSettingsService",
+ BrowserContextDependencyManager::GetInstance()) {}
+
+SupervisedUserSharedSettingsServiceFactory::
+ ~SupervisedUserSharedSettingsServiceFactory() {}
+
+KeyedService*
+SupervisedUserSharedSettingsServiceFactory::BuildServiceInstanceFor(
+ content::BrowserContext* profile) const {
+ return new SupervisedUserSharedSettingsService(
+ user_prefs::UserPrefs::Get(profile));
+}
diff --git a/chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h b/chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h
new file mode 100644
index 0000000..a5f9d08
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h
@@ -0,0 +1,34 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_SERVICE_FACTORY_H_
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+
+class SupervisedUserSharedSettingsService;
+
+class SupervisedUserSharedSettingsServiceFactory
+ : public BrowserContextKeyedServiceFactory {
+ public:
+ static SupervisedUserSharedSettingsService* GetForBrowserContext(
+ content::BrowserContext* profile);
+
+ static SupervisedUserSharedSettingsServiceFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<
+ SupervisedUserSharedSettingsServiceFactory>;
+
+ SupervisedUserSharedSettingsServiceFactory();
+ virtual ~SupervisedUserSharedSettingsServiceFactory();
+
+ // BrowserContextKeyedServiceFactory:
+ virtual KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const OVERRIDE;
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_SERVICE_FACTORY_H_
diff --git a/chrome/browser/managed_mode/managed_user_shared_settings_service_unittest.cc b/chrome/browser/supervised_user/supervised_user_shared_settings_service_unittest.cc
index 20df39e..cee7969 100644
--- a/chrome/browser/managed_mode/managed_user_shared_settings_service_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_shared_settings_service_unittest.cc
@@ -5,7 +5,7 @@
#include "base/bind.h"
#include "base/json/json_writer.h"
#include "base/prefs/pref_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "sync/api/fake_sync_change_processor.h"
@@ -72,14 +72,14 @@ std::string ToJson(const Value* value) {
} // namespace
-class ManagedUserSharedSettingsServiceTest : public ::testing::Test {
+class SupervisedUserSharedSettingsServiceTest : public ::testing::Test {
protected:
typedef base::CallbackList<void(const std::string&, const std::string&)>
CallbackList;
- ManagedUserSharedSettingsServiceTest()
+ SupervisedUserSharedSettingsServiceTest()
: settings_service_(profile_.GetPrefs()) {}
- virtual ~ManagedUserSharedSettingsServiceTest() {}
+ virtual ~SupervisedUserSharedSettingsServiceTest() {}
void StartSyncing(const syncer::SyncDataList& initial_sync_data) {
sync_processor_.reset(new syncer::FakeSyncChangeProcessor);
@@ -116,22 +116,22 @@ class ManagedUserSharedSettingsServiceTest : public ::testing::Test {
// testing::Test overrides:
virtual void SetUp() OVERRIDE {
subscription_ = settings_service_.Subscribe(
- base::Bind(&ManagedUserSharedSettingsServiceTest::OnSettingChanged,
+ base::Bind(&SupervisedUserSharedSettingsServiceTest::OnSettingChanged,
base::Unretained(this)));
}
virtual void TearDown() OVERRIDE { settings_service_.Shutdown(); }
- void OnSettingChanged(const std::string& mu_id, const std::string& key) {
- const Value* value = settings_service_.GetValue(mu_id, key);
+ void OnSettingChanged(const std::string& su_id, const std::string& key) {
+ const Value* value = settings_service_.GetValue(su_id, key);
ASSERT_TRUE(value);
changed_settings_.push_back(
- ManagedUserSharedSettingsService::CreateSyncDataForSetting(
- mu_id, key, *value, true));
+ SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
+ su_id, key, *value, true));
}
TestingProfile profile_;
- ManagedUserSharedSettingsService settings_service_;
+ SupervisedUserSharedSettingsService settings_service_;
SyncDataList changed_settings_;
scoped_ptr<CallbackList::Subscription> subscription_;
@@ -139,7 +139,7 @@ class ManagedUserSharedSettingsServiceTest : public ::testing::Test {
scoped_ptr<syncer::FakeSyncChangeProcessor> sync_processor_;
};
-TEST_F(ManagedUserSharedSettingsServiceTest, Empty) {
+TEST_F(SupervisedUserSharedSettingsServiceTest, Empty) {
StartSyncing(SyncDataList());
EXPECT_EQ(0u, sync_processor_->changes().size());
EXPECT_EQ(0u, changed_settings_.size());
@@ -149,7 +149,7 @@ TEST_F(ManagedUserSharedSettingsServiceTest, Empty) {
EXPECT_EQ(0u, GetAllSettings()->size());
}
-TEST_F(ManagedUserSharedSettingsServiceTest, SetAndGet) {
+TEST_F(SupervisedUserSharedSettingsServiceTest, SetAndGet) {
StartSyncing(SyncDataList());
const char kIdA[] = "aaaaaa";
@@ -184,7 +184,7 @@ TEST_F(ManagedUserSharedSettingsServiceTest, SetAndGet) {
EXPECT_FALSE(settings_service_.GetValue(kIdC, "name"));
}
-TEST_F(ManagedUserSharedSettingsServiceTest, Merge) {
+TEST_F(SupervisedUserSharedSettingsServiceTest, Merge) {
// Set initial values, then stop syncing so we can restart.
StartSyncing(SyncDataList());
@@ -204,10 +204,10 @@ TEST_F(ManagedUserSharedSettingsServiceTest, Merge) {
StringValue blurp("blurp");
SyncDataList sync_data;
sync_data.push_back(
- ManagedUserSharedSettingsService::CreateSyncDataForSetting(
+ SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
kIdA, "name", name, true));
sync_data.push_back(
- ManagedUserSharedSettingsService::CreateSyncDataForSetting(
+ SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
kIdC, "baz", blurp, true));
StartSyncing(sync_data);
@@ -228,7 +228,7 @@ TEST_F(ManagedUserSharedSettingsServiceTest, Merge) {
EXPECT_FALSE(settings_service_.GetValue(kIdC, "name"));
}
-TEST_F(ManagedUserSharedSettingsServiceTest, ProcessChanges) {
+TEST_F(SupervisedUserSharedSettingsServiceTest, ProcessChanges) {
StartSyncing(SyncDataList());
const char kIdA[] = "aaaaaa";
@@ -247,12 +247,12 @@ TEST_F(ManagedUserSharedSettingsServiceTest, ProcessChanges) {
changes.push_back(
SyncChange(FROM_HERE,
SyncChange::ACTION_UPDATE,
- ManagedUserSharedSettingsService::CreateSyncDataForSetting(
+ SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
kIdA, "name", name, true)));
changes.push_back(
SyncChange(FROM_HERE,
SyncChange::ACTION_ADD,
- ManagedUserSharedSettingsService::CreateSyncDataForSetting(
+ SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
kIdC, "baz", blurp, true)));
SyncError error = settings_service_.ProcessSyncChanges(FROM_HERE, changes);
EXPECT_FALSE(error.IsSet()) << error.ToString();
diff --git a/chrome/browser/supervised_user/supervised_user_shared_settings_update.cc b/chrome/browser/supervised_user/supervised_user_shared_settings_update.cc
new file mode 100644
index 0000000..705b508
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_shared_settings_update.cc
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_update.h"
+
+#include "base/bind.h"
+#include "base/values.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+
+SupervisedUserSharedSettingsUpdate::SupervisedUserSharedSettingsUpdate(
+ SupervisedUserSharedSettingsService* service,
+ const std::string& su_id,
+ const std::string& key,
+ scoped_ptr<base::Value> value,
+ const base::Callback<void(bool)>& success_callback)
+ : service_(service),
+ su_id_(su_id),
+ key_(key),
+ value_(value.Pass()),
+ callback_(success_callback) {
+ service->SetValueInternal(su_id, key, *value_, false);
+ subscription_ = service->Subscribe(
+ base::Bind(&SupervisedUserSharedSettingsUpdate::OnSettingChanged,
+ base::Unretained(this)));
+}
+
+SupervisedUserSharedSettingsUpdate::~SupervisedUserSharedSettingsUpdate() {}
+
+void SupervisedUserSharedSettingsUpdate::OnSettingChanged(
+ const std::string& su_id, const std::string& key) {
+ if (su_id != su_id_)
+ return;
+
+ if (key != key_)
+ return;
+
+ const base::Value* value = service_->GetValue(su_id, key);
+ callback_.Run(value->Equals(value_.get()));
+}
diff --git a/chrome/browser/managed_mode/managed_user_shared_settings_update.h b/chrome/browser/supervised_user/supervised_user_shared_settings_update.h
index dcc9f41..0ab673d 100644
--- a/chrome/browser/managed_mode/managed_user_shared_settings_update.h
+++ b/chrome/browser/supervised_user/supervised_user_shared_settings_update.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_UPDATE_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_UPDATE_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_UPDATE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_UPDATE_H_
#include <string>
@@ -15,39 +15,39 @@ namespace base {
class Value;
}
-class ManagedUserSharedSettingsService;
+class SupervisedUserSharedSettingsService;
-// Lets clients of ManagedUserSharedSettingsService change settings and wait for
-// the Sync server to acknowledge the change. The callback passed in the
+// Lets clients of SupervisedUserSharedSettingsService change settings and wait
+// for the Sync server to acknowledge the change. The callback passed in the
// constructor will be called with a true success value after the Sync server
// has flipped the acknowledgement flag for the setting. If another client
// changes the value in the mean time, the callback will be run with a false
// success value. If the object is destroyed before that, the callback will not
// be run. Note that any changes made to the setting will not be undone when
// destroying the object, even if the update was not successful or was canceled.
-class ManagedUserSharedSettingsUpdate {
+class SupervisedUserSharedSettingsUpdate {
public:
- ManagedUserSharedSettingsUpdate(
- ManagedUserSharedSettingsService* service,
- const std::string& mu_id,
+ SupervisedUserSharedSettingsUpdate(
+ SupervisedUserSharedSettingsService* service,
+ const std::string& su_id,
const std::string& key,
scoped_ptr<base::Value> value,
const base::Callback<void(bool)>& success_callback);
- ~ManagedUserSharedSettingsUpdate();
+ ~SupervisedUserSharedSettingsUpdate();
private:
typedef base::CallbackList<void(const std::string&, const std::string&)>
CallbackList;
- void OnSettingChanged(const std::string& mu_id,
+ void OnSettingChanged(const std::string& su_id,
const std::string& key);
- ManagedUserSharedSettingsService* service_;
- std::string mu_id_;
+ SupervisedUserSharedSettingsService* service_;
+ std::string su_id_;
std::string key_;
scoped_ptr<base::Value> value_;
base::Callback<void(bool)> callback_;
scoped_ptr<CallbackList::Subscription> subscription_;
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_UPDATE_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_UPDATE_H_
diff --git a/chrome/browser/managed_mode/managed_user_shared_settings_update_unittest.cc b/chrome/browser/supervised_user/supervised_user_shared_settings_update_unittest.cc
index 54fafb7..1266ccde 100644
--- a/chrome/browser/managed_mode/managed_user_shared_settings_update_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_shared_settings_update_unittest.cc
@@ -4,16 +4,16 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_update.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_update.h"
#include "chrome/test/base/testing_profile.h"
#include "sync/api/sync_change.h"
#include "testing/gtest/include/gtest/gtest.h"
-class ManagedUserSharedSettingsUpdateTest : public testing::Test {
+class SupervisedUserSharedSettingsUpdateTest : public testing::Test {
public:
- ManagedUserSharedSettingsUpdateTest() : service_(profile_.GetPrefs()) {}
- virtual ~ManagedUserSharedSettingsUpdateTest() {}
+ SupervisedUserSharedSettingsUpdateTest() : service_(profile_.GetPrefs()) {}
+ virtual ~SupervisedUserSharedSettingsUpdateTest() {}
void OnSettingUpdated(bool success) {
result_.reset(new bool(success));
@@ -21,23 +21,23 @@ class ManagedUserSharedSettingsUpdateTest : public testing::Test {
protected:
TestingProfile profile_;
- ManagedUserSharedSettingsService service_;
+ SupervisedUserSharedSettingsService service_;
scoped_ptr<bool> result_;
};
-TEST_F(ManagedUserSharedSettingsUpdateTest, Success) {
- ManagedUserSharedSettingsUpdate update(
+TEST_F(SupervisedUserSharedSettingsUpdateTest, Success) {
+ SupervisedUserSharedSettingsUpdate update(
&service_,
"abcdef",
"name",
scoped_ptr<base::Value>(new base::StringValue("Hans Moleman")),
- base::Bind(&ManagedUserSharedSettingsUpdateTest::OnSettingUpdated,
+ base::Bind(&SupervisedUserSharedSettingsUpdateTest::OnSettingUpdated,
base::Unretained(this)));
syncer::SyncChangeList changes;
changes.push_back(syncer::SyncChange(
FROM_HERE,
syncer::SyncChange::ACTION_UPDATE,
- ManagedUserSharedSettingsService::CreateSyncDataForSetting(
+ SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
"abcdef", "name", base::StringValue("Hans Moleman"), true)));
syncer::SyncError error = service_.ProcessSyncChanges(FROM_HERE, changes);
EXPECT_FALSE(error.IsSet()) << error.ToString();
@@ -45,13 +45,13 @@ TEST_F(ManagedUserSharedSettingsUpdateTest, Success) {
EXPECT_TRUE(*result_);
}
-TEST_F(ManagedUserSharedSettingsUpdateTest, Failure) {
- ManagedUserSharedSettingsUpdate update(
+TEST_F(SupervisedUserSharedSettingsUpdateTest, Failure) {
+ SupervisedUserSharedSettingsUpdate update(
&service_,
"abcdef",
"name",
scoped_ptr<base::Value>(new base::StringValue("Hans Moleman")),
- base::Bind(&ManagedUserSharedSettingsUpdateTest::OnSettingUpdated,
+ base::Bind(&SupervisedUserSharedSettingsUpdateTest::OnSettingUpdated,
base::Unretained(this)));
// Syncing down a different change will cause the update to fail.
@@ -59,7 +59,7 @@ TEST_F(ManagedUserSharedSettingsUpdateTest, Failure) {
changes.push_back(syncer::SyncChange(
FROM_HERE,
syncer::SyncChange::ACTION_UPDATE,
- ManagedUserSharedSettingsService::CreateSyncDataForSetting(
+ SupervisedUserSharedSettingsService::CreateSyncDataForSetting(
"abcdef",
"name",
base::StringValue("Barney Gumble"),
@@ -70,14 +70,14 @@ TEST_F(ManagedUserSharedSettingsUpdateTest, Failure) {
EXPECT_FALSE(*result_);
}
-TEST_F(ManagedUserSharedSettingsUpdateTest, Cancel) {
+TEST_F(SupervisedUserSharedSettingsUpdateTest, Cancel) {
{
- ManagedUserSharedSettingsUpdate update(
+ SupervisedUserSharedSettingsUpdate update(
&service_,
"abcdef",
"name",
scoped_ptr<base::Value>(new base::StringValue("Hans Moleman")),
- base::Bind(&ManagedUserSharedSettingsUpdateTest::OnSettingUpdated,
+ base::Bind(&SupervisedUserSharedSettingsUpdateTest::OnSettingUpdated,
base::Unretained(this)));
ASSERT_FALSE(result_);
}
diff --git a/chrome/browser/managed_mode/managed_mode_site_list.cc b/chrome/browser/supervised_user/supervised_user_site_list.cc
index e254381..b71e6a9 100644
--- a/chrome/browser/managed_mode/managed_mode_site_list.cc
+++ b/chrome/browser/supervised_user/supervised_user_site_list.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_mode_site_list.h"
+#include "chrome/browser/supervised_user/supervised_user_site_list.h"
#include "base/json/json_file_value_serializer.h"
#include "base/logging.h"
@@ -69,7 +69,7 @@ int GetCategoryId(const std::string& category) {
// (via URL patterns or hostname hashes) and the URL in the corresponding Site
// struct.
void AddWhitelistEntries(const base::DictionaryValue* site_dict,
- ManagedModeSiteList::Site* site) {
+ SupervisedUserSiteList::Site* site) {
std::vector<std::string>* patterns = &site->patterns;
bool found = false;
@@ -125,29 +125,29 @@ void AddWhitelistEntries(const base::DictionaryValue* site_dict,
} // namespace
-ManagedModeSiteList::Site::Site(const base::string16& name,
- int category_id)
+SupervisedUserSiteList::Site::Site(const base::string16& name,
+ int category_id)
: name(name),
category_id(category_id) {}
-ManagedModeSiteList::Site::~Site() {}
+SupervisedUserSiteList::Site::~Site() {}
-ManagedModeSiteList::ManagedModeSiteList(
+SupervisedUserSiteList::SupervisedUserSiteList(
const std::string& extension_id,
const base::FilePath& path)
: extension_id_(extension_id),
path_(path) {
}
-ManagedModeSiteList::~ManagedModeSiteList() {
+SupervisedUserSiteList::~SupervisedUserSiteList() {
}
-ManagedModeSiteList* ManagedModeSiteList::Clone() {
- return new ManagedModeSiteList(extension_id_, path_);
+SupervisedUserSiteList* SupervisedUserSiteList::Clone() {
+ return new SupervisedUserSiteList(extension_id_, path_);
}
// static
-void ManagedModeSiteList::GetCategoryNames(
+void SupervisedUserSiteList::GetCategoryNames(
std::vector<base::string16>* categories) {
// TODO(bauerb): Collect custom categories from extensions.
for (size_t i = 0; i < arraysize(g_categories); ++i) {
@@ -155,7 +155,7 @@ void ManagedModeSiteList::GetCategoryNames(
}
}
-void ManagedModeSiteList::GetSites(std::vector<Site>* sites) {
+void SupervisedUserSiteList::GetSites(std::vector<Site>* sites) {
if (!LazyLoad())
return;
@@ -191,7 +191,7 @@ void ManagedModeSiteList::GetSites(std::vector<Site>* sites) {
}
}
-bool ManagedModeSiteList::LazyLoad() {
+bool SupervisedUserSiteList::LazyLoad() {
if (sites_.get())
return true;
@@ -232,8 +232,9 @@ bool ManagedModeSiteList::LazyLoad() {
return true;
}
-void ManagedModeSiteList::CopyThumbnailUrl(const base::DictionaryValue* source,
- base::DictionaryValue* dest) {
+void SupervisedUserSiteList::CopyThumbnailUrl(
+ const base::DictionaryValue* source,
+ base::DictionaryValue* dest) {
if (!source->HasKey(kThumbnailKey))
return;
diff --git a/chrome/browser/managed_mode/managed_mode_site_list.h b/chrome/browser/supervised_user/supervised_user_site_list.h
index 7a6c035..b159774 100644
--- a/chrome/browser/managed_mode/managed_mode_site_list.h
+++ b/chrome/browser/supervised_user/supervised_user_site_list.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_SITE_LIST_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_SITE_LIST_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_
#include <string>
#include <vector>
@@ -25,12 +25,12 @@ class ListValue;
// on the list.
// Every site has -- among other attributes -- a whitelist of URLs that are
// required to use it. All sites from all installed content packs together with
-// their respective whitelists are combined in the ManagedModeURLFilter, which
-// can tell for a given URL if it is part of the whitelist for any site.
-// Effectively, ManagedModeURLFilter then acts as a big whitelist which is the
-// union of the whitelists in all sites in all content packs. See
+// their respective whitelists are combined in the SupervisedUserURLFilter,
+// which can tell for a given URL if it is part of the whitelist for any site.
+// Effectively, SupervisedUserURLFilter then acts as a big whitelist which is
+// the union of the whitelists in all sites in all content packs. See
// http://goo.gl/cBCB8 for a diagram.
-class ManagedModeSiteList {
+class SupervisedUserSiteList {
public:
struct Site {
Site(const base::string16& name, int category_id);
@@ -52,13 +52,13 @@ class ManagedModeSiteList {
std::vector<std::string> hostname_hashes;
};
- ManagedModeSiteList(const std::string& extension_id,
- const base::FilePath& path);
- ~ManagedModeSiteList();
+ SupervisedUserSiteList(const std::string& extension_id,
+ const base::FilePath& path);
+ ~SupervisedUserSiteList();
// Creates a copy of the site list.
// Caller takes ownership of the returned value.
- ManagedModeSiteList* Clone();
+ SupervisedUserSiteList* Clone();
// Returns a list of all categories.
// TODO(bauerb): The list is hardcoded for now, but if we allow custom
@@ -78,7 +78,7 @@ class ManagedModeSiteList {
scoped_ptr<base::DictionaryValue> categories_;
scoped_ptr<base::ListValue> sites_;
- DISALLOW_COPY_AND_ASSIGN(ManagedModeSiteList);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserSiteList);
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_SITE_LIST_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SITE_LIST_H_
diff --git a/chrome/browser/managed_mode/managed_user_sync_service.cc b/chrome/browser/supervised_user/supervised_user_sync_service.cc
index d41582a..4402415 100644
--- a/chrome/browser/managed_mode/managed_user_sync_service.cc
+++ b/chrome/browser/supervised_user/supervised_user_sync_service.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
#include "base/bind.h"
#include "base/callback.h"
@@ -82,20 +82,21 @@ SyncData CreateSyncDataFromDictionaryEntry(const std::string& id,
bool success = value.GetAsDictionary(&dict);
DCHECK(success);
bool acknowledged = false;
- dict->GetBoolean(ManagedUserSyncService::kAcknowledged, &acknowledged);
+ dict->GetBoolean(SupervisedUserSyncService::kAcknowledged, &acknowledged);
std::string name;
- dict->GetString(ManagedUserSyncService::kName, &name);
+ dict->GetString(SupervisedUserSyncService::kName, &name);
DCHECK(!name.empty());
std::string master_key;
- dict->GetString(ManagedUserSyncService::kMasterKey, &master_key);
+ dict->GetString(SupervisedUserSyncService::kMasterKey, &master_key);
std::string chrome_avatar;
- dict->GetString(ManagedUserSyncService::kChromeAvatar, &chrome_avatar);
+ dict->GetString(SupervisedUserSyncService::kChromeAvatar, &chrome_avatar);
std::string chromeos_avatar;
- dict->GetString(ManagedUserSyncService::kChromeOsAvatar, &chromeos_avatar);
+ dict->GetString(SupervisedUserSyncService::kChromeOsAvatar, &chromeos_avatar);
std::string signature;
- dict->GetString(ManagedUserSyncService::kPasswordSignatureKey, &signature);
+ dict->GetString(SupervisedUserSyncService::kPasswordSignatureKey, &signature);
std::string encryption;
- dict->GetString(ManagedUserSyncService::kPasswordEncryptionKey, &encryption);
+ dict->GetString(SupervisedUserSyncService::kPasswordEncryptionKey,
+ &encryption);
return CreateLocalSyncData(id,
name,
@@ -109,39 +110,39 @@ SyncData CreateSyncDataFromDictionaryEntry(const std::string& id,
} // namespace
-const char ManagedUserSyncService::kAcknowledged[] = "acknowledged";
-const char ManagedUserSyncService::kChromeAvatar[] = "chromeAvatar";
-const char ManagedUserSyncService::kChromeOsAvatar[] = "chromeOsAvatar";
-const char ManagedUserSyncService::kMasterKey[] = "masterKey";
-const char ManagedUserSyncService::kName[] = "name";
-const char ManagedUserSyncService::kPasswordSignatureKey[] =
+const char SupervisedUserSyncService::kAcknowledged[] = "acknowledged";
+const char SupervisedUserSyncService::kChromeAvatar[] = "chromeAvatar";
+const char SupervisedUserSyncService::kChromeOsAvatar[] = "chromeOsAvatar";
+const char SupervisedUserSyncService::kMasterKey[] = "masterKey";
+const char SupervisedUserSyncService::kName[] = "name";
+const char SupervisedUserSyncService::kPasswordSignatureKey[] =
"passwordSignatureKey";
-const char ManagedUserSyncService::kPasswordEncryptionKey[] =
+const char SupervisedUserSyncService::kPasswordEncryptionKey[] =
"passwordEncryptionKey";
-const int ManagedUserSyncService::kNoAvatar = -100;
+const int SupervisedUserSyncService::kNoAvatar = -100;
-ManagedUserSyncService::ManagedUserSyncService(PrefService* prefs)
+SupervisedUserSyncService::SupervisedUserSyncService(PrefService* prefs)
: prefs_(prefs) {
pref_change_registrar_.Init(prefs_);
pref_change_registrar_.Add(
prefs::kGoogleServicesLastUsername,
- base::Bind(&ManagedUserSyncService::OnLastSignedInUsernameChange,
+ base::Bind(&SupervisedUserSyncService::OnLastSignedInUsernameChange,
base::Unretained(this)));
}
-ManagedUserSyncService::~ManagedUserSyncService() {
+SupervisedUserSyncService::~SupervisedUserSyncService() {
}
// static
-void ManagedUserSyncService::RegisterProfilePrefs(
+void SupervisedUserSyncService::RegisterProfilePrefs(
PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(prefs::kSupervisedUsers,
PrefRegistrySyncable::UNSYNCABLE_PREF);
}
// static
-bool ManagedUserSyncService::GetAvatarIndex(const std::string& avatar_str,
- int* avatar_index) {
+bool SupervisedUserSyncService::GetAvatarIndex(const std::string& avatar_str,
+ int* avatar_index) {
DCHECK(avatar_index);
if (avatar_str.empty()) {
*avatar_index = kNoAvatar;
@@ -183,7 +184,7 @@ bool ManagedUserSyncService::GetAvatarIndex(const std::string& avatar_str,
}
// static
-std::string ManagedUserSyncService::BuildAvatarString(int avatar_index) {
+std::string SupervisedUserSyncService::BuildAvatarString(int avatar_index) {
#if defined(OS_CHROMEOS)
const char* prefix = kChromeOSAvatarPrefix;
#else
@@ -192,17 +193,17 @@ std::string ManagedUserSyncService::BuildAvatarString(int avatar_index) {
return base::StringPrintf("%s%d", prefix, avatar_index);
}
-void ManagedUserSyncService::AddObserver(
- ManagedUserSyncServiceObserver* observer) {
+void SupervisedUserSyncService::AddObserver(
+ SupervisedUserSyncServiceObserver* observer) {
observers_.AddObserver(observer);
}
-void ManagedUserSyncService::RemoveObserver(
- ManagedUserSyncServiceObserver* observer) {
+void SupervisedUserSyncService::RemoveObserver(
+ SupervisedUserSyncServiceObserver* observer) {
observers_.RemoveObserver(observer);
}
-scoped_ptr<base::DictionaryValue> ManagedUserSyncService::CreateDictionary(
+scoped_ptr<base::DictionaryValue> SupervisedUserSyncService::CreateDictionary(
const std::string& name,
const std::string& master_key,
const std::string& signature_key,
@@ -227,38 +228,39 @@ scoped_ptr<base::DictionaryValue> ManagedUserSyncService::CreateDictionary(
return result.Pass();
}
-void ManagedUserSyncService::AddManagedUser(const std::string& id,
- const std::string& name,
- const std::string& master_key,
- const std::string& signature_key,
- const std::string& encryption_key,
- int avatar_index) {
- UpdateManagedUserImpl(id,
- name,
- master_key,
- signature_key,
- encryption_key,
- avatar_index,
- true /* add */);
+void SupervisedUserSyncService::AddSupervisedUser(
+ const std::string& id,
+ const std::string& name,
+ const std::string& master_key,
+ const std::string& signature_key,
+ const std::string& encryption_key,
+ int avatar_index) {
+ UpdateSupervisedUserImpl(id,
+ name,
+ master_key,
+ signature_key,
+ encryption_key,
+ avatar_index,
+ true /* add */);
}
-void ManagedUserSyncService::UpdateManagedUser(
+void SupervisedUserSyncService::UpdateSupervisedUser(
const std::string& id,
const std::string& name,
const std::string& master_key,
const std::string& signature_key,
const std::string& encryption_key,
int avatar_index) {
- UpdateManagedUserImpl(id,
- name,
- master_key,
- signature_key,
- encryption_key,
- avatar_index,
- false /* update */);
+ UpdateSupervisedUserImpl(id,
+ name,
+ master_key,
+ signature_key,
+ encryption_key,
+ avatar_index,
+ false /* update */);
}
-void ManagedUserSyncService::UpdateManagedUserImpl(
+void SupervisedUserSyncService::UpdateSupervisedUserImpl(
const std::string& id,
const std::string& name,
const std::string& master_key,
@@ -289,7 +291,7 @@ void ManagedUserSyncService::UpdateManagedUserImpl(
DCHECK(!error.IsSet()) << error.ToString();
}
-void ManagedUserSyncService::DeleteManagedUser(const std::string& id) {
+void SupervisedUserSyncService::DeleteSupervisedUser(const std::string& id) {
DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUsers);
bool success = update->RemoveWithoutPathExpansion(id, NULL);
DCHECK(success);
@@ -307,12 +309,12 @@ void ManagedUserSyncService::DeleteManagedUser(const std::string& id) {
DCHECK(!sync_error.IsSet());
}
-const base::DictionaryValue* ManagedUserSyncService::GetManagedUsers() {
+const base::DictionaryValue* SupervisedUserSyncService::GetSupervisedUsers() {
DCHECK(sync_processor_);
return prefs_->GetDictionary(prefs::kSupervisedUsers);
}
-bool ManagedUserSyncService::UpdateManagedUserAvatarIfNeeded(
+bool SupervisedUserSyncService::UpdateSupervisedUserAvatarIfNeeded(
const std::string& id,
int avatar_index) {
DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUsers);
@@ -323,19 +325,22 @@ bool ManagedUserSyncService::UpdateManagedUserAvatarIfNeeded(
DCHECK(success);
bool acknowledged = false;
- value->GetBoolean(ManagedUserSyncService::kAcknowledged, &acknowledged);
+ value->GetBoolean(SupervisedUserSyncService::kAcknowledged, &acknowledged);
std::string name;
- value->GetString(ManagedUserSyncService::kName, &name);
+ value->GetString(SupervisedUserSyncService::kName, &name);
std::string master_key;
- value->GetString(ManagedUserSyncService::kMasterKey, &master_key);
+ value->GetString(SupervisedUserSyncService::kMasterKey, &master_key);
std::string signature;
- value->GetString(ManagedUserSyncService::kPasswordSignatureKey, &signature);
+ value->GetString(SupervisedUserSyncService::kPasswordSignatureKey,
+ &signature);
std::string encryption;
- value->GetString(ManagedUserSyncService::kPasswordEncryptionKey, &encryption);
+ value->GetString(SupervisedUserSyncService::kPasswordEncryptionKey,
+ &encryption);
std::string chromeos_avatar;
- value->GetString(ManagedUserSyncService::kChromeOsAvatar, &chromeos_avatar);
+ value->GetString(SupervisedUserSyncService::kChromeOsAvatar,
+ &chromeos_avatar);
std::string chrome_avatar;
- value->GetString(ManagedUserSyncService::kChromeAvatar, &chrome_avatar);
+ value->GetString(SupervisedUserSyncService::kChromeAvatar, &chrome_avatar);
// The following check is just for safety. We want to avoid that the existing
// avatar selection is overwritten. Currently we don't allow the user to
// choose a different avatar in the recreation dialog, anyway, if there is
@@ -372,16 +377,17 @@ bool ManagedUserSyncService::UpdateManagedUserAvatarIfNeeded(
return true;
}
-void ManagedUserSyncService::ClearManagedUserAvatar(const std::string& id) {
- bool cleared = UpdateManagedUserAvatarIfNeeded(id, kNoAvatar);
+void SupervisedUserSyncService::ClearSupervisedUserAvatar(
+ const std::string& id) {
+ bool cleared = UpdateSupervisedUserAvatarIfNeeded(id, kNoAvatar);
DCHECK(cleared);
}
-void ManagedUserSyncService::GetManagedUsersAsync(
- const ManagedUsersCallback& callback) {
+void SupervisedUserSyncService::GetSupervisedUsersAsync(
+ const SupervisedUsersCallback& callback) {
// If we are already syncing, just run the callback.
if (sync_processor_) {
- callback.Run(GetManagedUsers());
+ callback.Run(GetSupervisedUsers());
return;
}
@@ -389,11 +395,11 @@ void ManagedUserSyncService::GetManagedUsersAsync(
callbacks_.push_back(callback);
}
-void ManagedUserSyncService::Shutdown() {
- NotifyManagedUsersSyncingStopped();
+void SupervisedUserSyncService::Shutdown() {
+ NotifySupervisedUsersSyncingStopped();
}
-SyncMergeResult ManagedUserSyncService::MergeDataAndStartSyncing(
+SyncMergeResult SupervisedUserSyncService::MergeDataAndStartSyncing(
ModelType type,
const SyncDataList& initial_sync_data,
scoped_ptr<SyncChangeProcessor> sync_processor,
@@ -414,24 +420,24 @@ SyncMergeResult ManagedUserSyncService::MergeDataAndStartSyncing(
for (SyncDataList::const_iterator it = initial_sync_data.begin();
it != initial_sync_data.end(); ++it) {
DCHECK_EQ(SUPERVISED_USERS, it->GetDataType());
- const ManagedUserSpecifics& managed_user =
+ const ManagedUserSpecifics& supervised_user =
it->GetSpecifics().managed_user();
base::DictionaryValue* value = new base::DictionaryValue();
- value->SetString(kName, managed_user.name());
- value->SetBoolean(kAcknowledged, managed_user.acknowledged());
- value->SetString(kMasterKey, managed_user.master_key());
- value->SetString(kChromeAvatar, managed_user.chrome_avatar());
- value->SetString(kChromeOsAvatar, managed_user.chromeos_avatar());
+ value->SetString(kName, supervised_user.name());
+ value->SetBoolean(kAcknowledged, supervised_user.acknowledged());
+ value->SetString(kMasterKey, supervised_user.master_key());
+ value->SetString(kChromeAvatar, supervised_user.chrome_avatar());
+ value->SetString(kChromeOsAvatar, supervised_user.chromeos_avatar());
value->SetString(kPasswordSignatureKey,
- managed_user.password_signature_key());
+ supervised_user.password_signature_key());
value->SetString(kPasswordEncryptionKey,
- managed_user.password_encryption_key());
- if (dict->HasKey(managed_user.id()))
+ supervised_user.password_encryption_key());
+ if (dict->HasKey(supervised_user.id()))
num_items_modified++;
else
num_items_added++;
- dict->SetWithoutPathExpansion(managed_user.id(), value);
- seen_ids.insert(managed_user.id());
+ dict->SetWithoutPathExpansion(supervised_user.id(), value);
+ seen_ids.insert(supervised_user.id());
}
for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
@@ -454,16 +460,16 @@ SyncMergeResult ManagedUserSyncService::MergeDataAndStartSyncing(
return result;
}
-void ManagedUserSyncService::StopSyncing(ModelType type) {
+void SupervisedUserSyncService::StopSyncing(ModelType type) {
DCHECK_EQ(SUPERVISED_USERS, type);
// The observers may want to change the Sync data, so notify them before
// resetting the |sync_processor_|.
- NotifyManagedUsersSyncingStopped();
+ NotifySupervisedUsersSyncingStopped();
sync_processor_.reset();
error_handler_.reset();
}
-SyncDataList ManagedUserSyncService::GetAllSyncData(
+SyncDataList SupervisedUserSyncService::GetAllSyncData(
ModelType type) const {
SyncDataList data;
DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUsers);
@@ -474,7 +480,7 @@ SyncDataList ManagedUserSyncService::GetAllSyncData(
return data;
}
-SyncError ManagedUserSyncService::ProcessSyncChanges(
+SyncError SupervisedUserSyncService::ProcessSyncChanges(
const tracked_objects::Location& from_here,
const SyncChangeList& change_list) {
SyncError error;
@@ -484,45 +490,46 @@ SyncError ManagedUserSyncService::ProcessSyncChanges(
it != change_list.end(); ++it) {
SyncData data = it->sync_data();
DCHECK_EQ(SUPERVISED_USERS, data.GetDataType());
- const ManagedUserSpecifics& managed_user =
+ const ManagedUserSpecifics& supervised_user =
data.GetSpecifics().managed_user();
switch (it->change_type()) {
case SyncChange::ACTION_ADD:
case SyncChange::ACTION_UPDATE: {
// Every item we get from the server should be acknowledged.
- DCHECK(managed_user.acknowledged());
+ DCHECK(supervised_user.acknowledged());
const base::DictionaryValue* old_value = NULL;
- dict->GetDictionaryWithoutPathExpansion(managed_user.id(), &old_value);
+ dict->GetDictionaryWithoutPathExpansion(supervised_user.id(),
+ &old_value);
- // For an update action, the managed user should already exist, for an
- // add action, it should not.
+ // For an update action, the supervised user should already exist, for
+ // an add action, it should not.
DCHECK_EQ(
old_value ? SyncChange::ACTION_UPDATE : SyncChange::ACTION_ADD,
it->change_type());
- // If the managed user switched from unacknowledged to acknowledged,
+ // If the supervised user switched from unacknowledged to acknowledged,
// we might need to continue with a registration.
if (old_value && !old_value->HasKey(kAcknowledged))
- NotifyManagedUserAcknowledged(managed_user.id());
+ NotifySupervisedUserAcknowledged(supervised_user.id());
base::DictionaryValue* value = new base::DictionaryValue;
- value->SetString(kName, managed_user.name());
- value->SetBoolean(kAcknowledged, managed_user.acknowledged());
- value->SetString(kMasterKey, managed_user.master_key());
- value->SetString(kChromeAvatar, managed_user.chrome_avatar());
- value->SetString(kChromeOsAvatar, managed_user.chromeos_avatar());
+ value->SetString(kName, supervised_user.name());
+ value->SetBoolean(kAcknowledged, supervised_user.acknowledged());
+ value->SetString(kMasterKey, supervised_user.master_key());
+ value->SetString(kChromeAvatar, supervised_user.chrome_avatar());
+ value->SetString(kChromeOsAvatar, supervised_user.chromeos_avatar());
value->SetString(kPasswordSignatureKey,
- managed_user.password_signature_key());
+ supervised_user.password_signature_key());
value->SetString(kPasswordEncryptionKey,
- managed_user.password_encryption_key());
- dict->SetWithoutPathExpansion(managed_user.id(), value);
+ supervised_user.password_encryption_key());
+ dict->SetWithoutPathExpansion(supervised_user.id(), value);
- NotifyManagedUsersChanged();
+ NotifySupervisedUsersChanged();
break;
}
case SyncChange::ACTION_DELETE: {
- DCHECK(dict->HasKey(managed_user.id())) << managed_user.id();
- dict->RemoveWithoutPathExpansion(managed_user.id(), NULL);
+ DCHECK(dict->HasKey(supervised_user.id())) << supervised_user.id();
+ dict->RemoveWithoutPathExpansion(supervised_user.id(), NULL);
break;
}
case SyncChange::ACTION_INVALID: {
@@ -534,37 +541,37 @@ SyncError ManagedUserSyncService::ProcessSyncChanges(
return error;
}
-void ManagedUserSyncService::OnLastSignedInUsernameChange() {
+void SupervisedUserSyncService::OnLastSignedInUsernameChange() {
DCHECK(!sync_processor_);
- // If the last signed in user changes, we clear all data, to avoid managed
+ // If the last signed in user changes, we clear all data, to avoid supervised
// users from one custodian appearing in another one's profile.
prefs_->ClearPref(prefs::kSupervisedUsers);
}
-void ManagedUserSyncService::NotifyManagedUserAcknowledged(
- const std::string& managed_user_id) {
- FOR_EACH_OBSERVER(ManagedUserSyncServiceObserver, observers_,
- OnManagedUserAcknowledged(managed_user_id));
+void SupervisedUserSyncService::NotifySupervisedUserAcknowledged(
+ const std::string& supervised_user_id) {
+ FOR_EACH_OBSERVER(SupervisedUserSyncServiceObserver, observers_,
+ OnSupervisedUserAcknowledged(supervised_user_id));
}
-void ManagedUserSyncService::NotifyManagedUsersSyncingStopped() {
- FOR_EACH_OBSERVER(ManagedUserSyncServiceObserver, observers_,
- OnManagedUsersSyncingStopped());
+void SupervisedUserSyncService::NotifySupervisedUsersSyncingStopped() {
+ FOR_EACH_OBSERVER(SupervisedUserSyncServiceObserver, observers_,
+ OnSupervisedUsersSyncingStopped());
}
-void ManagedUserSyncService::NotifyManagedUsersChanged() {
- FOR_EACH_OBSERVER(ManagedUserSyncServiceObserver,
+void SupervisedUserSyncService::NotifySupervisedUsersChanged() {
+ FOR_EACH_OBSERVER(SupervisedUserSyncServiceObserver,
observers_,
- OnManagedUsersChanged());
+ OnSupervisedUsersChanged());
}
-void ManagedUserSyncService::DispatchCallbacks() {
- const base::DictionaryValue* managed_users =
+void SupervisedUserSyncService::DispatchCallbacks() {
+ const base::DictionaryValue* supervised_users =
prefs_->GetDictionary(prefs::kSupervisedUsers);
- for (std::vector<ManagedUsersCallback>::iterator it = callbacks_.begin();
+ for (std::vector<SupervisedUsersCallback>::iterator it = callbacks_.begin();
it != callbacks_.end(); ++it) {
- it->Run(managed_users);
+ it->Run(supervised_users);
}
callbacks_.clear();
}
diff --git a/chrome/browser/managed_mode/managed_user_sync_service.h b/chrome/browser/supervised_user/supervised_user_sync_service.h
index 5656ec5..ae1acd5 100644
--- a/chrome/browser/managed_mode/managed_user_sync_service.h
+++ b/chrome/browser/supervised_user/supervised_user_sync_service.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_SERVICE_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_SERVICE_H_
#include <vector>
@@ -11,8 +11,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/prefs/pref_change_registrar.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_observer.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_observer.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "components/keyed_service/core/keyed_service.h"
#include "sync/api/syncable_service.h"
@@ -26,14 +26,14 @@ class PrefRegistrySyncable;
class PrefService;
-class ManagedUserSyncService : public KeyedService,
- public syncer::SyncableService {
+class SupervisedUserSyncService : public KeyedService,
+ public syncer::SyncableService {
public:
- // For use with GetManagedUsersAsync() below.
+ // For use with GetSupervisedUsersAsync() below.
typedef base::Callback<void(const base::DictionaryValue*)>
- ManagedUsersCallback;
+ SupervisedUsersCallback;
- // Dictionary keys for entry values of |prefs::kManagedUsers|.
+ // Dictionary keys for entry values of |prefs::kSupervisedUsers|.
static const char kAcknowledged[];
static const char kChromeAvatar[];
static const char kChromeOsAvatar[];
@@ -45,7 +45,7 @@ class ManagedUserSyncService : public KeyedService,
// Represents a non-existing avatar on Chrome and Chrome OS.
static const int kNoAvatar;
- virtual ~ManagedUserSyncService();
+ virtual ~SupervisedUserSyncService();
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
@@ -54,7 +54,7 @@ class ManagedUserSyncService : public KeyedService,
// index was extracted successfully and false otherwise.
// |avatar_str| should have the format: "chrome-avatar-index:INDEX"
// where INDEX is the integer to be extracted. |avatar_str| can be empty
- // in case there is no avatar synced for a managed user in which case
+ // in case there is no avatar synced for a supervised user in which case
// |avatar_index| is set to -1.
static bool GetAvatarIndex(const std::string& avatar_str,
int* avatar_index);
@@ -64,44 +64,46 @@ class ManagedUserSyncService : public KeyedService,
// It is exposed for testing purposes only.
static std::string BuildAvatarString(int avatar_index);
- void AddObserver(ManagedUserSyncServiceObserver* observer);
- void RemoveObserver(ManagedUserSyncServiceObserver* observer);
+ void AddObserver(SupervisedUserSyncServiceObserver* observer);
+ void RemoveObserver(SupervisedUserSyncServiceObserver* observer);
- void AddManagedUser(const std::string& id,
- const std::string& name,
- const std::string& master_key,
- const std::string& password_signature_key,
- const std::string& password_encryption_key,
- int avatar_index);
- void UpdateManagedUser(const std::string& id,
+ void AddSupervisedUser(const std::string& id,
const std::string& name,
const std::string& master_key,
const std::string& signature_key,
const std::string& encryption_key,
int avatar_index);
+ void UpdateSupervisedUser(const std::string& id,
+ const std::string& name,
+ const std::string& master_key,
+ const std::string& signature_key,
+ const std::string& encryption_key,
+ int avatar_index);
- void DeleteManagedUser(const std::string& id);
+ void DeleteSupervisedUser(const std::string& id);
- // Updates the managed user avatar only if the managed user has
+ // Updates the supervised user avatar only if the supervised user has
// no avatar and |avatar_index| is set to some value other than
// |kNoAvatar|. If |avatar_index| equals |kNoAvatar| and the
- // managed user has an avatar, it will be cleared. However,
- // to clear an avatar call the convenience method |ClearManagedUserAvatar()|.
+ // supervised user has an avatar, it will be cleared. However,
+ // to clear an avatar call the convenience method
+ // |ClearSupervisedUserAvatar()|.
// Returns true if the avatar value is changed (either updated or cleared)
// and false otherwise.
- bool UpdateManagedUserAvatarIfNeeded(const std::string& id, int avatar_index);
- void ClearManagedUserAvatar(const std::string& id);
+ bool UpdateSupervisedUserAvatarIfNeeded(const std::string& id,
+ int avatar_index);
+ void ClearSupervisedUserAvatar(const std::string& id);
- // Returns a dictionary containing all managed users managed by this
+ // Returns a dictionary containing all supervised users supervised by this
// custodian. This method should only be called once this service has started
- // syncing managed users (i.e. has finished its initial merge of local and
+ // syncing supervised users (i.e. has finished its initial merge of local and
// server-side data, via MergeDataAndStartSyncing), as the stored data might
// be outdated before that.
- const base::DictionaryValue* GetManagedUsers();
+ const base::DictionaryValue* GetSupervisedUsers();
- // Calls the passed |callback| with a dictionary containing all managed users
- // managed by this custodian.
- void GetManagedUsersAsync(const ManagedUsersCallback& callback);
+ // Calls the passed |callback| with a dictionary containing all supervised
+ // users managed by this custodian.
+ void GetSupervisedUsersAsync(const SupervisedUsersCallback& callback);
// KeyedService implementation:
virtual void Shutdown() OVERRIDE;
@@ -120,11 +122,11 @@ class ManagedUserSyncService : public KeyedService,
const syncer::SyncChangeList& change_list) OVERRIDE;
private:
- friend class ManagedUserSyncServiceFactory;
+ friend class SupervisedUserSyncServiceFactory;
- // Use |ManagedUserSyncServiceFactory::GetForProfile(...)| to get an
+ // Use |SupervisedUserSyncServiceFactory::GetForProfile(...)| to get an
// instance of this service.
- explicit ManagedUserSyncService(PrefService* prefs);
+ explicit SupervisedUserSyncService(PrefService* prefs);
void OnLastSignedInUsernameChange();
@@ -135,17 +137,17 @@ class ManagedUserSyncService : public KeyedService,
const std::string& encryption_key,
int avatar_index);
- void UpdateManagedUserImpl(const std::string& id,
- const std::string& name,
- const std::string& master_key,
- const std::string& signature_key,
- const std::string& encryption_key,
- int avatar_index,
- bool add_user);
+ void UpdateSupervisedUserImpl(const std::string& id,
+ const std::string& name,
+ const std::string& master_key,
+ const std::string& signature_key,
+ const std::string& encryption_key,
+ int avatar_index,
+ bool add_user);
- void NotifyManagedUserAcknowledged(const std::string& managed_user_id);
- void NotifyManagedUsersSyncingStopped();
- void NotifyManagedUsersChanged();
+ void NotifySupervisedUserAcknowledged(const std::string& supervised_user_id);
+ void NotifySupervisedUsersSyncingStopped();
+ void NotifySupervisedUsersChanged();
void DispatchCallbacks();
@@ -155,11 +157,11 @@ class ManagedUserSyncService : public KeyedService,
scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
scoped_ptr<syncer::SyncErrorFactory> error_handler_;
- ObserverList<ManagedUserSyncServiceObserver> observers_;
+ ObserverList<SupervisedUserSyncServiceObserver> observers_;
- std::vector<ManagedUsersCallback> callbacks_;
+ std::vector<SupervisedUsersCallback> callbacks_;
- DISALLOW_COPY_AND_ASSIGN(ManagedUserSyncService);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserSyncService);
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_SERVICE_H_
diff --git a/chrome/browser/supervised_user/supervised_user_sync_service_factory.cc b/chrome/browser/supervised_user/supervised_user_sync_service_factory.cc
new file mode 100644
index 0000000..ed2f3fb
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_sync_service_factory.cc
@@ -0,0 +1,36 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+
+// static
+SupervisedUserSyncService* SupervisedUserSyncServiceFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<SupervisedUserSyncService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+// static
+SupervisedUserSyncServiceFactory*
+SupervisedUserSyncServiceFactory::GetInstance() {
+ return Singleton<SupervisedUserSyncServiceFactory>::get();
+}
+
+SupervisedUserSyncServiceFactory::SupervisedUserSyncServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "SupervisedUserSyncService",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+SupervisedUserSyncServiceFactory::~SupervisedUserSyncServiceFactory() {}
+
+KeyedService* SupervisedUserSyncServiceFactory::BuildServiceInstanceFor(
+ content::BrowserContext* profile) const {
+ return new SupervisedUserSyncService(
+ static_cast<Profile*>(profile)->GetPrefs());
+}
diff --git a/chrome/browser/supervised_user/supervised_user_sync_service_factory.h b/chrome/browser/supervised_user/supervised_user_sync_service_factory.h
new file mode 100644
index 0000000..f390a59
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_sync_service_factory.h
@@ -0,0 +1,32 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_SERVICE_FACTORY_H_
+
+#include "base/memory/singleton.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+
+class Profile;
+class SupervisedUserSyncService;
+
+class SupervisedUserSyncServiceFactory
+ : public BrowserContextKeyedServiceFactory {
+ public:
+ static SupervisedUserSyncService* GetForProfile(Profile* profile);
+
+ static SupervisedUserSyncServiceFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<SupervisedUserSyncServiceFactory>;
+
+ SupervisedUserSyncServiceFactory();
+ virtual ~SupervisedUserSyncServiceFactory();
+
+ // BrowserContextKeyedServiceFactory:
+ virtual KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const OVERRIDE;
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_SERVICE_FACTORY_H_
diff --git a/chrome/browser/supervised_user/supervised_user_sync_service_observer.h b/chrome/browser/supervised_user/supervised_user_sync_service_observer.h
new file mode 100644
index 0000000..ab4b6eb
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_user_sync_service_observer.h
@@ -0,0 +1,23 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_SERVICE_OBSERVER_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_SERVICE_OBSERVER_H_
+
+class SupervisedUserSyncServiceObserver {
+ public:
+ // Called when the Sync server has acknowledged a newly
+ // created supervised user.
+ virtual void OnSupervisedUserAcknowledged(
+ const std::string& supervised_user_id) = 0;
+
+ virtual void OnSupervisedUsersSyncingStopped() = 0;
+
+ virtual void OnSupervisedUsersChanged() = 0;
+
+ protected:
+ virtual ~SupervisedUserSyncServiceObserver() {}
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_SERVICE_OBSERVER_H_
diff --git a/chrome/browser/managed_mode/managed_user_sync_service_unittest.cc b/chrome/browser/supervised_user/supervised_user_sync_service_unittest.cc
index f59eea6..8cb0c70 100644
--- a/chrome/browser/managed_mode/managed_user_sync_service_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_sync_service_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,8 +10,8 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "sync/api/attachments/attachment_id.h"
@@ -76,18 +76,18 @@ SyncChange MockChangeProcessor::GetChange(const std::string& id) const {
return SyncChange();
}
-// Callback for ManagedUserSyncService::GetManagedUsersAsync().
-void GetManagedUsersCallback(const base::DictionaryValue** dict,
- const base::DictionaryValue* managed_users) {
- *dict = managed_users;
+// Callback for SupervisedUserSyncService::GetSupervisedUsersAsync().
+void GetSupervisedUsersCallback(const base::DictionaryValue** dict,
+ const base::DictionaryValue* supervised_users) {
+ *dict = supervised_users;
}
} // namespace
-class ManagedUserSyncServiceTest : public ::testing::Test {
+class SupervisedUserSyncServiceTest : public ::testing::Test {
public:
- ManagedUserSyncServiceTest();
- virtual ~ManagedUserSyncServiceTest();
+ SupervisedUserSyncServiceTest();
+ virtual ~SupervisedUserSyncServiceTest();
protected:
scoped_ptr<SyncChangeProcessor> CreateChangeProcessor();
@@ -97,42 +97,42 @@ class ManagedUserSyncServiceTest : public ::testing::Test {
const std::string& avatar);
PrefService* prefs() { return profile_.GetPrefs(); }
- ManagedUserSyncService* service() { return service_; }
+ SupervisedUserSyncService* service() { return service_; }
MockChangeProcessor* change_processor() { return change_processor_; }
private:
base::MessageLoop message_loop;
TestingProfile profile_;
- ManagedUserSyncService* service_;
+ SupervisedUserSyncService* service_;
- // Owned by the ManagedUserSyncService.
+ // Owned by the SupervisedUserSyncService.
MockChangeProcessor* change_processor_;
// A unique ID for creating "remote" Sync data.
int64 sync_data_id_;
};
-ManagedUserSyncServiceTest::ManagedUserSyncServiceTest()
+SupervisedUserSyncServiceTest::SupervisedUserSyncServiceTest()
: change_processor_(NULL),
sync_data_id_(0) {
- service_ = ManagedUserSyncServiceFactory::GetForProfile(&profile_);
+ service_ = SupervisedUserSyncServiceFactory::GetForProfile(&profile_);
}
-ManagedUserSyncServiceTest::~ManagedUserSyncServiceTest() {}
+SupervisedUserSyncServiceTest::~SupervisedUserSyncServiceTest() {}
scoped_ptr<SyncChangeProcessor>
-ManagedUserSyncServiceTest::CreateChangeProcessor() {
+SupervisedUserSyncServiceTest::CreateChangeProcessor() {
EXPECT_FALSE(change_processor_);
change_processor_ = new MockChangeProcessor();
return scoped_ptr<SyncChangeProcessor>(change_processor_);
}
scoped_ptr<SyncErrorFactory>
-ManagedUserSyncServiceTest::CreateErrorFactory() {
+SupervisedUserSyncServiceTest::CreateErrorFactory() {
return scoped_ptr<SyncErrorFactory>(new syncer::SyncErrorFactoryMock());
}
-SyncData ManagedUserSyncServiceTest::CreateRemoteData(
+SyncData SupervisedUserSyncServiceTest::CreateRemoteData(
const std::string& id,
const std::string& name,
const std::string& chrome_avatar) {
@@ -151,7 +151,7 @@ SyncData ManagedUserSyncServiceTest::CreateRemoteData(
syncer::AttachmentServiceProxyForTest::Create());
}
-TEST_F(ManagedUserSyncServiceTest, MergeEmpty) {
+TEST_F(SupervisedUserSyncServiceTest, MergeEmpty) {
SyncMergeResult result =
service()->MergeDataAndStartSyncing(SUPERVISED_USERS,
SyncDataList(),
@@ -163,14 +163,14 @@ TEST_F(ManagedUserSyncServiceTest, MergeEmpty) {
EXPECT_EQ(0, result.num_items_deleted());
EXPECT_EQ(0, result.num_items_before_association());
EXPECT_EQ(0, result.num_items_after_association());
- EXPECT_EQ(0u, service()->GetManagedUsers()->size());
+ EXPECT_EQ(0u, service()->GetSupervisedUsers()->size());
EXPECT_EQ(0u, change_processor()->changes().size());
service()->StopSyncing(SUPERVISED_USERS);
service()->Shutdown();
}
-TEST_F(ManagedUserSyncServiceTest, MergeExisting) {
+TEST_F(SupervisedUserSyncServiceTest, MergeExisting) {
const char kNameKey[] = "name";
const char kAcknowledgedKey[] = "acknowledged";
const char kChromeAvatarKey[] = "chromeAvatar";
@@ -194,19 +194,19 @@ TEST_F(ManagedUserSyncServiceTest, MergeExisting) {
const char kAvatar4[] = "";
{
DictionaryPrefUpdate update(prefs(), prefs::kSupervisedUsers);
- base::DictionaryValue* managed_users = update.Get();
+ base::DictionaryValue* supervised_users = update.Get();
base::DictionaryValue* dict = new base::DictionaryValue;
dict->SetString(kNameKey, kName1);
- managed_users->Set(kUserId1, dict);
+ supervised_users->Set(kUserId1, dict);
dict = new base::DictionaryValue;
dict->SetString(kNameKey, kName2);
dict->SetBoolean(kAcknowledgedKey, true);
- managed_users->Set(kUserId2, dict);
+ supervised_users->Set(kUserId2, dict);
}
- const base::DictionaryValue* async_managed_users = NULL;
- service()->GetManagedUsersAsync(
- base::Bind(&GetManagedUsersCallback, &async_managed_users));
+ const base::DictionaryValue* async_supervised_users = NULL;
+ service()->GetSupervisedUsersAsync(
+ base::Bind(&GetSupervisedUsersCallback, &async_supervised_users));
SyncDataList initial_sync_data;
initial_sync_data.push_back(CreateRemoteData(kUserId2, kName2, kAvatar2));
@@ -225,51 +225,52 @@ TEST_F(ManagedUserSyncServiceTest, MergeExisting) {
EXPECT_EQ(2, result.num_items_before_association());
EXPECT_EQ(4, result.num_items_after_association());
- const base::DictionaryValue* managed_users = service()->GetManagedUsers();
- EXPECT_EQ(4u, managed_users->size());
- EXPECT_TRUE(async_managed_users);
- EXPECT_TRUE(managed_users->Equals(async_managed_users));
+ const base::DictionaryValue* supervised_users =
+ service()->GetSupervisedUsers();
+ EXPECT_EQ(4u, supervised_users->size());
+ EXPECT_TRUE(async_supervised_users);
+ EXPECT_TRUE(supervised_users->Equals(async_supervised_users));
{
- const base::DictionaryValue* managed_user = NULL;
- ASSERT_TRUE(managed_users->GetDictionary(kUserId2, &managed_user));
- ASSERT_TRUE(managed_user);
+ const base::DictionaryValue* supervised_user = NULL;
+ ASSERT_TRUE(supervised_users->GetDictionary(kUserId2, &supervised_user));
+ ASSERT_TRUE(supervised_user);
std::string name;
- EXPECT_TRUE(managed_user->GetString(kNameKey, &name));
+ EXPECT_TRUE(supervised_user->GetString(kNameKey, &name));
EXPECT_EQ(kName2, name);
bool acknowledged = false;
- EXPECT_TRUE(managed_user->GetBoolean(kAcknowledgedKey, &acknowledged));
+ EXPECT_TRUE(supervised_user->GetBoolean(kAcknowledgedKey, &acknowledged));
EXPECT_TRUE(acknowledged);
std::string avatar;
- EXPECT_TRUE(managed_user->GetString(kChromeAvatarKey, &avatar));
+ EXPECT_TRUE(supervised_user->GetString(kChromeAvatarKey, &avatar));
EXPECT_EQ(kAvatar2, avatar);
}
{
- const base::DictionaryValue* managed_user = NULL;
- ASSERT_TRUE(managed_users->GetDictionary(kUserId3, &managed_user));
- ASSERT_TRUE(managed_user);
+ const base::DictionaryValue* supervised_user = NULL;
+ ASSERT_TRUE(supervised_users->GetDictionary(kUserId3, &supervised_user));
+ ASSERT_TRUE(supervised_user);
std::string name;
- EXPECT_TRUE(managed_user->GetString(kNameKey, &name));
+ EXPECT_TRUE(supervised_user->GetString(kNameKey, &name));
EXPECT_EQ(kName3, name);
bool acknowledged = false;
- EXPECT_TRUE(managed_user->GetBoolean(kAcknowledgedKey, &acknowledged));
+ EXPECT_TRUE(supervised_user->GetBoolean(kAcknowledgedKey, &acknowledged));
EXPECT_TRUE(acknowledged);
std::string avatar;
- EXPECT_TRUE(managed_user->GetString(kChromeAvatarKey, &avatar));
+ EXPECT_TRUE(supervised_user->GetString(kChromeAvatarKey, &avatar));
EXPECT_EQ(kAvatar3, avatar);
}
{
- const base::DictionaryValue* managed_user = NULL;
- ASSERT_TRUE(managed_users->GetDictionary(kUserId4, &managed_user));
- ASSERT_TRUE(managed_user);
+ const base::DictionaryValue* supervised_user = NULL;
+ ASSERT_TRUE(supervised_users->GetDictionary(kUserId4, &supervised_user));
+ ASSERT_TRUE(supervised_user);
std::string name;
- EXPECT_TRUE(managed_user->GetString(kNameKey, &name));
+ EXPECT_TRUE(supervised_user->GetString(kNameKey, &name));
EXPECT_EQ(kName4, name);
bool acknowledged = false;
- EXPECT_TRUE(managed_user->GetBoolean(kAcknowledgedKey, &acknowledged));
+ EXPECT_TRUE(supervised_user->GetBoolean(kAcknowledgedKey, &acknowledged));
EXPECT_TRUE(acknowledged);
std::string avatar;
- EXPECT_TRUE(managed_user->GetString(kChromeAvatarKey, &avatar));
+ EXPECT_TRUE(supervised_user->GetString(kChromeAvatarKey, &avatar));
EXPECT_EQ(kAvatar4, avatar);
}
@@ -278,25 +279,26 @@ TEST_F(ManagedUserSyncServiceTest, MergeExisting) {
SyncChange change = change_processor()->GetChange(kUserId1);
ASSERT_TRUE(change.IsValid());
EXPECT_EQ(SyncChange::ACTION_ADD, change.change_type());
- const ManagedUserSpecifics& managed_user =
+ const ManagedUserSpecifics& supervised_user =
change.sync_data().GetSpecifics().managed_user();
- EXPECT_EQ(kName1, managed_user.name());
- EXPECT_FALSE(managed_user.acknowledged());
- EXPECT_EQ(kAvatar1, managed_user.chrome_avatar());
+ EXPECT_EQ(kName1, supervised_user.name());
+ EXPECT_FALSE(supervised_user.acknowledged());
+ EXPECT_EQ(kAvatar1, supervised_user.chrome_avatar());
}
}
-TEST_F(ManagedUserSyncServiceTest, GetAvatarIndex) {
+TEST_F(SupervisedUserSyncServiceTest, GetAvatarIndex) {
int avatar = 100;
- EXPECT_TRUE(ManagedUserSyncService::GetAvatarIndex(std::string(), &avatar));
- EXPECT_EQ(ManagedUserSyncService::kNoAvatar, avatar);
+ EXPECT_TRUE(SupervisedUserSyncService::GetAvatarIndex(std::string(),
+ &avatar));
+ EXPECT_EQ(SupervisedUserSyncService::kNoAvatar, avatar);
int avatar_index = 4;
#if defined(OS_CHROMEOS)
avatar_index += chromeos::kFirstDefaultImageIndex;
#endif
std::string avatar_str =
- ManagedUserSyncService::BuildAvatarString(avatar_index);
+ SupervisedUserSyncService::BuildAvatarString(avatar_index);
#if defined(OS_CHROMEOS)
EXPECT_EQ(base::StringPrintf("chromeos-avatar-index:%d", avatar_index),
avatar_str);
@@ -304,14 +306,14 @@ TEST_F(ManagedUserSyncServiceTest, GetAvatarIndex) {
EXPECT_EQ(base::StringPrintf("chrome-avatar-index:%d", avatar_index),
avatar_str);
#endif
- EXPECT_TRUE(ManagedUserSyncService::GetAvatarIndex(avatar_str, &avatar));
+ EXPECT_TRUE(SupervisedUserSyncService::GetAvatarIndex(avatar_str, &avatar));
EXPECT_EQ(avatar_index, avatar);
avatar_index = 0;
#if defined(OS_CHROMEOS)
avatar_index += chromeos::kFirstDefaultImageIndex;
#endif
- avatar_str = ManagedUserSyncService::BuildAvatarString(avatar_index);
+ avatar_str = SupervisedUserSyncService::BuildAvatarString(avatar_index);
#if defined(OS_CHROMEOS)
EXPECT_EQ(base::StringPrintf("chromeos-avatar-index:%d", avatar_index),
avatar_str);
@@ -319,41 +321,50 @@ TEST_F(ManagedUserSyncServiceTest, GetAvatarIndex) {
EXPECT_EQ(base::StringPrintf("chrome-avatar-index:%d", avatar_index),
avatar_str);
#endif
- EXPECT_TRUE(ManagedUserSyncService::GetAvatarIndex(avatar_str, &avatar));
+ EXPECT_TRUE(SupervisedUserSyncService::GetAvatarIndex(avatar_str, &avatar));
EXPECT_EQ(avatar_index, avatar);
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("wrong-prefix:5",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex("wrong-prefix:5",
+ &avatar));
#if defined(OS_CHROMEOS)
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chromeos-avatar-indes:2",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
+ "chromeos-avatar-indes:2",
+ &avatar));
EXPECT_FALSE(
- ManagedUserSyncService::GetAvatarIndex("chromeos-avatar-indexxx:2",
- &avatar));
+ SupervisedUserSyncService::GetAvatarIndex("chromeos-avatar-indexxx:2",
+ &avatar));
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chromeos-avatar-index:",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
+ "chromeos-avatar-index:",
+ &avatar));
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chromeos-avatar-index:x",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
+ "chromeos-avatar-index:x",
+ &avatar));
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chrome-avatar-index:5",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
+ "chrome-avatar-index:5",
+ &avatar));
#else
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chrome-avatar-indes:2",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
+ "chrome-avatar-indes:2",
+ &avatar));
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chrome-avatar-indexxx:2",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
+ "chrome-avatar-indexxx:2",
+ &avatar));
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chrome-avatar-index:",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
+ "chrome-avatar-index:",
+ &avatar));
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chrome-avatar-index:x",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
+ "chrome-avatar-index:x",
+ &avatar));
- EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chromeos-avatar-index:5",
- &avatar));
+ EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
+ "chromeos-avatar-index:5",
+ &avatar));
#endif
}
diff --git a/chrome/browser/managed_mode/managed_user_theme.cc b/chrome/browser/supervised_user/supervised_user_theme.cc
index 42ee844..e507673 100644
--- a/chrome/browser/managed_mode/managed_user_theme.cc
+++ b/chrome/browser/supervised_user/supervised_user_theme.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_user_theme.h"
+#include "chrome/browser/supervised_user/supervised_user_theme.h"
#include "chrome/browser/themes/theme_properties.h"
#include "grit/theme_resources.h"
@@ -11,14 +11,14 @@
namespace {
-const SkColor kDefaultColorFrameManagedUser = SkColorSetRGB(165, 197, 225);
-const SkColor kDefaultColorFrameManagedUserInactive =
+const SkColor kDefaultColorFrameSupervisedUser = SkColorSetRGB(165, 197, 225);
+const SkColor kDefaultColorFrameSupervisedUserInactive =
SkColorSetRGB(180, 225, 247);
-const SkColor kDefaultColorManagedUserLabelBackground =
+const SkColor kDefaultColorSupervisedUserLabelBackground =
SkColorSetRGB(108, 167, 210);
-// Map resource ids to the managed user resource ids.
-int MapToManagedUserResourceIds(int id) {
+// Map resource ids to the supervised user resource ids.
+int MapToSupervisedUserResourceIds(int id) {
switch (id) {
case IDR_THEME_FRAME:
#if defined(USE_ASH) && !defined(OS_CHROMEOS)
@@ -42,37 +42,37 @@ int MapToManagedUserResourceIds(int id) {
} // namespace
-ManagedUserTheme::ManagedUserTheme()
+SupervisedUserTheme::SupervisedUserTheme()
: CustomThemeSupplier(SUPERVISED_USER_THEME) {}
-ManagedUserTheme::~ManagedUserTheme() {}
+SupervisedUserTheme::~SupervisedUserTheme() {}
-bool ManagedUserTheme::GetColor(int id, SkColor* color) const {
+bool SupervisedUserTheme::GetColor(int id, SkColor* color) const {
switch (id) {
case ThemeProperties::COLOR_FRAME:
- *color = kDefaultColorFrameManagedUser;
+ *color = kDefaultColorFrameSupervisedUser;
return true;
case ThemeProperties::COLOR_FRAME_INACTIVE:
- *color = kDefaultColorFrameManagedUserInactive;
+ *color = kDefaultColorFrameSupervisedUserInactive;
return true;
case ThemeProperties::COLOR_SUPERVISED_USER_LABEL:
*color = SK_ColorWHITE;
return true;
case ThemeProperties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND:
- *color = kDefaultColorManagedUserLabelBackground;
+ *color = kDefaultColorSupervisedUserLabelBackground;
return true;
}
return false;
}
-gfx::Image ManagedUserTheme::GetImageNamed(int id) {
+gfx::Image SupervisedUserTheme::GetImageNamed(int id) {
if (!HasCustomImage(id))
return gfx::Image();
- id = MapToManagedUserResourceIds(id);
+ id = MapToSupervisedUserResourceIds(id);
return ResourceBundle::GetSharedInstance().GetNativeImageNamed(id);
}
-bool ManagedUserTheme::HasCustomImage(int id) const {
- return id != MapToManagedUserResourceIds(id);
+bool SupervisedUserTheme::HasCustomImage(int id) const {
+ return id != MapToSupervisedUserResourceIds(id);
}
diff --git a/chrome/browser/managed_mode/managed_user_theme.h b/chrome/browser/supervised_user/supervised_user_theme.h
index e23995c..dc11d6f 100644
--- a/chrome/browser/managed_mode/managed_user_theme.h
+++ b/chrome/browser/supervised_user/supervised_user_theme.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_THEME_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_THEME_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_THEME_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_THEME_H_
#include "chrome/browser/themes/custom_theme_supplier.h"
@@ -13,9 +13,9 @@ class Image;
// This theme is used as a default theme for supervised users. It uses a light
// blue as frame color, and defines color properties for the avatar label.
-class ManagedUserTheme : public CustomThemeSupplier {
+class SupervisedUserTheme : public CustomThemeSupplier {
public:
- ManagedUserTheme();
+ SupervisedUserTheme();
// Overridden from CustomThemeSupplier:
virtual bool GetColor(int id, SkColor* color) const OVERRIDE;
@@ -23,9 +23,9 @@ class ManagedUserTheme : public CustomThemeSupplier {
virtual bool HasCustomImage(int id) const OVERRIDE;
private:
- virtual ~ManagedUserTheme();
+ virtual ~SupervisedUserTheme();
- DISALLOW_COPY_AND_ASSIGN(ManagedUserTheme);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserTheme);
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_THEME_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_THEME_H_
diff --git a/chrome/browser/managed_mode/managed_mode_url_filter.cc b/chrome/browser/supervised_user/supervised_user_url_filter.cc
index efd9645..b1a98f1 100644
--- a/chrome/browser/managed_mode/managed_mode_url_filter.cc
+++ b/chrome/browser/supervised_user/supervised_user_url_filter.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "base/containers/hash_tables.h"
#include "base/files/file_path.h"
@@ -28,11 +28,11 @@ using policy::URLBlacklist;
using url_matcher::URLMatcher;
using url_matcher::URLMatcherConditionSet;
-struct ManagedModeURLFilter::Contents {
+struct SupervisedUserURLFilter::Contents {
URLMatcher url_matcher;
std::map<URLMatcherConditionSet::ID, int> matcher_site_map;
base::hash_multimap<std::string, int> hash_site_map;
- std::vector<ManagedModeSiteList::Site> sites;
+ std::vector<SupervisedUserSiteList::Site> sites;
};
namespace {
@@ -50,7 +50,7 @@ const char* kFilteredSchemes[] = {
// This class encapsulates all the state that is required during construction of
-// a new ManagedModeURLFilter::Contents.
+// a new SupervisedUserURLFilter::Contents.
class FilterBuilder {
public:
FilterBuilder();
@@ -63,20 +63,20 @@ class FilterBuilder {
void AddHostnameHash(const std::string& hash, int site_id);
// Adds all the sites in |site_list|, with URL patterns and hostname hashes.
- void AddSiteList(ManagedModeSiteList* site_list);
+ void AddSiteList(SupervisedUserSiteList* site_list);
- // Finalizes construction of the ManagedModeURLFilter::Contents and returns
+ // Finalizes construction of the SupervisedUserURLFilter::Contents and returns
// them. This method should be called before this object is destroyed.
- scoped_ptr<ManagedModeURLFilter::Contents> Build();
+ scoped_ptr<SupervisedUserURLFilter::Contents> Build();
private:
- scoped_ptr<ManagedModeURLFilter::Contents> contents_;
+ scoped_ptr<SupervisedUserURLFilter::Contents> contents_;
URLMatcherConditionSet::Vector all_conditions_;
URLMatcherConditionSet::ID matcher_id_;
};
FilterBuilder::FilterBuilder()
- : contents_(new ManagedModeURLFilter::Contents()),
+ : contents_(new SupervisedUserURLFilter::Contents()),
matcher_id_(0) {}
FilterBuilder::~FilterBuilder() {
@@ -114,13 +114,13 @@ void FilterBuilder::AddHostnameHash(const std::string& hash, int site_id) {
site_id));
}
-void FilterBuilder::AddSiteList(ManagedModeSiteList* site_list) {
- std::vector<ManagedModeSiteList::Site> sites;
+void FilterBuilder::AddSiteList(SupervisedUserSiteList* site_list) {
+ std::vector<SupervisedUserSiteList::Site> sites;
site_list->GetSites(&sites);
int site_id = contents_->sites.size();
- for (std::vector<ManagedModeSiteList::Site>::const_iterator it =
+ for (std::vector<SupervisedUserSiteList::Site>::const_iterator it =
sites.begin(); it != sites.end(); ++it) {
- const ManagedModeSiteList::Site& site = *it;
+ const SupervisedUserSiteList::Site& site = *it;
contents_->sites.push_back(site);
for (std::vector<std::string>::const_iterator pattern_it =
@@ -139,13 +139,13 @@ void FilterBuilder::AddSiteList(ManagedModeSiteList* site_list) {
}
}
-scoped_ptr<ManagedModeURLFilter::Contents> FilterBuilder::Build() {
+scoped_ptr<SupervisedUserURLFilter::Contents> FilterBuilder::Build() {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
contents_->url_matcher.AddConditionSets(all_conditions_);
return contents_.Pass();
}
-scoped_ptr<ManagedModeURLFilter::Contents> CreateWhitelistFromPatterns(
+scoped_ptr<SupervisedUserURLFilter::Contents> CreateWhitelistFromPatterns(
const std::vector<std::string>& patterns) {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
@@ -159,12 +159,13 @@ scoped_ptr<ManagedModeURLFilter::Contents> CreateWhitelistFromPatterns(
return builder.Build();
}
-scoped_ptr<ManagedModeURLFilter::Contents> LoadWhitelistsOnBlockingPoolThread(
- ScopedVector<ManagedModeSiteList> site_lists) {
+scoped_ptr<SupervisedUserURLFilter::Contents>
+LoadWhitelistsOnBlockingPoolThread(
+ ScopedVector<SupervisedUserSiteList> site_lists) {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
FilterBuilder builder;
- for (ScopedVector<ManagedModeSiteList>::iterator it = site_lists.begin();
+ for (ScopedVector<SupervisedUserSiteList>::iterator it = site_lists.begin();
it != site_lists.end(); ++it) {
builder.AddSiteList(*it);
}
@@ -174,7 +175,7 @@ scoped_ptr<ManagedModeURLFilter::Contents> LoadWhitelistsOnBlockingPoolThread(
} // namespace
-ManagedModeURLFilter::ManagedModeURLFilter()
+SupervisedUserURLFilter::SupervisedUserURLFilter()
: default_behavior_(ALLOW),
contents_(new Contents()) {
// Detach from the current thread so we can be constructed on a different
@@ -182,20 +183,20 @@ ManagedModeURLFilter::ManagedModeURLFilter()
DetachFromThread();
}
-ManagedModeURLFilter::~ManagedModeURLFilter() {
+SupervisedUserURLFilter::~SupervisedUserURLFilter() {
DCHECK(CalledOnValidThread());
}
// static
-ManagedModeURLFilter::FilteringBehavior
-ManagedModeURLFilter::BehaviorFromInt(int behavior_value) {
+SupervisedUserURLFilter::FilteringBehavior
+SupervisedUserURLFilter::BehaviorFromInt(int behavior_value) {
DCHECK_GE(behavior_value, ALLOW);
DCHECK_LE(behavior_value, BLOCK);
return static_cast<FilteringBehavior>(behavior_value);
}
// static
-GURL ManagedModeURLFilter::Normalize(const GURL& url) {
+GURL SupervisedUserURLFilter::Normalize(const GURL& url) {
GURL normalized_url = url;
GURL::Replacements replacements;
// Strip username, password, query, and ref.
@@ -207,7 +208,7 @@ GURL ManagedModeURLFilter::Normalize(const GURL& url) {
}
// static
-bool ManagedModeURLFilter::HasFilteredScheme(const GURL& url) {
+bool SupervisedUserURLFilter::HasFilteredScheme(const GURL& url) {
for (size_t i = 0; i < arraysize(kFilteredSchemes); ++i) {
if (url.scheme() == kFilteredSchemes[i])
return true;
@@ -221,8 +222,8 @@ std::string GetHostnameHash(const GURL& url) {
}
// static
-bool ManagedModeURLFilter::HostMatchesPattern(const std::string& host,
- const std::string& pattern) {
+bool SupervisedUserURLFilter::HostMatchesPattern(const std::string& host,
+ const std::string& pattern) {
std::string trimmed_pattern = pattern;
std::string trimmed_host = host;
if (EndsWith(pattern, ".*", true)) {
@@ -258,8 +259,8 @@ bool ManagedModeURLFilter::HostMatchesPattern(const std::string& host,
return trimmed_host == trimmed_pattern;
}
-ManagedModeURLFilter::FilteringBehavior
-ManagedModeURLFilter::GetFilteringBehaviorForURL(const GURL& url) const {
+SupervisedUserURLFilter::FilteringBehavior
+SupervisedUserURLFilter::GetFilteringBehaviorForURL(const GURL& url) const {
DCHECK(CalledOnValidThread());
// URLs with a non-standard scheme (e.g. chrome://) are always allowed.
@@ -305,9 +306,9 @@ ManagedModeURLFilter::GetFilteringBehaviorForURL(const GURL& url) const {
return default_behavior_;
}
-void ManagedModeURLFilter::GetSites(
+void SupervisedUserURLFilter::GetSites(
const GURL& url,
- std::vector<ManagedModeSiteList::Site*>* sites) const {
+ std::vector<SupervisedUserSiteList::Site*>* sites) const {
std::set<URLMatcherConditionSet::ID> matching_ids =
contents_->url_matcher.MatchURL(url);
for (std::set<URLMatcherConditionSet::ID>::const_iterator it =
@@ -331,14 +332,14 @@ void ManagedModeURLFilter::GetSites(
}
}
-void ManagedModeURLFilter::SetDefaultFilteringBehavior(
+void SupervisedUserURLFilter::SetDefaultFilteringBehavior(
FilteringBehavior behavior) {
DCHECK(CalledOnValidThread());
default_behavior_ = behavior;
}
-void ManagedModeURLFilter::LoadWhitelists(
- ScopedVector<ManagedModeSiteList> site_lists) {
+void SupervisedUserURLFilter::LoadWhitelists(
+ ScopedVector<SupervisedUserSiteList> site_lists) {
DCHECK(CalledOnValidThread());
base::PostTaskAndReplyWithResult(
@@ -346,10 +347,10 @@ void ManagedModeURLFilter::LoadWhitelists(
FROM_HERE,
base::Bind(&LoadWhitelistsOnBlockingPoolThread,
base::Passed(&site_lists)),
- base::Bind(&ManagedModeURLFilter::SetContents, this));
+ base::Bind(&SupervisedUserURLFilter::SetContents, this));
}
-void ManagedModeURLFilter::SetFromPatterns(
+void SupervisedUserURLFilter::SetFromPatterns(
const std::vector<std::string>& patterns) {
DCHECK(CalledOnValidThread());
@@ -357,10 +358,10 @@ void ManagedModeURLFilter::SetFromPatterns(
BrowserThread::GetBlockingPool(),
FROM_HERE,
base::Bind(&CreateWhitelistFromPatterns, patterns),
- base::Bind(&ManagedModeURLFilter::SetContents, this));
+ base::Bind(&SupervisedUserURLFilter::SetContents, this));
}
-void ManagedModeURLFilter::SetManualHosts(
+void SupervisedUserURLFilter::SetManualHosts(
const std::map<std::string, bool>* host_map) {
DCHECK(CalledOnValidThread());
host_map_ = *host_map;
@@ -368,7 +369,7 @@ void ManagedModeURLFilter::SetManualHosts(
host_map->size(), 1, 1000, 50);
}
-void ManagedModeURLFilter::SetManualURLs(
+void SupervisedUserURLFilter::SetManualURLs(
const std::map<GURL, bool>* url_map) {
DCHECK(CalledOnValidThread());
url_map_ = *url_map;
@@ -376,15 +377,15 @@ void ManagedModeURLFilter::SetManualURLs(
url_map->size(), 1, 1000, 50);
}
-void ManagedModeURLFilter::AddObserver(Observer* observer) {
+void SupervisedUserURLFilter::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
-void ManagedModeURLFilter::RemoveObserver(Observer* observer) {
+void SupervisedUserURLFilter::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
-void ManagedModeURLFilter::SetContents(scoped_ptr<Contents> contents) {
+void SupervisedUserURLFilter::SetContents(scoped_ptr<Contents> contents) {
DCHECK(CalledOnValidThread());
contents_ = contents.Pass();
FOR_EACH_OBSERVER(Observer, observers_, OnSiteListUpdated());
diff --git a/chrome/browser/managed_mode/managed_mode_url_filter.h b/chrome/browser/supervised_user/supervised_user_url_filter.h
index c43326a..64ef42b 100644
--- a/chrome/browser/managed_mode/managed_mode_url_filter.h
+++ b/chrome/browser/supervised_user/supervised_user_url_filter.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_URL_FILTER_H_
-#define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_URL_FILTER_H_
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_URL_FILTER_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_URL_FILTER_H_
#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
@@ -12,8 +12,8 @@
#include "base/observer_list.h"
#include "base/threading/non_thread_safe.h"
#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_mode_site_list.h"
-#include "chrome/browser/managed_mode/managed_users.h"
+#include "chrome/browser/supervised_user/supervised_user_site_list.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
class GURL;
@@ -29,8 +29,8 @@ class GURL;
// References to it can be passed around on different threads (the refcounting
// is thread-safe), but the object itself should always be accessed on the same
// thread (member access isn't thread-safe).
-class ManagedModeURLFilter
- : public base::RefCountedThreadSafe<ManagedModeURLFilter>,
+class SupervisedUserURLFilter
+ : public base::RefCountedThreadSafe<SupervisedUserURLFilter>,
public base::NonThreadSafe {
public:
enum FilteringBehavior {
@@ -47,7 +47,7 @@ class ManagedModeURLFilter
struct Contents;
- ManagedModeURLFilter();
+ SupervisedUserURLFilter();
static FilteringBehavior BehaviorFromInt(int behavior_value);
@@ -66,7 +66,7 @@ class ManagedModeURLFilter
// or accounts.google.com).
// - If the pattern ends with ".*", it matches the host on any known TLD
// (e.g. the pattern "google.*" would match google.com or google.co.uk).
- // See the ManagedModeURLFilterTest.HostMatchesPattern unit test for more
+ // See the SupervisedUserURLFilterTest.HostMatchesPattern unit test for more
// examples.
// Asterisks in other parts of the pattern are not allowed.
// |host| and |pattern| are assumed to be normalized to lower-case.
@@ -75,7 +75,7 @@ class ManagedModeURLFilter
const std::string& pattern);
void GetSites(const GURL& url,
- std::vector<ManagedModeSiteList::Site*>* sites) const;
+ std::vector<SupervisedUserSiteList::Site*>* sites) const;
// Returns the filtering behavior for a given URL, based on the default
// behavior and whether it is on a site list.
@@ -87,7 +87,7 @@ class ManagedModeURLFilter
// Asynchronously loads the specified site lists from disk and updates the
// filter to recognize each site on them.
// Calls |continuation| when the filter has been updated.
- void LoadWhitelists(ScopedVector<ManagedModeSiteList> site_lists);
+ void LoadWhitelists(ScopedVector<SupervisedUserSiteList> site_lists);
// Set the list of matched patterns to the passed in list.
// This method is only used for testing.
@@ -103,8 +103,8 @@ class ManagedModeURLFilter
void RemoveObserver(Observer* observer);
private:
- friend class base::RefCountedThreadSafe<ManagedModeURLFilter>;
- ~ManagedModeURLFilter();
+ friend class base::RefCountedThreadSafe<SupervisedUserURLFilter>;
+ ~SupervisedUserURLFilter();
void SetContents(scoped_ptr<Contents> url_matcher);
@@ -121,7 +121,7 @@ class ManagedModeURLFilter
// (false).
std::map<std::string, bool> host_map_;
- DISALLOW_COPY_AND_ASSIGN(ManagedModeURLFilter);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserURLFilter);
};
-#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_URL_FILTER_H_
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_URL_FILTER_H_
diff --git a/chrome/browser/managed_mode/managed_mode_url_filter_unittest.cc b/chrome/browser/supervised_user/supervised_user_url_filter_unittest.cc
index e1091e4..f62f3ac 100644
--- a/chrome/browser/managed_mode/managed_mode_url_filter_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_url_filter_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,23 +6,23 @@
#include "base/bind_helpers.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
-class ManagedModeURLFilterTest : public ::testing::Test,
- public ManagedModeURLFilter::Observer {
+class SupervisedUserURLFilterTest : public ::testing::Test,
+ public SupervisedUserURLFilter::Observer {
public:
- ManagedModeURLFilterTest() : filter_(new ManagedModeURLFilter) {
- filter_->SetDefaultFilteringBehavior(ManagedModeURLFilter::BLOCK);
+ SupervisedUserURLFilterTest() : filter_(new SupervisedUserURLFilter) {
+ filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::BLOCK);
filter_->AddObserver(this);
}
- virtual ~ManagedModeURLFilterTest() {
+ virtual ~SupervisedUserURLFilterTest() {
filter_->RemoveObserver(this);
}
- // ManagedModeURLFilter::Observer:
+ // SupervisedUserURLFilter::Observer:
virtual void OnSiteListUpdated() OVERRIDE {
run_loop_.Quit();
}
@@ -30,15 +30,15 @@ class ManagedModeURLFilterTest : public ::testing::Test,
protected:
bool IsURLWhitelisted(const std::string& url) {
return filter_->GetFilteringBehaviorForURL(GURL(url)) ==
- ManagedModeURLFilter::ALLOW;
+ SupervisedUserURLFilter::ALLOW;
}
base::MessageLoop message_loop_;
base::RunLoop run_loop_;
- scoped_refptr<ManagedModeURLFilter> filter_;
+ scoped_refptr<SupervisedUserURLFilter> filter_;
};
-TEST_F(ManagedModeURLFilterTest, Basic) {
+TEST_F(SupervisedUserURLFilterTest, Basic) {
std::vector<std::string> list;
// Allow domain and all subdomains, for any filtered scheme.
list.push_back("google.com");
@@ -63,8 +63,8 @@ TEST_F(ManagedModeURLFilterTest, Basic) {
EXPECT_TRUE(IsURLWhitelisted("file:///home/chronos/user/Downloads/img.jpg"));
}
-TEST_F(ManagedModeURLFilterTest, Inactive) {
- filter_->SetDefaultFilteringBehavior(ManagedModeURLFilter::ALLOW);
+TEST_F(SupervisedUserURLFilterTest, Inactive) {
+ filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::ALLOW);
std::vector<std::string> list;
list.push_back("google.com");
@@ -76,7 +76,7 @@ TEST_F(ManagedModeURLFilterTest, Inactive) {
EXPECT_TRUE(IsURLWhitelisted("https://www.example.com"));
}
-TEST_F(ManagedModeURLFilterTest, Scheme) {
+TEST_F(SupervisedUserURLFilterTest, Scheme) {
std::vector<std::string> list;
// Filter only http, ftp and ws schemes.
list.push_back("http://secure.com");
@@ -96,7 +96,7 @@ TEST_F(ManagedModeURLFilterTest, Scheme) {
EXPECT_FALSE(IsURLWhitelisted("wss://www.secure.com"));
}
-TEST_F(ManagedModeURLFilterTest, Path) {
+TEST_F(SupervisedUserURLFilterTest, Path) {
std::vector<std::string> list;
// Filter only a certain path prefix.
list.push_back("path.to/ruin");
@@ -111,7 +111,7 @@ TEST_F(ManagedModeURLFilterTest, Path) {
EXPECT_FALSE(IsURLWhitelisted("http://path.to/fortune"));
}
-TEST_F(ManagedModeURLFilterTest, PathAndScheme) {
+TEST_F(SupervisedUserURLFilterTest, PathAndScheme) {
std::vector<std::string> list;
// Filter only a certain path prefix and scheme.
list.push_back("https://s.aaa.com/path");
@@ -127,7 +127,7 @@ TEST_F(ManagedModeURLFilterTest, PathAndScheme) {
EXPECT_FALSE(IsURLWhitelisted("https://s.aaa.com/"));
}
-TEST_F(ManagedModeURLFilterTest, Host) {
+TEST_F(SupervisedUserURLFilterTest, Host) {
std::vector<std::string> list;
// Filter only a certain hostname, without subdomains.
list.push_back(".www.example.com");
@@ -139,7 +139,7 @@ TEST_F(ManagedModeURLFilterTest, Host) {
EXPECT_FALSE(IsURLWhitelisted("http://subdomain.example.com"));
}
-TEST_F(ManagedModeURLFilterTest, IPAddress) {
+TEST_F(SupervisedUserURLFilterTest, IPAddress) {
std::vector<std::string> list;
// Filter an ip address.
list.push_back("123.123.123.123");
@@ -150,7 +150,7 @@ TEST_F(ManagedModeURLFilterTest, IPAddress) {
EXPECT_FALSE(IsURLWhitelisted("http://123.123.123.124/"));
}
-TEST_F(ManagedModeURLFilterTest, Canonicalization) {
+TEST_F(SupervisedUserURLFilterTest, Canonicalization) {
// We assume that the hosts and URLs are already canonicalized.
std::map<std::string, bool> hosts;
hosts["www.moose.org"] = true;
@@ -187,129 +187,139 @@ TEST_F(ManagedModeURLFilterTest, Canonicalization) {
EXPECT_TRUE(IsURLWhitelisted("http://www.example.com/foo/?bar=baz#ref"));
}
-TEST_F(ManagedModeURLFilterTest, HasFilteredScheme) {
+TEST_F(SupervisedUserURLFilterTest, HasFilteredScheme) {
EXPECT_TRUE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("http://example.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("http://example.com")));
EXPECT_TRUE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("https://example.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("https://example.com")));
EXPECT_TRUE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("ftp://example.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("ftp://example.com")));
EXPECT_TRUE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("gopher://example.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("gopher://example.com")));
EXPECT_TRUE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("ws://example.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("ws://example.com")));
EXPECT_TRUE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("wss://example.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("wss://example.com")));
EXPECT_FALSE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("file://example.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("file://example.com")));
EXPECT_FALSE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("filesystem://80cols.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(
+ GURL("filesystem://80cols.com")));
EXPECT_FALSE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("chrome://example.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("chrome://example.com")));
EXPECT_FALSE(
- ManagedModeURLFilter::HasFilteredScheme(GURL("wtf://example.com")));
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("wtf://example.com")));
}
-TEST_F(ManagedModeURLFilterTest, HostMatchesPattern) {
+TEST_F(SupervisedUserURLFilterTest, HostMatchesPattern) {
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com",
- "*.google.com"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com",
+ "*.google.com"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("google.com", "*.google.com"));
+ SupervisedUserURLFilter::HostMatchesPattern("google.com",
+ "*.google.com"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("accounts.google.com",
- "*.google.com"));
+ SupervisedUserURLFilter::HostMatchesPattern("accounts.google.com",
+ "*.google.com"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.de",
- "*.google.com"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.de",
+ "*.google.com"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("notgoogle.com",
- "*.google.com"));
+ SupervisedUserURLFilter::HostMatchesPattern("notgoogle.com",
+ "*.google.com"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com",
- "www.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com",
+ "www.google.*"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.de",
- "www.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.de",
+ "www.google.*"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.co.uk",
- "www.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.co.uk",
+ "www.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.blogspot.com",
- "www.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.blogspot.com",
+ "www.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google", "www.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google",
+ "www.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("google.com", "www.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("google.com",
+ "www.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("mail.google.com",
- "www.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("mail.google.com",
+ "www.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.googleplex.com",
- "www.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.googleplex.com",
+ "www.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.googleco.uk",
- "www.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.googleco.uk",
+ "www.google.*"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com",
+ "*.google.*"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("google.com", "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("google.com",
+ "*.google.*"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("accounts.google.com",
- "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("accounts.google.com",
+ "*.google.*"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("mail.google.com",
- "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("mail.google.com",
+ "*.google.*"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.de",
- "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.de",
+ "*.google.*"));
EXPECT_TRUE(
- ManagedModeURLFilter::HostMatchesPattern("google.de",
- "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("google.de",
+ "*.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("google.blogspot.com",
- "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("google.blogspot.com",
+ "*.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("google", "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("google", "*.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("notgoogle.com", "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("notgoogle.com",
+ "*.google.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.googleplex.com",
- "*.google.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.googleplex.com",
+ "*.google.*"));
// Now test a few invalid patterns. They should never match.
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", ""));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", ""));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "."));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "."));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", ".*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", ".*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*."));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "*."));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "*.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google..com", "*..*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google..com", "*..*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*.*.com"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "*.*.com"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "www.*.*"));
- EXPECT_FALSE(ManagedModeURLFilter::HostMatchesPattern("www.google.com",
- "*.goo.*le.*"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "www.*.*"));
EXPECT_FALSE(
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*google*"));
- EXPECT_FALSE(ManagedModeURLFilter::HostMatchesPattern("www.google.com",
- "www.*.google.com"));
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com",
+ "*.goo.*le.*"));
+ EXPECT_FALSE(
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com",
+ "*google*"));
+ EXPECT_FALSE(
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com",
+ "www.*.google.com"));
}
-TEST_F(ManagedModeURLFilterTest, Patterns) {
+TEST_F(SupervisedUserURLFilterTest, Patterns) {
std::map<std::string, bool> hosts;
// Initally, the second rule is ignored because has the same value as the
@@ -328,7 +338,7 @@ TEST_F(ManagedModeURLFilterTest, Patterns) {
EXPECT_FALSE(IsURLWhitelisted("http://www.google.co.uk/blurp/"));
EXPECT_TRUE(IsURLWhitelisted("http://mail.google.com/moose/"));
- filter_->SetDefaultFilteringBehavior(ManagedModeURLFilter::ALLOW);
+ filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::ALLOW);
EXPECT_FALSE(IsURLWhitelisted("http://www.google.com/foo/"));
EXPECT_FALSE(IsURLWhitelisted("http://accounts.google.com/bar/"));
EXPECT_FALSE(IsURLWhitelisted("http://www.google.co.uk/blurp/"));
diff --git a/chrome/browser/supervised_user/supervised_users.h b/chrome/browser/supervised_user/supervised_users.h
new file mode 100644
index 0000000..b73e99b
--- /dev/null
+++ b/chrome/browser/supervised_user/supervised_users.h
@@ -0,0 +1,14 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USERS_H_
+#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USERS_H_
+
+// Compile-time check to make sure that we don't include supervised user source
+// files when ENABLE_MANAGED_USERS is not defined.
+#if !defined(ENABLE_MANAGED_USERS)
+#error "Supervised users aren't enabled."
+#endif
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USERS_H_
diff --git a/chrome/browser/sync/managed_user_signin_manager_wrapper.cc b/chrome/browser/sync/managed_user_signin_manager_wrapper.cc
index 8765418..13a8ce0 100644
--- a/chrome/browser/sync/managed_user_signin_manager_wrapper.cc
+++ b/chrome/browser/sync/managed_user_signin_manager_wrapper.cc
@@ -9,7 +9,7 @@
#include "google_apis/gaia/gaia_constants.h"
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
#endif
ManagedUserSigninManagerWrapper::ManagedUserSigninManagerWrapper(
@@ -28,7 +28,7 @@ std::string ManagedUserSigninManagerWrapper::GetEffectiveUsername() const {
const std::string& auth_username = original_->GetAuthenticatedUsername();
#if defined(ENABLE_MANAGED_USERS)
if (auth_username.empty() && profile_->IsSupervised())
- return managed_users::kManagedUserPseudoEmail;
+ return supervised_users::kSupervisedUserPseudoEmail;
#endif
return auth_username;
}
@@ -37,7 +37,7 @@ std::string ManagedUserSigninManagerWrapper::GetAccountIdToUse() const {
const std::string& auth_account = original_->GetAuthenticatedAccountId();
#if defined(ENABLE_MANAGED_USERS)
if (auth_account.empty() && profile_->IsSupervised())
- return managed_users::kManagedUserPseudoEmail;
+ return supervised_users::kSupervisedUserPseudoEmail;
#endif
return auth_account;
}
diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc
index 9624fe5..2d5cba9 100644
--- a/chrome/browser/sync/profile_sync_components_factory_impl.cc
+++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc
@@ -80,12 +80,12 @@
#endif
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#endif
#if defined(ENABLE_SPELLCHECK)
@@ -534,13 +534,13 @@ base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl::
}
#if defined(ENABLE_MANAGED_USERS)
case syncer::SUPERVISED_USER_SETTINGS:
- return ManagedUserSettingsServiceFactory::GetForProfile(profile_)->
+ return SupervisedUserSettingsServiceFactory::GetForProfile(profile_)->
AsWeakPtr();
case syncer::SUPERVISED_USERS:
- return ManagedUserSyncServiceFactory::GetForProfile(profile_)->
+ return SupervisedUserSyncServiceFactory::GetForProfile(profile_)->
AsWeakPtr();
case syncer::SUPERVISED_USER_SHARED_SETTINGS:
- return ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ return SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
profile_)->AsWeakPtr();
#endif
case syncer::ARTICLES: {
diff --git a/chrome/browser/sync/sessions/notification_service_sessions_router.cc b/chrome/browser/sync/sessions/notification_service_sessions_router.cc
index 8edbb38..35f58c0 100644
--- a/chrome/browser/sync/sessions/notification_service_sessions_router.cc
+++ b/chrome/browser/sync/sessions/notification_service_sessions_router.cc
@@ -21,8 +21,8 @@
#include "content/public/browser/web_contents.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"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#endif
using content::NavigationController;
@@ -57,9 +57,9 @@ NotificationServiceSessionsRouter::NotificationServiceSessionsRouter(
content::Source<Profile>(profile_));
#if defined(ENABLE_MANAGED_USERS)
if (profile_->IsSupervised()) {
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile_);
- managed_user_service->AddNavigationBlockedCallback(
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile_);
+ supervised_user_service->AddNavigationBlockedCallback(
base::Bind(&NotificationServiceSessionsRouter::OnNavigationBlocked,
weak_ptr_factory_.GetWeakPtr()));
}
diff --git a/chrome/browser/sync/test/integration/profile_sync_service_harness.cc b/chrome/browser/sync/test/integration/profile_sync_service_harness.cc
index d9125c4..092df7f 100644
--- a/chrome/browser/sync/test/integration/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/test/integration/profile_sync_service_harness.cc
@@ -33,7 +33,7 @@
#include "sync/internal_api/public/util/sync_string_conversions.h"
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
#endif
using syncer::sessions::SyncSessionSnapshot;
@@ -162,7 +162,7 @@ bool ProfileSyncServiceHarness::SetupSync(
#if defined(ENABLE_MANAGED_USERS)
std::string account_id = profile_->IsSupervised() ?
- managed_users::kManagedUserPseudoEmail : username_;
+ supervised_users::kSupervisedUserPseudoEmail : username_;
#else
std::string account_id = username_;
#endif
diff --git a/chrome/browser/sync/test/integration/single_client_managed_user_settings_sync_test.cc b/chrome/browser/sync/test/integration/single_client_managed_user_settings_sync_test.cc
index 6fad88b..5ac3cd0 100644
--- a/chrome/browser/sync/test/integration/single_client_managed_user_settings_sync_test.cc
+++ b/chrome/browser/sync/test/integration/single_client_managed_user_settings_sync_test.cc
@@ -5,21 +5,21 @@
#include "base/command_line.h"
#include "base/prefs/pref_service.h"
#include "base/values.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/common/chrome_switches.h"
-class SingleClientManagedUserSettingsSyncTest : public SyncTest {
+class SingleClientSupervisedUserSettingsSyncTest : public SyncTest {
public:
- SingleClientManagedUserSettingsSyncTest() : SyncTest(SINGLE_CLIENT) {}
+ SingleClientSupervisedUserSettingsSyncTest() : SyncTest(SINGLE_CLIENT) {}
- virtual ~SingleClientManagedUserSettingsSyncTest() {}
+ virtual ~SingleClientSupervisedUserSettingsSyncTest() {}
// SyncTest overrides:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
@@ -28,21 +28,23 @@ class SingleClientManagedUserSettingsSyncTest : public SyncTest {
}
};
-IN_PROC_BROWSER_TEST_F(SingleClientManagedUserSettingsSyncTest, Sanity) {
+IN_PROC_BROWSER_TEST_F(SingleClientSupervisedUserSettingsSyncTest, Sanity) {
ASSERT_TRUE(SetupClients());
for (int i = 0; i < num_clients(); ++i) {
Profile* profile = GetProfile(i);
- // Managed users are prohibited from signing into the browser. Currently
+ // Supervised users are prohibited from signing into the browser. Currently
// that means they're also unable to sync anything, so override that for
// this test.
- // TODO(pamg): Remove this override (and the managed user setting it
- // requires) once sync and signin are properly separated for managed users.
+ // TODO(pamg): Remove this override (and the supervised user setting it
+ // requires) once sync and signin are properly separated for supervised
+ // users.
// See http://crbug.com/239785.
- ManagedUserSettingsService* settings_service =
- ManagedUserSettingsServiceFactory::GetForProfile(profile);
+ SupervisedUserSettingsService* settings_service =
+ SupervisedUserSettingsServiceFactory::GetForProfile(profile);
scoped_ptr<base::Value> allow_signin(new base::FundamentalValue(true));
- settings_service->SetLocalSettingForTesting(managed_users::kSigninAllowed,
- allow_signin.Pass());
+ settings_service->SetLocalSettingForTesting(
+ supervised_users::kSigninAllowed,
+ allow_signin.Pass());
// The user should not be signed in.
std::string username;
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 8d6d003..c7650ac 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -13,8 +13,8 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/managed_mode/managed_user_theme.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_theme.h"
#include "chrome/browser/themes/browser_theme_pack.h"
#include "chrome/browser/themes/custom_theme_supplier.h"
#include "chrome/browser/themes/theme_properties.h"
@@ -586,7 +586,7 @@ bool ThemeService::IsSupervisedUser() const {
}
void ThemeService::SetSupervisedUserTheme() {
- SetCustomDefaultTheme(new ManagedUserTheme);
+ SetCustomDefaultTheme(new SupervisedUserTheme);
}
void ThemeService::OnInfobarDisplayed() {
diff --git a/chrome/browser/themes/theme_service_unittest.cc b/chrome/browser/themes/theme_service_unittest.cc
index 3238c10..85bf126 100644
--- a/chrome/browser/themes/theme_service_unittest.cc
+++ b/chrome/browser/themes/theme_service_unittest.cc
@@ -10,8 +10,8 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/browser/extensions/unpacked_installer.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/themes/custom_theme_supplier.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/common/chrome_paths.h"
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm b/chrome/browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm
index db4083b..49c0197 100644
--- a/chrome/browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm
@@ -8,8 +8,8 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
index 16fdb45f..821bfe6 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -15,15 +15,15 @@
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/infobars/infobar_service.h"
-#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_impl.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sessions/session_restore.h"
#include "chrome/browser/signin/signin_promo.h"
+#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.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 8e5c447..40f2d3a 100644
--- a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
+++ b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
@@ -15,7 +15,7 @@
#include "extensions/common/extension.h"
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
+#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
#endif
using content::NavigationEntry;
@@ -81,8 +81,8 @@ bool TabContentsSyncedTabDelegate::ProfileIsSupervised() const {
const std::vector<const content::NavigationEntry*>*
TabContentsSyncedTabDelegate::GetBlockedNavigations() const {
#if defined(ENABLE_MANAGED_USERS)
- ManagedModeNavigationObserver* navigation_observer =
- ManagedModeNavigationObserver::FromWebContents(web_contents_);
+ SupervisedUserNavigationObserver* navigation_observer =
+ SupervisedUserNavigationObserver::FromWebContents(web_contents_);
DCHECK(navigation_observer);
return navigation_observer->blocked_navigations();
#else
diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc
index ee5a729..811f959 100644
--- a/chrome/browser/ui/tab_helpers.cc
+++ b/chrome/browser/ui/tab_helpers.cc
@@ -64,7 +64,7 @@
#endif
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
+#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
#endif
#if defined(ENABLE_PRINTING)
@@ -176,7 +176,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
#endif
#if defined(ENABLE_MANAGED_USERS)
- ManagedModeNavigationObserver::CreateForWebContents(web_contents);
+ SupervisedUserNavigationObserver::CreateForWebContents(web_contents);
#endif
#if defined(ENABLE_PRINTING) && !defined(OS_ANDROID)
diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest.cc b/chrome/browser/ui/webui/downloads_ui_browsertest.cc
index 7531155..eafa460 100644
--- a/chrome/browser/ui/webui/downloads_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/downloads_ui_browsertest.cc
@@ -6,9 +6,9 @@
#include "base/command_line.h"
#include "base/prefs/pref_service.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
index 44cec5f..431361d 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -42,9 +42,9 @@
#include "chrome/browser/extensions/install_verifier.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/google/google_util.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/tab_contents/background_contents.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/extensions/application_launch.h"
diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc
index 604624c..12b3470 100644
--- a/chrome/browser/ui/webui/history_ui.cc
+++ b/chrome/browser/ui/webui/history_ui.cc
@@ -58,10 +58,10 @@
#include "ui/base/resource/resource_bundle.h"
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#endif
#if defined(OS_ANDROID)
@@ -311,7 +311,7 @@ void BrowsingHistoryHandler::HistoryEntry::SetUrlAndTitle(
scoped_ptr<base::DictionaryValue> BrowsingHistoryHandler::HistoryEntry::ToValue(
BookmarkModel* bookmark_model,
- ManagedUserService* managed_user_service,
+ SupervisedUserService* supervised_user_service,
const ProfileSyncService* sync_service) const {
scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
SetUrlAndTitle(result.get());
@@ -365,9 +365,9 @@ scoped_ptr<base::DictionaryValue> BrowsingHistoryHandler::HistoryEntry::ToValue(
result->SetString("deviceType", device_type);
#if defined(ENABLE_MANAGED_USERS)
- if (managed_user_service) {
- const ManagedModeURLFilter* url_filter =
- managed_user_service->GetURLFilterForUIThread();
+ if (supervised_user_service) {
+ const SupervisedUserURLFilter* url_filter =
+ supervised_user_service->GetURLFilterForUIThread();
int filtering_behavior =
url_filter->GetFilteringBehaviorForURL(url.GetWithEmptyPath());
result->SetInteger("hostFilteringBehavior", filtering_behavior);
@@ -709,10 +709,11 @@ void BrowsingHistoryHandler::MergeDuplicateResults(
void BrowsingHistoryHandler::ReturnResultsToFrontEnd() {
Profile* profile = Profile::FromWebUI(web_ui());
BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile);
- ManagedUserService* managed_user_service = NULL;
+ SupervisedUserService* supervised_user_service = NULL;
#if defined(ENABLE_MANAGED_USERS)
if (profile->IsSupervised())
- managed_user_service = ManagedUserServiceFactory::GetForProfile(profile);
+ supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile);
#endif
ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
@@ -741,7 +742,7 @@ void BrowsingHistoryHandler::ReturnResultsToFrontEnd() {
for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it =
query_results_.begin(); it != query_results_.end(); ++it) {
scoped_ptr<base::Value> value(
- it->ToValue(bookmark_model, managed_user_service, sync_service));
+ it->ToValue(bookmark_model, supervised_user_service, sync_service));
results_value.Append(value.release());
}
diff --git a/chrome/browser/ui/webui/history_ui.h b/chrome/browser/ui/webui/history_ui.h
index d11dbc1..bb3d147 100644
--- a/chrome/browser/ui/webui/history_ui.h
+++ b/chrome/browser/ui/webui/history_ui.h
@@ -20,8 +20,8 @@
#include "content/public/browser/web_ui_message_handler.h"
class BookmarkModel;
-class ManagedUserService;
class ProfileSyncService;
+class SupervisedUserService;
// The handler for Javascript messages related to the "history" view.
class BrowsingHistoryHandler : public content::WebUIMessageHandler,
@@ -53,7 +53,7 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
// Converts the entry to a DictionaryValue to be owned by the caller.
scoped_ptr<base::DictionaryValue> ToValue(
BookmarkModel* bookmark_model,
- ManagedUserService* managed_user_service,
+ SupervisedUserService* supervised_user_service,
const ProfileSyncService* sync_service) const;
// Comparison function for sorting HistoryEntries from newest to oldest.
diff --git a/chrome/browser/ui/webui/options/create_profile_handler.cc b/chrome/browser/ui/webui/options/create_profile_handler.cc
index 3d3cc3d..9bd2509 100644
--- a/chrome/browser/ui/webui/options/create_profile_handler.cc
+++ b/chrome/browser/ui/webui/options/create_profile_handler.cc
@@ -12,14 +12,14 @@
#include "base/value_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/managed_mode/managed_user_registration_utility.h"
-#include "chrome/browser/managed_mode/managed_user_service.h"
-#include "chrome/browser/managed_mode/managed_user_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/profiles/profiles_state.h"
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/options/options_handlers_helper.h"
@@ -97,7 +97,7 @@ void CreateProfileHandler::CreateProfile(const base::ListValue* args) {
if (supervised_user_id.empty()) {
profile_creation_type_ = SUPERVISED_PROFILE_CREATION;
supervised_user_id =
- ManagedUserRegistrationUtility::GenerateNewManagedUserId();
+ SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId();
// If sync is not yet fully initialized, the creation may take extra time,
// so show a message. Import doesn't wait for an acknowledgement, so it
@@ -193,14 +193,14 @@ void CreateProfileHandler::RegisterSupervisedUser(
DCHECK_EQ(profile_path_being_created_.value(),
new_profile->GetPath().value());
- ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(new_profile);
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(new_profile);
// Register the supervised user using the profile of the custodian.
- managed_user_registration_utility_ =
- ManagedUserRegistrationUtility::Create(Profile::FromWebUI(web_ui()));
- managed_user_service->RegisterAndInitSync(
- managed_user_registration_utility_.get(),
+ supervised_user_registration_utility_ =
+ SupervisedUserRegistrationUtility::Create(Profile::FromWebUI(web_ui()));
+ supervised_user_service->RegisterAndInitSync(
+ supervised_user_registration_utility_.get(),
Profile::FromWebUI(web_ui()),
supervised_user_id,
base::Bind(&CreateProfileHandler::OnSupervisedUserRegistered,
@@ -321,8 +321,8 @@ void CreateProfileHandler::CancelProfileRegistration(bool user_initiated) {
RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED);
}
- DCHECK(managed_user_registration_utility_.get());
- managed_user_registration_utility_.reset();
+ DCHECK(supervised_user_registration_utility_.get());
+ supervised_user_registration_utility_.reset();
DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
profile_creation_type_ = NO_CREATION_IN_PROGRESS;
@@ -414,7 +414,8 @@ bool CreateProfileHandler::IsValidExistingSupervisedUserId(
Profile* profile = Profile::FromWebUI(web_ui());
const base::DictionaryValue* dict =
- ManagedUserSyncServiceFactory::GetForProfile(profile)->GetManagedUsers();
+ SupervisedUserSyncServiceFactory::GetForProfile(profile)->
+ GetSupervisedUsers();
if (!dict->HasKey(existing_supervised_user_id))
return false;
diff --git a/chrome/browser/ui/webui/options/create_profile_handler.h b/chrome/browser/ui/webui/options/create_profile_handler.h
index e813b39..34942e9 100644
--- a/chrome/browser/ui/webui/options/create_profile_handler.h
+++ b/chrome/browser/ui/webui/options/create_profile_handler.h
@@ -19,7 +19,7 @@ class DictionaryValue;
class ListValue;
}
-class ManagedUserRegistrationUtility;
+class SupervisedUserRegistrationUtility;
namespace options {
@@ -150,7 +150,8 @@ class CreateProfileHandler: public OptionsPageUIHandler {
// Used to track how long profile creation takes.
base::TimeTicks profile_creation_start_time_;
- scoped_ptr<ManagedUserRegistrationUtility> managed_user_registration_utility_;
+ scoped_ptr<SupervisedUserRegistrationUtility>
+ supervised_user_registration_utility_;
// Indicates the type of the in progress profile creation operation.
// The value is only relevant while we are creating/importing a profile.
diff --git a/chrome/browser/ui/webui/options/managed_user_import_handler.cc b/chrome/browser/ui/webui/options/managed_user_import_handler.cc
index 34064e2..eaff762 100644
--- a/chrome/browser/ui/webui/options/managed_user_import_handler.cc
+++ b/chrome/browser/ui/webui/options/managed_user_import_handler.cc
@@ -10,17 +10,17 @@
#include "base/prefs/pref_service.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/managed_mode/managed_user_constants.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
-#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_constants.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
+#include "chrome/browser/supervised_user/supervised_user_shared_settings_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
@@ -54,8 +54,8 @@ ManagedUserImportHandler::ManagedUserImportHandler()
ManagedUserImportHandler::~ManagedUserImportHandler() {
Profile* profile = Profile::FromWebUI(web_ui());
if (!profile->IsSupervised()) {
- ManagedUserSyncService* service =
- ManagedUserSyncServiceFactory::GetForProfile(profile);
+ SupervisedUserSyncService* service =
+ SupervisedUserSyncServiceFactory::GetForProfile(profile);
if (service)
service->RemoveObserver(this);
subscription_.reset();
@@ -87,20 +87,20 @@ void ManagedUserImportHandler::GetLocalizedValues(
void ManagedUserImportHandler::InitializeHandler() {
Profile* profile = Profile::FromWebUI(web_ui());
if (!profile->IsSupervised()) {
- ManagedUserSyncService* sync_service =
- ManagedUserSyncServiceFactory::GetForProfile(profile);
+ SupervisedUserSyncService* sync_service =
+ SupervisedUserSyncServiceFactory::GetForProfile(profile);
if (sync_service) {
sync_service->AddObserver(this);
observer_.Add(ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
signin_error_controller());
- ManagedUserSharedSettingsService* settings_service =
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ SupervisedUserSharedSettingsService* settings_service =
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
profile);
subscription_ = settings_service->Subscribe(
base::Bind(&ManagedUserImportHandler::OnSharedSettingChanged,
weak_ptr_factory_.GetWeakPtr()));
} else {
- DCHECK(!ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
+ DCHECK(!SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
profile));
DCHECK(!ProfileOAuth2TokenServiceFactory::GetForProfile(profile));
}
@@ -113,7 +113,7 @@ void ManagedUserImportHandler::RegisterMessages() {
base::Unretained(this)));
}
-void ManagedUserImportHandler::OnManagedUsersChanged() {
+void ManagedUserImportHandler::OnSupervisedUsersChanged() {
FetchManagedUsers();
}
@@ -130,11 +130,11 @@ void ManagedUserImportHandler::RequestManagedUserImportUpdate(
if (!IsAccountConnected() || HasAuthError()) {
ClearManagedUsersAndShowError();
} else {
- ManagedUserSyncService* managed_user_sync_service =
- ManagedUserSyncServiceFactory::GetForProfile(
+ SupervisedUserSyncService* supervised_user_sync_service =
+ SupervisedUserSyncServiceFactory::GetForProfile(
Profile::FromWebUI(web_ui()));
- if (managed_user_sync_service) {
- managed_user_sync_service->GetManagedUsersAsync(
+ if (supervised_user_sync_service) {
+ supervised_user_sync_service->GetSupervisedUsersAsync(
base::Bind(&ManagedUserImportHandler::SendExistingManagedUsers,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -148,61 +148,62 @@ void ManagedUserImportHandler::SendExistingManagedUsers(
g_browser_process->profile_manager()->GetProfileInfoCache();
// Collect the ids of local supervised user profiles.
- std::set<std::string> managed_user_ids;
+ std::set<std::string> supervised_user_ids;
for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
if (cache.ProfileIsSupervisedAtIndex(i))
- managed_user_ids.insert(cache.GetSupervisedUserIdOfProfileAtIndex(i));
+ supervised_user_ids.insert(cache.GetSupervisedUserIdOfProfileAtIndex(i));
}
- base::ListValue managed_users;
+ base::ListValue supervised_users;
Profile* profile = Profile::FromWebUI(web_ui());
- ManagedUserSharedSettingsService* service =
- ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
+ SupervisedUserSharedSettingsService* service =
+ SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
const base::DictionaryValue* value = NULL;
bool success = it.value().GetAsDictionary(&value);
DCHECK(success);
std::string name;
- value->GetString(ManagedUserSyncService::kName, &name);
+ value->GetString(SupervisedUserSyncService::kName, &name);
- base::DictionaryValue* managed_user = new base::DictionaryValue;
- managed_user->SetString("id", it.key());
- managed_user->SetString("name", name);
+ base::DictionaryValue* supervised_user = new base::DictionaryValue;
+ supervised_user->SetString("id", it.key());
+ supervised_user->SetString("name", name);
- int avatar_index = ManagedUserSyncService::kNoAvatar;
+ int avatar_index = SupervisedUserSyncService::kNoAvatar;
const base::Value* avatar_index_value =
- service->GetValue(it.key(), managed_users::kChromeAvatarIndex);
+ service->GetValue(it.key(), supervised_users::kChromeAvatarIndex);
if (avatar_index_value) {
success = avatar_index_value->GetAsInteger(&avatar_index);
} else {
// Check if there is a legacy avatar index stored.
std::string avatar_str;
- value->GetString(ManagedUserSyncService::kChromeAvatar, &avatar_str);
+ value->GetString(SupervisedUserSyncService::kChromeAvatar, &avatar_str);
success =
- ManagedUserSyncService::GetAvatarIndex(avatar_str, &avatar_index);
+ SupervisedUserSyncService::GetAvatarIndex(avatar_str, &avatar_index);
}
DCHECK(success);
- managed_user->SetBoolean("needAvatar",
- avatar_index == ManagedUserSyncService::kNoAvatar);
+ supervised_user->SetBoolean(
+ "needAvatar",
+ avatar_index == SupervisedUserSyncService::kNoAvatar);
std::string supervised_user_icon =
std::string(chrome::kChromeUIThemeURL) +
"IDR_SUPERVISED_USER_PLACEHOLDER";
std::string avatar_url =
- avatar_index == ManagedUserSyncService::kNoAvatar ?
+ avatar_index == SupervisedUserSyncService::kNoAvatar ?
supervised_user_icon :
profiles::GetDefaultAvatarIconUrl(avatar_index);
- managed_user->SetString("iconURL", avatar_url);
+ supervised_user->SetString("iconURL", avatar_url);
bool on_current_device =
- managed_user_ids.find(it.key()) != managed_user_ids.end();
- managed_user->SetBoolean("onCurrentDevice", on_current_device);
+ supervised_user_ids.find(it.key()) != supervised_user_ids.end();
+ supervised_user->SetBoolean("onCurrentDevice", on_current_device);
- managed_users.Append(managed_user);
+ supervised_users.Append(supervised_user);
}
web_ui()->CallJavascriptFunction(
"options.ManagedUserListData.receiveExistingManagedUsers",
- managed_users);
+ supervised_users);
}
void ManagedUserImportHandler::ClearManagedUsersAndShowError() {
@@ -235,9 +236,9 @@ bool ManagedUserImportHandler::HasAuthError() const {
}
void ManagedUserImportHandler::OnSharedSettingChanged(
- const std::string& managed_user_id,
+ const std::string& supervised_user_id,
const std::string& key) {
- if (key == managed_users::kChromeAvatarIndex)
+ if (key == supervised_users::kChromeAvatarIndex)
FetchManagedUsers();
}
diff --git a/chrome/browser/ui/webui/options/managed_user_import_handler.h b/chrome/browser/ui/webui/options/managed_user_import_handler.h
index 2128a41f..52d129f 100644
--- a/chrome/browser/ui/webui/options/managed_user_import_handler.h
+++ b/chrome/browser/ui/webui/options/managed_user_import_handler.h
@@ -8,7 +8,7 @@
#include "base/callback_list.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
-#include "chrome/browser/managed_mode/managed_user_sync_service_observer.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_observer.h"
#include "chrome/browser/ui/webui/options/options_ui.h"
#include "components/signin/core/browser/signin_error_controller.h"
@@ -21,7 +21,7 @@ namespace options {
// Handler for the 'import existing managed user' dialog.
class ManagedUserImportHandler : public OptionsPageUIHandler,
- public ManagedUserSyncServiceObserver,
+ public SupervisedUserSyncServiceObserver,
public SigninErrorController::Observer {
public:
typedef base::CallbackList<void(const std::string&, const std::string&)>
@@ -38,11 +38,11 @@ class ManagedUserImportHandler : public OptionsPageUIHandler,
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
- // ManagedUserSyncServiceObserver implementation.
- virtual void OnManagedUserAcknowledged(const std::string& managed_user_id)
- OVERRIDE {}
- virtual void OnManagedUsersSyncingStopped() OVERRIDE {}
- virtual void OnManagedUsersChanged() OVERRIDE;
+ // SupervisedUserSyncServiceObserver implementation.
+ virtual void OnSupervisedUserAcknowledged(
+ const std::string& supervised_user_id) OVERRIDE {}
+ virtual void OnSupervisedUsersSyncingStopped() OVERRIDE {}
+ virtual void OnSupervisedUsersChanged() OVERRIDE;
// SigninErrorController::Observer implementation.
virtual void OnErrorChanged() OVERRIDE;
diff --git a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
index 7c5a4ca..6df51df 100644
--- a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
+++ b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
@@ -39,7 +39,7 @@
#include "ui/gfx/image/image_util.h"
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
#endif
namespace {