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

Side by Side Diff: chrome/browser/extensions/extension_preference_helpers.cc

Issue 10008076: Add onFontNameChanged event to Font Settings API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/extension_preference_helpers.h" 5 #include "chrome/browser/extensions/extension_preference_helpers.h"
6 6
7 #include "chrome/browser/extensions/extension_prefs.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h"
10
7 namespace { 11 namespace {
8 12
9 const char kIncognitoPersistent[] = "incognito_persistent"; 13 const char kIncognitoPersistent[] = "incognito_persistent";
10 const char kIncognitoSessionOnly[] = "incognito_session_only"; 14 const char kIncognitoSessionOnly[] = "incognito_session_only";
11 const char kRegular[] = "regular"; 15 const char kRegular[] = "regular";
12 16
17 const char kNotControllable[] = "not_controllable";
18 const char kControlledByOtherExtensions[] = "controlled_by_other_extensions";
19 const char kControllableByThisExtension[] = "controllable_by_this_extension";
20 const char kControlledByThisExtension[] = "controlled_by_this_extension";
21
13 } // namespace 22 } // namespace
14 23
15 namespace extension_preference_helpers { 24 namespace extension_preference_helpers {
16 25
17 bool StringToScope(const std::string& s, ExtensionPrefsScope* scope) { 26 bool StringToScope(const std::string& s, ExtensionPrefsScope* scope) {
18 if (s == kRegular) 27 if (s == kRegular)
19 *scope = kExtensionPrefsScopeRegular; 28 *scope = kExtensionPrefsScopeRegular;
20 else if (s == kIncognitoPersistent) 29 else if (s == kIncognitoPersistent)
21 *scope = kExtensionPrefsScopeIncognitoPersistent; 30 *scope = kExtensionPrefsScopeIncognitoPersistent;
22 else if (s == kIncognitoSessionOnly) 31 else if (s == kIncognitoSessionOnly)
23 *scope = kExtensionPrefsScopeIncognitoSessionOnly; 32 *scope = kExtensionPrefsScopeIncognitoSessionOnly;
24 else 33 else
25 return false; 34 return false;
26 return true; 35 return true;
27 } 36 }
28 37
38 const char* GetLevelOfControl(
39 Profile* profile,
40 const std::string& extension_id,
41 const std::string& browser_pref,
42 bool incognito) {
43 PrefService* prefs = incognito ? profile->GetOffTheRecordPrefs()
44 : profile->GetPrefs();
45 const PrefService::Preference* pref =
46 prefs->FindPreference(browser_pref.c_str());
47 CHECK(pref);
48 ExtensionPrefs* ep = profile->GetExtensionService()->extension_prefs();
49
50 if (!pref->IsExtensionModifiable())
51 return kNotControllable;
52
53 if (ep->DoesExtensionControlPref(extension_id, browser_pref, incognito))
54 return kControlledByThisExtension;
55
56 if (ep->CanExtensionControlPref(extension_id, browser_pref, incognito))
57 return kControllableByThisExtension;
58
59 return kControlledByOtherExtensions;
60 }
61
29 } // namespace extension_preference_helpers 62 } // namespace extension_preference_helpers
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698