| 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/prefs/pref_value_map.h" | 8 #include "base/prefs/pref_value_map.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 const base::Value* availability = | 62 const base::Value* availability = |
| 63 policies.GetValue(key::kIncognitoModeAvailability); | 63 policies.GetValue(key::kIncognitoModeAvailability); |
| 64 const base::Value* deprecated_enabled = | 64 const base::Value* deprecated_enabled = |
| 65 policies.GetValue(key::kIncognitoEnabled); | 65 policies.GetValue(key::kIncognitoEnabled); |
| 66 if (availability) { | 66 if (availability) { |
| 67 int int_value = IncognitoModePrefs::ENABLED; | 67 int int_value = IncognitoModePrefs::ENABLED; |
| 68 IncognitoModePrefs::Availability availability_enum_value; | 68 IncognitoModePrefs::Availability availability_enum_value; |
| 69 if (availability->GetAsInteger(&int_value) && | 69 if (availability->GetAsInteger(&int_value) && |
| 70 IncognitoModePrefs::IntToAvailability(int_value, | 70 IncognitoModePrefs::IntToAvailability(int_value, |
| 71 &availability_enum_value)) { | 71 &availability_enum_value)) { |
| 72 prefs->SetValue(prefs::kIncognitoModeAvailability, | 72 prefs->SetInteger(prefs::kIncognitoModeAvailability, |
| 73 base::Value::CreateIntegerValue(availability_enum_value)); | 73 availability_enum_value); |
| 74 } else { | 74 } else { |
| 75 NOTREACHED(); | 75 NOTREACHED(); |
| 76 } | 76 } |
| 77 } else if (deprecated_enabled) { | 77 } else if (deprecated_enabled) { |
| 78 // If kIncognitoModeAvailability is not specified, check the obsolete | 78 // If kIncognitoModeAvailability is not specified, check the obsolete |
| 79 // kIncognitoEnabled. | 79 // kIncognitoEnabled. |
| 80 bool enabled = true; | 80 bool enabled = true; |
| 81 if (deprecated_enabled->GetAsBoolean(&enabled)) { | 81 if (deprecated_enabled->GetAsBoolean(&enabled)) { |
| 82 prefs->SetInteger( | 82 prefs->SetInteger( |
| 83 prefs::kIncognitoModeAvailability, | 83 prefs::kIncognitoModeAvailability, |
| 84 enabled ? IncognitoModePrefs::ENABLED : IncognitoModePrefs::DISABLED); | 84 enabled ? IncognitoModePrefs::ENABLED : IncognitoModePrefs::DISABLED); |
| 85 } else { | 85 } else { |
| 86 NOTREACHED(); | 86 NOTREACHED(); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace policy | 91 } // namespace policy |
| OLD | NEW |