summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorakuegel@chromium.org <akuegel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-06 23:47:19 +0000
committerakuegel@chromium.org <akuegel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-06 23:47:19 +0000
commitf252df2e3c3cc046b4624d905a999b74111cf5bf (patch)
treecace77d393ee7251faa2f099b5ad0a59b58c7ec0 /chrome/browser
parent16465ec641d4332ae4265e81e96bce91460757d1 (diff)
downloadchromium_src-f252df2e3c3cc046b4624d905a999b74111cf5bf.zip
chromium_src-f252df2e3c3cc046b4624d905a999b74111cf5bf.tar.gz
chromium_src-f252df2e3c3cc046b4624d905a999b74111cf5bf.tar.bz2
Store the username of the custodian of the managed user.
To create a managed user, someone has to be signed in. We store the username immediately after the new managed profile has been created as a profile preference. BUG=241387 Review URL: https://chromiumcodereview.appspot.com/15907009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/invalidation/invalidator_storage.h1
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_service.h4
-rw-r--r--chrome/browser/managed_mode/managed_user_service.cc22
-rw-r--r--chrome/browser/managed_mode/managed_user_service.h6
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc17
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.h2
6 files changed, 32 insertions, 20 deletions
diff --git a/chrome/browser/invalidation/invalidator_storage.h b/chrome/browser/invalidation/invalidator_storage.h
index e8b7ba5..2e5f420 100644
--- a/chrome/browser/invalidation/invalidator_storage.h
+++ b/chrome/browser/invalidation/invalidator_storage.h
@@ -16,7 +16,6 @@
#include "sync/notifier/invalidation_state_tracker.h"
class PrefService;
-class PrefRegistrySyncable;
namespace base {
class DictionaryValue;
diff --git a/chrome/browser/managed_mode/managed_user_registration_service.h b/chrome/browser/managed_mode/managed_user_registration_service.h
index 82e7da9..047a2e4 100644
--- a/chrome/browser/managed_mode/managed_user_registration_service.h
+++ b/chrome/browser/managed_mode/managed_user_registration_service.h
@@ -51,7 +51,9 @@ class ManagedUserRegistrationService : public BrowserContextKeyedService,
static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry);
// Registers a new managed user with the server. |name| is the display name of
- // the user. |callback| is called with the result of the registration.
+ // the user. |callback| is called with the result of the registration. We use
+ // the name here and not the profile, because on Chrome OS the profile of the
+ // managed user does not yet exist.
void Register(const string16& name, const RegistrationCallback& callback);
// Cancels any registration currently in progress and calls the callback with
diff --git a/chrome/browser/managed_mode/managed_user_service.cc b/chrome/browser/managed_mode/managed_user_service.cc
index c9da4d7..13305e8 100644
--- a/chrome/browser/managed_mode/managed_user_service.cc
+++ b/chrome/browser/managed_mode/managed_user_service.cc
@@ -14,11 +14,15 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/managed_mode/managed_mode_site_list.h"
#include "chrome/browser/managed_mode/managed_user_registration_service.h"
+#include "chrome/browser/managed_mode/managed_user_registration_service_factory.h"
#include "chrome/browser/policy/managed_mode_policy_provider.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_base.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/sync/glue/session_model_associator.h"
@@ -157,6 +161,9 @@ void ManagedUserService::RegisterUserPrefs(
registry->RegisterIntegerPref(
prefs::kDefaultManagedModeFilteringBehavior, ManagedModeURLFilter::ALLOW,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+ registry->RegisterStringPref(
+ prefs::kManagedUserCustodian, std::string(),
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
// static
@@ -197,9 +204,7 @@ void ManagedUserService::GetCategoryNames(CategoryList* list) {
}
std::string ManagedUserService::GetCustodianEmailAddress() const {
- DCHECK(ProfileIsManaged());
- // TODO(akuegel): Replace the dummy value by the real value.
- return "custodian@gmail.com";
+ return profile_->GetPrefs()->GetString(prefs::kManagedUserCustodian);
}
std::string ManagedUserService::GetDebugPolicyProviderName() const {
@@ -520,18 +525,21 @@ void ManagedUserService::Init() {
}
void ManagedUserService::RegisterAndInitSync(
- ManagedUserRegistrationService* registration_service,
+ Profile* custodian_profile,
const ProfileManager::CreateCallback& callback) {
+ ManagedUserRegistrationService* registration_service =
+ ManagedUserRegistrationServiceFactory::GetForProfile(custodian_profile);
string16 name = UTF8ToUTF16(
profile_->GetPrefs()->GetString(prefs::kProfileName));
registration_service->Register(
name,
base::Bind(&ManagedUserService::OnManagedUserRegistered,
- weak_ptr_factory_.GetWeakPtr(), callback));
+ weak_ptr_factory_.GetWeakPtr(), callback, custodian_profile));
}
void ManagedUserService::OnManagedUserRegistered(
const ProfileManager::CreateCallback& callback,
+ Profile* custodian_profile,
const GoogleServiceAuthError& auth_error,
const std::string& token) {
if (auth_error.state() == GoogleServiceAuthError::REQUEST_CANCELED) {
@@ -545,6 +553,10 @@ void ManagedUserService::OnManagedUserRegistered(
}
InitSync(token);
+ SigninManagerBase* signin =
+ SigninManagerFactory::GetForProfile(custodian_profile);
+ profile_->GetPrefs()->SetString(prefs::kManagedUserCustodian,
+ signin->GetAuthenticatedUsername());
callback.Run(profile_, Profile::CREATE_STATUS_INITIALIZED);
}
diff --git a/chrome/browser/managed_mode/managed_user_service.h b/chrome/browser/managed_mode/managed_user_service.h
index 8f4f1a3..b0e5d97 100644
--- a/chrome/browser/managed_mode/managed_user_service.h
+++ b/chrome/browser/managed_mode/managed_user_service.h
@@ -121,9 +121,8 @@ class ManagedUserService : public BrowserContextKeyedService,
// |registration_service| and initializes sync with the returned token.
// Note that |registration_service| should belong to the custodian's profile,
// not this one.
- void RegisterAndInitSync(
- ManagedUserRegistrationService* registration_service,
- const ProfileManager::CreateCallback& callback);
+ void RegisterAndInitSync(Profile* custodian_profile,
+ const ProfileManager::CreateCallback& callback);
// Returns a pseudo-email address for systems that expect well-formed email
// addresses (like Sync), even though we're not signed in.
@@ -179,6 +178,7 @@ class ManagedUserService : public BrowserContextKeyedService,
};
void OnManagedUserRegistered(const ProfileManager::CreateCallback& callback,
+ Profile* custodian_profile,
const GoogleServiceAuthError& auth_error,
const std::string& token);
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index ac5def7..62a372d 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -1157,20 +1157,19 @@ void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
void BrowserOptionsHandler::RegisterNewManagedUser(
const ProfileManager::CreateCallback& callback,
- Profile* profile,
+ Profile* new_profile,
Profile::CreateStatus status) {
- DCHECK(profile_path_being_created_ == profile->GetPath());
+ DCHECK(profile_path_being_created_ == new_profile->GetPath());
if (status != Profile::CREATE_STATUS_INITIALIZED)
return;
ManagedUserService* managed_user_service =
- ManagedUserServiceFactory::GetForProfile(profile);
+ ManagedUserServiceFactory::GetForProfile(new_profile);
DCHECK(managed_user_service->ProfileIsManaged());
- ManagedUserRegistrationService* registration_service =
- ManagedUserRegistrationServiceFactory::GetForProfile(
- Profile::FromWebUI(web_ui()));
- managed_user_service->RegisterAndInitSync(registration_service, callback);
+ // Register the managed user using the profile of the custodian.
+ managed_user_service->RegisterAndInitSync(Profile::FromWebUI(web_ui()),
+ callback);
}
void BrowserOptionsHandler::ShowProfileCreationFeedback(
@@ -1365,8 +1364,8 @@ scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() {
SigninManagerFactory::GetForProfile(profile)->IsSignoutProhibited();
#endif
- ProfileSyncService* service(
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile));
+ ProfileSyncService* service =
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
SigninManagerBase* signin = service->signin();
sync_status->SetBoolean("signoutAllowed", !signout_prohibited);
sync_status->SetBoolean("signinAllowed", signin->IsSigninAllowed());
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.h b/chrome/browser/ui/webui/options/browser_options_handler.h
index 911f54b..156764b 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.h
+++ b/chrome/browser/ui/webui/options/browser_options_handler.h
@@ -159,7 +159,7 @@ class BrowserOptionsHandler
// class) still exists after the new managed profile has been created
// asynchronously.
void RegisterNewManagedUser(const ProfileManager::CreateCallback& callback,
- Profile* profile,
+ Profile* new_profile,
Profile::CreateStatus status);
// Updates the UI as the final task after a new profile has been created.