Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/supervised_user/legacy/permission_request_creator_sync. h" | 5 #include "chrome/browser/supervised_user/legacy/permission_request_creator_sync. h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service.h" | 9 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service.h" |
| 10 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 10 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 // We allow requesting access if Sync is working or has a transient error. | 45 // We allow requesting access if Sync is working or has a transient error. |
| 46 return (state == GoogleServiceAuthError::NONE || | 46 return (state == GoogleServiceAuthError::NONE || |
| 47 state == GoogleServiceAuthError::CONNECTION_FAILED || | 47 state == GoogleServiceAuthError::CONNECTION_FAILED || |
| 48 state == GoogleServiceAuthError::SERVICE_UNAVAILABLE); | 48 state == GoogleServiceAuthError::SERVICE_UNAVAILABLE); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void PermissionRequestCreatorSync::CreateURLAccessRequest( | 51 void PermissionRequestCreatorSync::CreateURLAccessRequest( |
| 52 const GURL& url_requested, | 52 const GURL& url_requested, |
| 53 const SuccessCallback& callback) { | 53 const SuccessCallback& callback) { |
| 54 CreateRequest(kSupervisedUserAccessRequestKeyPrefix, | 54 CreateRequest(kSupervisedUserAccessRequestKeyPrefix, |
| 55 url_requested.spec(), | 55 net::EscapeQueryParamValue(url_requested.spec(), true), |
| 56 callback); | 56 callback); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void PermissionRequestCreatorSync::CreateExtensionUpdateRequest( | 59 void PermissionRequestCreatorSync::CreateExtensionUpdateRequest( |
| 60 const std::string& id, | 60 const std::string& id, |
| 61 const SuccessCallback& callback) { | 61 const SuccessCallback& callback) { |
| 62 CreateRequest(kSupervisedUserUpdateRequestKeyPrefix, id, callback); | 62 CreateRequest(kSupervisedUserUpdateRequestKeyPrefix, id, callback); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void PermissionRequestCreatorSync::CreateRequest( | 65 void PermissionRequestCreatorSync::CreateRequest( |
| 66 const std::string& prefix, | 66 const std::string& prefix, |
| 67 const std::string& data, | 67 const std::string& data, |
| 68 const SuccessCallback& callback) { | 68 const SuccessCallback& callback) { |
| 69 // Escape the data string and add the prefix. | 69 // Add the prefix. |
|
Pam (message me for reviews)
2015/03/27 12:13:54
Please add a note to the corresponding .h file men
Marc Treib
2015/03/27 12:19:16
This is a private method. CreateURLAccessRequest a
| |
| 70 std::string key = SupervisedUserSettingsService::MakeSplitSettingKey( | 70 std::string key = |
| 71 prefix, | 71 SupervisedUserSettingsService::MakeSplitSettingKey(prefix, data); |
| 72 net::EscapeQueryParamValue(data, true)); | |
| 73 | 72 |
| 74 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 73 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 75 // TODO(sergiu): Use sane time here when it's ready. | 74 // TODO(sergiu): Use sane time here when it's ready. |
| 76 dict->SetDouble(kSupervisedUserAccessRequestTime, | 75 dict->SetDouble(kSupervisedUserAccessRequestTime, |
| 77 base::Time::Now().ToJsTime()); | 76 base::Time::Now().ToJsTime()); |
| 78 dict->SetString(kSupervisedUserName, name_); | 77 dict->SetString(kSupervisedUserName, name_); |
| 79 | 78 |
| 80 // Copy the notification setting of the custodian. | 79 // Copy the notification setting of the custodian. |
| 81 const base::Value* value = shared_settings_service_->GetValue( | 80 const base::Value* value = shared_settings_service_->GetValue( |
| 82 supervised_user_id_, kNotificationSetting); | 81 supervised_user_id_, kNotificationSetting); |
| 83 bool notifications_enabled = false; | 82 bool notifications_enabled = false; |
| 84 if (value) { | 83 if (value) { |
| 85 bool success = value->GetAsBoolean(¬ifications_enabled); | 84 bool success = value->GetAsBoolean(¬ifications_enabled); |
| 86 DCHECK(success); | 85 DCHECK(success); |
| 87 } | 86 } |
| 88 dict->SetBoolean(kNotificationSetting, notifications_enabled); | 87 dict->SetBoolean(kNotificationSetting, notifications_enabled); |
| 89 | 88 |
| 90 settings_service_->UploadItem(key, dict.Pass()); | 89 settings_service_->UploadItem(key, dict.Pass()); |
| 91 | 90 |
| 92 callback.Run(true); | 91 callback.Run(true); |
| 93 } | 92 } |
| OLD | NEW |