| Index: chrome/browser/managed_mode/managed_user_service.cc
|
| diff --git a/chrome/browser/managed_mode/managed_user_service.cc b/chrome/browser/managed_mode/managed_user_service.cc
|
| index 8ca555f7c129bac3ed47141c368f33d36c77bb33..8317feabae0ea48110567bb8bd64dc3afad857ca 100644
|
| --- a/chrome/browser/managed_mode/managed_user_service.cc
|
| +++ b/chrome/browser/managed_mode/managed_user_service.cc
|
| @@ -23,6 +23,7 @@
|
| #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.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"
|
| @@ -140,6 +141,7 @@ ManagedUserService::ManagedUserService(Profile* profile)
|
| is_profile_active_(false),
|
| elevated_for_testing_(false),
|
| did_shutdown_(false),
|
| + waiting_for_permissions_(false),
|
| weak_ptr_factory_(this) {
|
| }
|
|
|
| @@ -444,6 +446,9 @@ void ManagedUserService::UpdateSiteLists() {
|
| }
|
|
|
| bool ManagedUserService::AccessRequestsEnabled() {
|
| + if (waiting_for_permissions_)
|
| + return false;
|
| +
|
| ProfileSyncService* service =
|
| ProfileSyncServiceFactory::GetForProfile(profile_);
|
| GoogleServiceAuthError::State state = service->GetAuthError().state();
|
| @@ -453,6 +458,14 @@ bool ManagedUserService::AccessRequestsEnabled() {
|
| state == GoogleServiceAuthError::SERVICE_UNAVAILABLE);
|
| }
|
|
|
| +void ManagedUserService::OnPermissionRequestIssued(
|
| + const GoogleServiceAuthError& error) {
|
| + 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) {
|
| // Normalize the URL.
|
| GURL normalized_url = ManagedModeURLFilter::Normalize(url);
|
| @@ -460,6 +473,16 @@ void ManagedUserService::AddAccessRequest(const GURL& url) {
|
| // Escape the URL.
|
| std::string output(net::EscapeQueryParamValue(normalized_url.spec(), true));
|
|
|
| + if (CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kPermissionRequestApiUrl)) {
|
| + waiting_for_permissions_ = true;
|
| + permissions_creator_->CreatePermissionRequest(
|
| + output,
|
| + base::Bind(&ManagedUserService::OnPermissionRequestIssued,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| + return;
|
| + }
|
| +
|
| // Add the prefix.
|
| std::string key = ManagedUserSettingsService::MakeSplitSettingKey(
|
| kManagedUserAccessRequestKeyPrefix, output);
|
| @@ -568,6 +591,7 @@ void ManagedUserService::Init() {
|
| ProfileOAuth2TokenService* token_service =
|
| ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
|
| token_service->LoadCredentials(managed_users::kManagedUserPseudoEmail);
|
| + permissions_creator_ = PermissionRequestCreator::Create(profile_);
|
|
|
| extensions::ExtensionSystem* extension_system =
|
| extensions::ExtensionSystem::Get(profile_);
|
|
|