| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" | 11 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" |
| 12 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 12 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
| 13 #include "components/browser_sync/browser/profile_sync_service.h" | 13 #include "components/browser_sync/browser/profile_sync_service.h" |
| 14 #include "google_apis/gaia/google_service_auth_error.h" | 14 #include "google_apis/gaia/google_service_auth_error.h" |
| 15 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 const char kSupervisedUserAccessRequestKeyPrefix[] = | 18 const char kSupervisedUserAccessRequestKeyPrefix[] = |
| 19 "X-ManagedUser-AccessRequests"; | 19 "X-ManagedUser-AccessRequests"; |
| 20 const char kSupervisedUserInstallRequestKeyPrefix[] = |
| 21 "X-ManagedUser-InstallRequests"; |
| 20 const char kSupervisedUserUpdateRequestKeyPrefix[] = | 22 const char kSupervisedUserUpdateRequestKeyPrefix[] = |
| 21 "X-ManagedUser-UpdateRequests"; | 23 "X-ManagedUser-UpdateRequests"; |
| 22 const char kSupervisedUserAccessRequestTime[] = "timestamp"; | 24 const char kSupervisedUserAccessRequestTime[] = "timestamp"; |
| 23 const char kSupervisedUserName[] = "name"; | 25 const char kSupervisedUserName[] = "name"; |
| 24 | 26 |
| 25 // Key for the notification setting of the custodian. This is a shared setting | 27 // Key for the notification setting of the custodian. This is a shared setting |
| 26 // so we can include the setting in the access request data that is used to | 28 // so we can include the setting in the access request data that is used to |
| 27 // trigger notifications. | 29 // trigger notifications. |
| 28 const char kNotificationSetting[] = "custodian-notification-setting"; | 30 const char kNotificationSetting[] = "custodian-notification-setting"; |
| 29 | 31 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 51 } | 53 } |
| 52 | 54 |
| 53 void PermissionRequestCreatorSync::CreateURLAccessRequest( | 55 void PermissionRequestCreatorSync::CreateURLAccessRequest( |
| 54 const GURL& url_requested, | 56 const GURL& url_requested, |
| 55 const SuccessCallback& callback) { | 57 const SuccessCallback& callback) { |
| 56 CreateRequest(kSupervisedUserAccessRequestKeyPrefix, | 58 CreateRequest(kSupervisedUserAccessRequestKeyPrefix, |
| 57 net::EscapeQueryParamValue(url_requested.spec(), true), | 59 net::EscapeQueryParamValue(url_requested.spec(), true), |
| 58 callback); | 60 callback); |
| 59 } | 61 } |
| 60 | 62 |
| 63 void PermissionRequestCreatorSync::CreateExtensionInstallRequest( |
| 64 const std::string& id, |
| 65 const SuccessCallback& callback) { |
| 66 CreateRequest(kSupervisedUserInstallRequestKeyPrefix, id, callback); |
| 67 } |
| 68 |
| 61 void PermissionRequestCreatorSync::CreateExtensionUpdateRequest( | 69 void PermissionRequestCreatorSync::CreateExtensionUpdateRequest( |
| 62 const std::string& id, | 70 const std::string& id, |
| 63 const SuccessCallback& callback) { | 71 const SuccessCallback& callback) { |
| 64 CreateRequest(kSupervisedUserUpdateRequestKeyPrefix, id, callback); | 72 CreateRequest(kSupervisedUserUpdateRequestKeyPrefix, id, callback); |
| 65 } | 73 } |
| 66 | 74 |
| 67 void PermissionRequestCreatorSync::CreateRequest( | 75 void PermissionRequestCreatorSync::CreateRequest( |
| 68 const std::string& prefix, | 76 const std::string& prefix, |
| 69 const std::string& data, | 77 const std::string& data, |
| 70 const SuccessCallback& callback) { | 78 const SuccessCallback& callback) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 85 if (value) { | 93 if (value) { |
| 86 bool success = value->GetAsBoolean(¬ifications_enabled); | 94 bool success = value->GetAsBoolean(¬ifications_enabled); |
| 87 DCHECK(success); | 95 DCHECK(success); |
| 88 } | 96 } |
| 89 dict->SetBoolean(kNotificationSetting, notifications_enabled); | 97 dict->SetBoolean(kNotificationSetting, notifications_enabled); |
| 90 | 98 |
| 91 settings_service_->UploadItem(key, std::move(dict)); | 99 settings_service_->UploadItem(key, std::move(dict)); |
| 92 | 100 |
| 93 callback.Run(true); | 101 callback.Run(true); |
| 94 } | 102 } |
| OLD | NEW |