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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 const char kSupervisedUserName[] = "name"; | 25 const char kSupervisedUserName[] = "name"; |
26 | 26 |
27 // 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 |
28 // 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 |
29 // trigger notifications. | 29 // trigger notifications. |
30 const char kNotificationSetting[] = "custodian-notification-setting"; | 30 const char kNotificationSetting[] = "custodian-notification-setting"; |
31 | 31 |
32 PermissionRequestCreatorSync::PermissionRequestCreatorSync( | 32 PermissionRequestCreatorSync::PermissionRequestCreatorSync( |
33 SupervisedUserSettingsService* settings_service, | 33 SupervisedUserSettingsService* settings_service, |
34 SupervisedUserSharedSettingsService* shared_settings_service, | 34 SupervisedUserSharedSettingsService* shared_settings_service, |
35 ProfileSyncService* sync_service, | 35 browser_sync::ProfileSyncService* sync_service, |
36 const std::string& name, | 36 const std::string& name, |
37 const std::string& supervised_user_id) | 37 const std::string& supervised_user_id) |
38 : settings_service_(settings_service), | 38 : settings_service_(settings_service), |
39 shared_settings_service_(shared_settings_service), | 39 shared_settings_service_(shared_settings_service), |
40 sync_service_(sync_service), | 40 sync_service_(sync_service), |
41 name_(name), | 41 name_(name), |
42 supervised_user_id_(supervised_user_id) { | 42 supervised_user_id_(supervised_user_id) {} |
43 } | |
44 | 43 |
45 PermissionRequestCreatorSync::~PermissionRequestCreatorSync() {} | 44 PermissionRequestCreatorSync::~PermissionRequestCreatorSync() {} |
46 | 45 |
47 bool PermissionRequestCreatorSync::IsEnabled() const { | 46 bool PermissionRequestCreatorSync::IsEnabled() const { |
48 GoogleServiceAuthError::State state = sync_service_->GetAuthError().state(); | 47 GoogleServiceAuthError::State state = sync_service_->GetAuthError().state(); |
49 // We allow requesting access if Sync is working or has a transient error. | 48 // We allow requesting access if Sync is working or has a transient error. |
50 return (state == GoogleServiceAuthError::NONE || | 49 return (state == GoogleServiceAuthError::NONE || |
51 state == GoogleServiceAuthError::CONNECTION_FAILED || | 50 state == GoogleServiceAuthError::CONNECTION_FAILED || |
52 state == GoogleServiceAuthError::SERVICE_UNAVAILABLE); | 51 state == GoogleServiceAuthError::SERVICE_UNAVAILABLE); |
53 } | 52 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (value) { | 92 if (value) { |
94 bool success = value->GetAsBoolean(¬ifications_enabled); | 93 bool success = value->GetAsBoolean(¬ifications_enabled); |
95 DCHECK(success); | 94 DCHECK(success); |
96 } | 95 } |
97 dict->SetBoolean(kNotificationSetting, notifications_enabled); | 96 dict->SetBoolean(kNotificationSetting, notifications_enabled); |
98 | 97 |
99 settings_service_->UploadItem(key, std::move(dict)); | 98 settings_service_->UploadItem(key, std::move(dict)); |
100 | 99 |
101 callback.Run(true); | 100 callback.Run(true); |
102 } | 101 } |
OLD | NEW |