summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/preference
diff options
context:
space:
mode:
authorbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-28 21:19:23 +0000
committerbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-28 21:19:23 +0000
commit21a40087a57e13cc9b81cb7e8064f74587dfa8a1 (patch)
treee88d44c64fcaa47a5b45533a4d6c993de770757c /chrome/browser/extensions/api/preference
parent0f75118d4799a7c5421150826eaccd1dfd253f8e (diff)
downloadchromium_src-21a40087a57e13cc9b81cb7e8064f74587dfa8a1.zip
chromium_src-21a40087a57e13cc9b81cb7e8064f74587dfa8a1.tar.gz
chromium_src-21a40087a57e13cc9b81cb7e8064f74587dfa8a1.tar.bz2
Remove Profile dependency from ExtensionFunction
This instead creates new variants of ExtensionFunction for Chrome APIs, which need Profile, and uses them for any API that needs to access Profiles. TBR=sky@chromium.org BUG=297942 Review URL: https://codereview.chromium.org/35893010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/preference')
-rw-r--r--chrome/browser/extensions/api/preference/chrome_direct_setting.cc14
-rw-r--r--chrome/browser/extensions/api/preference/chrome_direct_setting.h4
-rw-r--r--chrome/browser/extensions/api/preference/preference_api.cc32
-rw-r--r--chrome/browser/extensions/api/preference/preference_api.h4
4 files changed, 25 insertions, 29 deletions
diff --git a/chrome/browser/extensions/api/preference/chrome_direct_setting.cc b/chrome/browser/extensions/api/preference/chrome_direct_setting.cc
index 6d1bd76..bcd13a5 100644
--- a/chrome/browser/extensions/api/preference/chrome_direct_setting.cc
+++ b/chrome/browser/extensions/api/preference/chrome_direct_setting.cc
@@ -20,7 +20,7 @@ DirectSettingFunctionBase::DirectSettingFunctionBase() {}
DirectSettingFunctionBase::~DirectSettingFunctionBase() {}
PrefService* DirectSettingFunctionBase::GetPrefService() {
- return profile()->GetPrefs();
+ return GetProfile()->GetPrefs();
}
bool DirectSettingFunctionBase::IsCalledFromComponentExtension() {
@@ -34,8 +34,8 @@ bool GetDirectSettingFunction::RunImpl() {
std::string pref_key;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &pref_key));
- EXTENSION_FUNCTION_VALIDATE(
- ChromeDirectSettingAPI::Get(profile())->IsPreferenceOnWhitelist(pref_key));
+ EXTENSION_FUNCTION_VALIDATE(ChromeDirectSettingAPI::Get(GetProfile())
+ ->IsPreferenceOnWhitelist(pref_key));
const PrefService::Preference* preference =
GetPrefService()->FindPreference(pref_key.c_str());
@@ -58,8 +58,8 @@ bool SetDirectSettingFunction::RunImpl() {
std::string pref_key;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &pref_key));
- EXTENSION_FUNCTION_VALIDATE(
- ChromeDirectSettingAPI::Get(profile())->IsPreferenceOnWhitelist(pref_key));
+ EXTENSION_FUNCTION_VALIDATE(ChromeDirectSettingAPI::Get(GetProfile())
+ ->IsPreferenceOnWhitelist(pref_key));
DictionaryValue* details = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &details));
@@ -89,8 +89,8 @@ bool ClearDirectSettingFunction::RunImpl() {
std::string pref_key;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &pref_key));
- EXTENSION_FUNCTION_VALIDATE(
- ChromeDirectSettingAPI::Get(profile())->IsPreferenceOnWhitelist(pref_key));
+ EXTENSION_FUNCTION_VALIDATE(ChromeDirectSettingAPI::Get(GetProfile())
+ ->IsPreferenceOnWhitelist(pref_key));
GetPrefService()->ClearPref(pref_key.c_str());
return true;
diff --git a/chrome/browser/extensions/api/preference/chrome_direct_setting.h b/chrome/browser/extensions/api/preference/chrome_direct_setting.h
index 7e36344..504bc66 100644
--- a/chrome/browser/extensions/api/preference/chrome_direct_setting.h
+++ b/chrome/browser/extensions/api/preference/chrome_direct_setting.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_CHROME_DIRECT_SETTING_H__
#include "base/lazy_instance.h"
-#include "chrome/browser/extensions/extension_function.h"
+#include "chrome/browser/extensions/chrome_extension_function.h"
class PrefService;
@@ -14,7 +14,7 @@ namespace extensions {
namespace chromedirectsetting {
// Base class to host instance method helpers.
-class DirectSettingFunctionBase : public SyncExtensionFunction {
+class DirectSettingFunctionBase : public ChromeSyncExtensionFunction {
protected:
DirectSettingFunctionBase();
virtual ~DirectSettingFunctionBase();
diff --git a/chrome/browser/extensions/api/preference/preference_api.cc b/chrome/browser/extensions/api/preference/preference_api.cc
index 5f12e5d..9711adf 100644
--- a/chrome/browser/extensions/api/preference/preference_api.cc
+++ b/chrome/browser/extensions/api/preference/preference_api.cc
@@ -570,8 +570,8 @@ bool GetPreferenceFunction::RunImpl() {
std::string browser_pref;
if (!ValidateBrowserPref(pref_key, &browser_pref))
return false;
- PrefService* prefs = incognito ? profile_->GetOffTheRecordPrefs()
- : profile_->GetPrefs();
+ PrefService* prefs = incognito ? GetProfile()->GetOffTheRecordPrefs()
+ : GetProfile()->GetPrefs();
const PrefService::Preference* pref =
prefs->FindPreference(browser_pref.c_str());
CHECK(pref);
@@ -579,9 +579,8 @@ bool GetPreferenceFunction::RunImpl() {
scoped_ptr<DictionaryValue> result(new DictionaryValue);
// Retrieve level of control.
- std::string level_of_control =
- helpers::GetLevelOfControl(profile_, extension_id(), browser_pref,
- incognito);
+ std::string level_of_control = helpers::GetLevelOfControl(
+ GetProfile(), extension_id(), browser_pref, incognito);
result->SetString(keys::kLevelOfControl, level_of_control);
// Retrieve pref value.
@@ -599,7 +598,7 @@ bool GetPreferenceFunction::RunImpl() {
// Retrieve incognito status.
if (incognito) {
- ExtensionPrefs* ep = ExtensionPrefs::Get(profile_);
+ ExtensionPrefs* ep = ExtensionPrefs::Get(GetProfile());
result->SetBoolean(keys::kIncognitoSpecific,
ep->HasIncognitoPrefValue(browser_pref));
}
@@ -634,21 +633,21 @@ bool SetPreferenceFunction::RunImpl() {
scope == kExtensionPrefsScopeIncognitoSessionOnly);
if (incognito) {
// Regular profiles can't access incognito unless include_incognito is true.
- if (!profile()->IsOffTheRecord() && !include_incognito()) {
+ if (!GetProfile()->IsOffTheRecord() && !include_incognito()) {
error_ = keys::kIncognitoErrorMessage;
return false;
}
} else {
// Incognito profiles can't access regular mode ever, they only exist in
// split mode.
- if (profile()->IsOffTheRecord()) {
+ if (GetProfile()->IsOffTheRecord()) {
error_ = "Can't modify regular settings from an incognito context.";
return false;
}
}
if (scope == kExtensionPrefsScopeIncognitoSessionOnly &&
- !profile_->HasOffTheRecordProfile()) {
+ !GetProfile()->HasOffTheRecordProfile()) {
error_ = keys::kIncognitoSessionOnlyErrorMessage;
return false;
}
@@ -657,7 +656,7 @@ bool SetPreferenceFunction::RunImpl() {
std::string browser_pref;
if (!ValidateBrowserPref(pref_key, &browser_pref))
return false;
- ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
+ ExtensionPrefs* prefs = ExtensionPrefs::Get(GetProfile());
const PrefService::Preference* pref =
prefs->pref_service()->FindPreference(browser_pref.c_str());
CHECK(pref);
@@ -687,11 +686,8 @@ bool SetPreferenceFunction::RunImpl() {
return false;
}
- PreferenceAPI::Get(profile())->SetExtensionControlledPref(
- extension_id(),
- browser_pref,
- scope,
- browser_pref_value.release());
+ PreferenceAPI::Get(GetProfile())->SetExtensionControlledPref(
+ extension_id(), browser_pref, scope, browser_pref_value.release());
return true;
}
@@ -722,7 +718,7 @@ bool ClearPreferenceFunction::RunImpl() {
} else {
// Incognito profiles can't access regular mode ever, they only exist in
// split mode.
- if (profile()->IsOffTheRecord()) {
+ if (GetProfile()->IsOffTheRecord()) {
error_ = "Can't modify regular settings from an incognito context.";
return false;
}
@@ -732,8 +728,8 @@ bool ClearPreferenceFunction::RunImpl() {
if (!ValidateBrowserPref(pref_key, &browser_pref))
return false;
- PreferenceAPI::Get(profile())->RemoveExtensionControlledPref(
- extension_id(), browser_pref, scope);
+ PreferenceAPI::Get(GetProfile())
+ ->RemoveExtensionControlledPref(extension_id(), browser_pref, scope);
return true;
}
diff --git a/chrome/browser/extensions/api/preference/preference_api.h b/chrome/browser/extensions/api/preference/preference_api.h
index e706b57..b924126 100644
--- a/chrome/browser/extensions/api/preference/preference_api.h
+++ b/chrome/browser/extensions/api/preference/preference_api.h
@@ -10,8 +10,8 @@
#include "base/prefs/pref_change_registrar.h"
#include "chrome/browser/extensions/api/content_settings/content_settings_store.h"
#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
+#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/browser/extensions/event_router.h"
-#include "chrome/browser/extensions/extension_function.h"
#include "content/public/browser/notification_observer.h"
#include "extensions/browser/extension_prefs_scope.h"
@@ -175,7 +175,7 @@ class PrefTransformerInterface {
// A base class to provide functionality common to the other *PreferenceFunction
// classes.
-class PreferenceFunction : public SyncExtensionFunction {
+class PreferenceFunction : public ChromeSyncExtensionFunction {
protected:
virtual ~PreferenceFunction();