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

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

Issue 7298005: Expose privacy-relevant preferences via Chrome's extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing. Created 9 years, 3 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) 2011 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_api.h" 5 #include "chrome/browser/extensions/extension_preference_api.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 27 matching lines...) Expand all
38 const char kControllableByThisExtension[] = "controllable_by_this_extension"; 38 const char kControllableByThisExtension[] = "controllable_by_this_extension";
39 const char kControlledByThisExtension[] = "controlled_by_this_extension"; 39 const char kControlledByThisExtension[] = "controlled_by_this_extension";
40 40
41 const char kIncognitoSpecific[] = "incognitoSpecific"; 41 const char kIncognitoSpecific[] = "incognitoSpecific";
42 const char kLevelOfControl[] = "levelOfControl"; 42 const char kLevelOfControl[] = "levelOfControl";
43 const char kValue[] = "value"; 43 const char kValue[] = "value";
44 44
45 const char kOnPrefChangeFormat[] = "types.ChromeSetting.%s.onChange"; 45 const char kOnPrefChangeFormat[] = "types.ChromeSetting.%s.onChange";
46 46
47 PrefMappingEntry kPrefMapping[] = { 47 PrefMappingEntry kPrefMapping[] = {
48 { "thirdPartyCookiesAllowed", 48 { "alternateErrorPagesEnabled",
49 prefs::kBlockThirdPartyCookies, 49 prefs::kAlternateErrorPagesEnabled,
50 ExtensionAPIPermission::kContentSettings 50 ExtensionAPIPermission::kExperimental
51 }, 51 },
52 { "referrersEnabled", 52 { "autofillEnabled",
53 prefs::kEnableReferrers, 53 prefs::kAutofillEnabled,
54 ExtensionAPIPermission::kContentSettings 54 ExtensionAPIPermission::kExperimental
55 }, 55 },
56 { "hyperlinkAuditingEnabled", 56 { "hyperlinkAuditingEnabled",
57 prefs::kEnableHyperlinkAuditing, 57 prefs::kEnableHyperlinkAuditing,
58 ExtensionAPIPermission::kContentSettings 58 ExtensionAPIPermission::kExperimental
59 },
60 { "instantEnabled",
61 prefs::kInstantEnabled,
62 ExtensionAPIPermission::kExperimental
63 },
64 // TODO(mkwst): come back to this once the UMA discussion has been resolved.
65 // { "metricsReportingEnabled",
66 // prefs::kMetricsReportingEnabled,
67 // ExtensionAPIPermission::kMetrics
68 // },
69 { "networkPredictionEnabled",
70 prefs::kNetworkPredictionEnabled,
71 ExtensionAPIPermission::kExperimental
59 }, 72 },
60 { "proxy", 73 { "proxy",
61 prefs::kProxy, 74 prefs::kProxy,
62 ExtensionAPIPermission::kProxy 75 ExtensionAPIPermission::kProxy
63 }, 76 },
77 { "referrersEnabled",
78 prefs::kEnableReferrers,
79 ExtensionAPIPermission::kExperimental
80 },
81 { "searchSuggestEnabled",
82 prefs::kSearchSuggestEnabled,
83 ExtensionAPIPermission::kExperimental
84 },
85 { "safeBrowsingEnabled",
86 prefs::kSafeBrowsingEnabled,
87 ExtensionAPIPermission::kExperimental
88 },
89 { "thirdPartyCookiesAllowed",
90 prefs::kBlockThirdPartyCookies,
91 ExtensionAPIPermission::kExperimental
92 },
93 { "translationServiceEnabled",
94 prefs::kEnableTranslate,
95 ExtensionAPIPermission::kExperimental
96 }
64 }; 97 };
65 98
66 class IdentityPrefTransformer : public PrefTransformerInterface { 99 class IdentityPrefTransformer : public PrefTransformerInterface {
67 public: 100 public:
68 virtual Value* ExtensionToBrowserPref(const Value* extension_pref, 101 virtual Value* ExtensionToBrowserPref(const Value* extension_pref,
69 std::string* error, 102 std::string* error,
70 bool* bad_message) { 103 bool* bad_message) {
71 return extension_pref->DeepCopy(); 104 return extension_pref->DeepCopy();
72 } 105 }
73 106
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 pref_key, &browser_pref, &permission)); 503 pref_key, &browser_pref, &permission));
471 if (!GetExtension()->HasAPIPermission(permission)) { 504 if (!GetExtension()->HasAPIPermission(permission)) {
472 error_ = ExtensionErrorUtils::FormatErrorMessage( 505 error_ = ExtensionErrorUtils::FormatErrorMessage(
473 keys::kPermissionErrorMessage, pref_key); 506 keys::kPermissionErrorMessage, pref_key);
474 return false; 507 return false;
475 } 508 }
476 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); 509 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs();
477 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); 510 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope);
478 return true; 511 return true;
479 } 512 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698