| Index: chrome/browser/extensions/extension_system_api.cc
|
| diff --git a/chrome/browser/extensions/extension_system_api.cc b/chrome/browser/extensions/extension_system_api.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0231da50f8c34ac68c948d8bf9ad0d3a782d1f01
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/extension_system_api.cc
|
| @@ -0,0 +1,48 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/extensions/extension_system_api.h"
|
| +
|
| +#include "base/values.h"
|
| +
|
| +namespace {
|
| +
|
| +// Maps prefs::kIncognitoModeAvailability values (0 = enabled, ...)
|
| +// to strings exposed to extensions.
|
| +const char* kIncognitoModeAvailabilityStrings[] = {
|
| + "enabled",
|
| + "disabled",
|
| + "forced"
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +IncognitoModeAvailabilityTransformer::IncognitoModeAvailabilityTransformer() {
|
| +}
|
| +
|
| +IncognitoModeAvailabilityTransformer::~IncognitoModeAvailabilityTransformer() {
|
| +}
|
| +
|
| +Value* IncognitoModeAvailabilityTransformer::ExtensionToBrowserPref(
|
| + const Value* extension_pref,
|
| + std::string* error,
|
| + bool* bad_message) {
|
| + // We do not allow extensions to modify the IncognitoModeAvailability
|
| + // preference. Therefore, this function is never called.
|
| + NOTREACHED();
|
| + return NULL;
|
| +}
|
| +
|
| + Value* IncognitoModeAvailabilityTransformer::BrowserToExtensionPref(
|
| + const Value* browser_pref) {
|
| + int browser_pref_value;
|
| + if (!browser_pref->GetAsInteger(&browser_pref_value) ||
|
| + browser_pref_value < 0 ||
|
| + browser_pref_value >=
|
| + static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings))) {
|
| + return NULL;
|
| + }
|
| + return Value::CreateStringValue(
|
| + kIncognitoModeAvailabilityStrings[browser_pref_value]);
|
| +}
|
|
|