| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profiles/incognito_mode_policy_handler.h" | 5 #include "chrome/browser/profiles/incognito_mode_policy_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 10 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 IncognitoModePolicyHandler::~IncognitoModePolicyHandler() {} | 22 IncognitoModePolicyHandler::~IncognitoModePolicyHandler() {} |
| 23 | 23 |
| 24 bool IncognitoModePolicyHandler::CheckPolicySettings(const PolicyMap& policies, | 24 bool IncognitoModePolicyHandler::CheckPolicySettings(const PolicyMap& policies, |
| 25 PolicyErrorMap* errors) { | 25 PolicyErrorMap* errors) { |
| 26 const base::Value* availability = | 26 const base::Value* availability = |
| 27 policies.GetValue(key::kIncognitoModeAvailability); | 27 policies.GetValue(key::kIncognitoModeAvailability); |
| 28 if (availability) { | 28 if (availability) { |
| 29 int int_value = IncognitoModePrefs::ENABLED; | 29 int int_value = IncognitoModePrefs::ENABLED; |
| 30 if (!availability->GetAsInteger(&int_value)) { | 30 if (!availability->GetAsInteger(&int_value)) { |
| 31 errors->AddError(key::kIncognitoModeAvailability, IDS_POLICY_TYPE_ERROR, | 31 errors->AddError(key::kIncognitoModeAvailability, IDS_POLICY_TYPE_ERROR, |
| 32 base::Value::GetTypeName(base::Value::TYPE_INTEGER)); | 32 base::Value::GetTypeName(base::Value::Type::INTEGER)); |
| 33 return false; | 33 return false; |
| 34 } | 34 } |
| 35 IncognitoModePrefs::Availability availability_enum_value; | 35 IncognitoModePrefs::Availability availability_enum_value; |
| 36 if (!IncognitoModePrefs::IntToAvailability(int_value, | 36 if (!IncognitoModePrefs::IntToAvailability(int_value, |
| 37 &availability_enum_value)) { | 37 &availability_enum_value)) { |
| 38 errors->AddError(key::kIncognitoModeAvailability, | 38 errors->AddError(key::kIncognitoModeAvailability, |
| 39 IDS_POLICY_OUT_OF_RANGE_ERROR, | 39 IDS_POLICY_OUT_OF_RANGE_ERROR, |
| 40 base::IntToString(int_value)); | 40 base::IntToString(int_value)); |
| 41 return false; | 41 return false; |
| 42 } | 42 } |
| 43 return true; | 43 return true; |
| 44 } | 44 } |
| 45 | 45 |
| 46 const base::Value* deprecated_enabled = | 46 const base::Value* deprecated_enabled = |
| 47 policies.GetValue(key::kIncognitoEnabled); | 47 policies.GetValue(key::kIncognitoEnabled); |
| 48 if (deprecated_enabled && | 48 if (deprecated_enabled && |
| 49 !deprecated_enabled->IsType(base::Value::TYPE_BOOLEAN)) { | 49 !deprecated_enabled->IsType(base::Value::Type::BOOLEAN)) { |
| 50 errors->AddError(key::kIncognitoEnabled, IDS_POLICY_TYPE_ERROR, | 50 errors->AddError(key::kIncognitoEnabled, IDS_POLICY_TYPE_ERROR, |
| 51 base::Value::GetTypeName(base::Value::TYPE_BOOLEAN)); | 51 base::Value::GetTypeName(base::Value::Type::BOOLEAN)); |
| 52 return false; | 52 return false; |
| 53 } | 53 } |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void IncognitoModePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, | 57 void IncognitoModePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, |
| 58 PrefValueMap* prefs) { | 58 PrefValueMap* prefs) { |
| 59 const base::Value* availability = | 59 const base::Value* availability = |
| 60 policies.GetValue(key::kIncognitoModeAvailability); | 60 policies.GetValue(key::kIncognitoModeAvailability); |
| 61 const base::Value* deprecated_enabled = | 61 const base::Value* deprecated_enabled = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 79 prefs->SetInteger( | 79 prefs->SetInteger( |
| 80 prefs::kIncognitoModeAvailability, | 80 prefs::kIncognitoModeAvailability, |
| 81 enabled ? IncognitoModePrefs::ENABLED : IncognitoModePrefs::DISABLED); | 81 enabled ? IncognitoModePrefs::ENABLED : IncognitoModePrefs::DISABLED); |
| 82 } else { | 82 } else { |
| 83 NOTREACHED(); | 83 NOTREACHED(); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace policy | 88 } // namespace policy |
| OLD | NEW |