OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/extensions/system/system_api.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/pref_names.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 // Maps prefs::kIncognitoModeAvailability values (0 = enabled, ...) |
| 15 // to strings exposed to extensions. |
| 16 const char* kIncognitoModeAvailabilityStrings[] = { |
| 17 "enabled", |
| 18 "disabled", |
| 19 "forced" |
| 20 }; |
| 21 |
| 22 } // namespace |
| 23 |
| 24 namespace extensions { |
| 25 |
| 26 GetIncognitoModeAvailabilityFunction::~GetIncognitoModeAvailabilityFunction() { |
| 27 } |
| 28 |
| 29 bool GetIncognitoModeAvailabilityFunction::RunImpl() { |
| 30 PrefService* prefs = profile_->GetPrefs(); |
| 31 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability); |
| 32 EXTENSION_FUNCTION_VALIDATE( |
| 33 value >= 0 && |
| 34 value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings))); |
| 35 result_.reset( |
| 36 Value::CreateStringValue(kIncognitoModeAvailabilityStrings[value])); |
| 37 return true; |
| 38 } |
| 39 |
| 40 } // namespace extensions |
OLD | NEW |