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/extension_system_api.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 |
| 9 namespace { |
| 10 |
| 11 // Maps prefs::kIncognitoModeAvailability values (0 = enabled, ...) |
| 12 // to strings exposed to extensions. |
| 13 const char* kIncognitoModeAvailabilityStrings[] = { |
| 14 "enabled", |
| 15 "disabled", |
| 16 "forced" |
| 17 }; |
| 18 |
| 19 } // namespace |
| 20 |
| 21 IncognitoModeAvailabilityTransformer::IncognitoModeAvailabilityTransformer() { |
| 22 } |
| 23 |
| 24 IncognitoModeAvailabilityTransformer::~IncognitoModeAvailabilityTransformer() { |
| 25 } |
| 26 |
| 27 Value* IncognitoModeAvailabilityTransformer::ExtensionToBrowserPref( |
| 28 const Value* extension_pref, |
| 29 std::string* error, |
| 30 bool* bad_message) { |
| 31 // We do not allow extensions to modify the IncognitoModeAvailability |
| 32 // preference. Therefore, this function is never called. |
| 33 NOTREACHED(); |
| 34 return NULL; |
| 35 } |
| 36 |
| 37 Value* IncognitoModeAvailabilityTransformer::BrowserToExtensionPref( |
| 38 const Value* browser_pref) { |
| 39 int browser_pref_value; |
| 40 if (!browser_pref->GetAsInteger(&browser_pref_value) || |
| 41 browser_pref_value < 0 || |
| 42 browser_pref_value >= |
| 43 static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings))) { |
| 44 return NULL; |
| 45 } |
| 46 return Value::CreateStringValue( |
| 47 kIncognitoModeAvailabilityStrings[browser_pref_value]); |
| 48 } |
OLD | NEW |