Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: chrome/browser/extensions/system/system_api.cc

Issue 8662008: Implement chrome.systemPrivate.getIncognitoModeAvailability extension API function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged with ToT Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW
« no previous file with comments | « chrome/browser/extensions/system/system_api.h ('k') | chrome/browser/extensions/system/system_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698