| 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/permission_request_creator_sync.h" | 5 #include "chrome/browser/supervised_user/permission_request_creator_sync.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | |
| 9 #include "base/values.h" | 8 #include "base/values.h" |
| 10 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 9 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
| 11 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
.h" | 10 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
.h" |
| 12 #include "chrome/common/chrome_switches.h" | |
| 13 | 11 |
| 14 using base::Time; | 12 using base::Time; |
| 15 | 13 |
| 16 const char kSupervisedUserAccessRequestKeyPrefix[] = | 14 const char kSupervisedUserAccessRequestKeyPrefix[] = |
| 17 "X-ManagedUser-AccessRequests"; | 15 "X-ManagedUser-AccessRequests"; |
| 18 const char kSupervisedUserAccessRequestTime[] = "timestamp"; | 16 const char kSupervisedUserAccessRequestTime[] = "timestamp"; |
| 19 const char kSupervisedUserName[] = "name"; | 17 const char kSupervisedUserName[] = "name"; |
| 20 | 18 |
| 21 // Key for the notification setting of the custodian. This is a shared setting | 19 // Key for the notification setting of the custodian. This is a shared setting |
| 22 // so we can include the setting in the access request data that is used to | 20 // so we can include the setting in the access request data that is used to |
| (...skipping 25 matching lines...) Expand all Loading... |
| 48 // TODO(sergiu): Use sane time here when it's ready. | 46 // TODO(sergiu): Use sane time here when it's ready. |
| 49 dict->SetDouble(kSupervisedUserAccessRequestTime, | 47 dict->SetDouble(kSupervisedUserAccessRequestTime, |
| 50 base::Time::Now().ToJsTime()); | 48 base::Time::Now().ToJsTime()); |
| 51 | 49 |
| 52 dict->SetString(kSupervisedUserName, name_); | 50 dict->SetString(kSupervisedUserName, name_); |
| 53 | 51 |
| 54 // Copy the notification setting of the custodian. | 52 // Copy the notification setting of the custodian. |
| 55 const base::Value* value = shared_settings_service_->GetValue( | 53 const base::Value* value = shared_settings_service_->GetValue( |
| 56 supervised_user_id_, kNotificationSetting); | 54 supervised_user_id_, kNotificationSetting); |
| 57 bool notifications_enabled = false; | 55 bool notifications_enabled = false; |
| 58 if (CommandLine::ForCurrentProcess()->HasSwitch( | 56 if (value) { |
| 59 switches::kEnableAccessRequestNotifications)) { | |
| 60 notifications_enabled = true; | |
| 61 } else if (value) { | |
| 62 bool success = value->GetAsBoolean(¬ifications_enabled); | 57 bool success = value->GetAsBoolean(¬ifications_enabled); |
| 63 DCHECK(success); | 58 DCHECK(success); |
| 64 } | 59 } |
| 65 dict->SetBoolean(kNotificationSetting, notifications_enabled); | 60 dict->SetBoolean(kNotificationSetting, notifications_enabled); |
| 66 | 61 |
| 67 settings_service_->UploadItem(key, dict.PassAs<base::Value>()); | 62 settings_service_->UploadItem(key, dict.PassAs<base::Value>()); |
| 68 | 63 |
| 69 callback.Run(); | 64 callback.Run(); |
| 70 } | 65 } |
| OLD | NEW |