summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfalken@chromium.org <falken@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-23 04:52:45 +0000
committerfalken@chromium.org <falken@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-23 04:52:45 +0000
commit52fbc381a51a1a017e14124a46289ba3f63f44b8 (patch)
treed6b219dcdcfa0473cb13f3bb373bffa821b20a94
parente2544ed410d44bbcd5c26e049128e697dd143be6 (diff)
downloadchromium_src-52fbc381a51a1a017e14124a46289ba3f63f44b8.zip
chromium_src-52fbc381a51a1a017e14124a46289ba3f63f44b8.tar.gz
chromium_src-52fbc381a51a1a017e14124a46289ba3f63f44b8.tar.bz2
Add character encoding to Font Settings Extension API.
BUG=114148 TEST=browser_tests --gtest_filter=ExtensionApiTest.FontSettings Review URL: http://codereview.chromium.org/10142011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133405 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_font_settings_api.cc125
-rw-r--r--chrome/browser/extensions/extension_font_settings_api.h86
-rw-r--r--chrome/browser/extensions/extension_function_registry.cc2
-rw-r--r--chrome/common/extensions/api/experimental.fontSettings.json71
-rw-r--r--chrome/common/extensions/docs/experimental.fontSettings.html354
-rw-r--r--chrome/common/extensions/docs/samples.json3
-rw-r--r--chrome/test/data/extensions/api_test/font_settings/test.js22
7 files changed, 604 insertions, 59 deletions
diff --git a/chrome/browser/extensions/extension_font_settings_api.cc b/chrome/browser/extensions/extension_font_settings_api.cc
index 6102785..0b250d6 100644
--- a/chrome/browser/extensions/extension_font_settings_api.cc
+++ b/chrome/browser/extensions/extension_font_settings_api.cc
@@ -29,12 +29,15 @@
namespace {
-const char kGenericFamilyKey[] = "genericFamily";
+const char kCharsetKey[] = "charset";
const char kFontNameKey[] = "fontName";
+const char kGenericFamilyKey[] = "genericFamily";
const char kLocalizedNameKey[] = "localizedName";
const char kPixelSizeKey[] = "pixelSize";
const char kScriptKey[] = "script";
+const char kOnDefaultCharacterSetChanged[] =
+ "experimental.fontSettings.onDefaultCharacterSetChanged";
const char kOnDefaultFixedFontSizeChanged[] =
"experimental.fontSettings.onDefaultFixedFontSizeChanged";
const char kOnDefaultFontSizeChanged[] =
@@ -140,17 +143,18 @@ ExtensionFontSettingsEventRouter::~ExtensionFontSettingsEventRouter() {}
void ExtensionFontSettingsEventRouter::Init() {
registrar_.Init(profile_->GetPrefs());
- registrar_.Add(prefs::kWebKitGlobalDefaultFixedFontSize, this);
- pref_event_map_[prefs::kWebKitGlobalDefaultFixedFontSize] =
- kOnDefaultFixedFontSizeChanged;
-
- registrar_.Add(prefs::kWebKitGlobalDefaultFontSize, this);
- pref_event_map_[prefs::kWebKitGlobalDefaultFontSize] =
- kOnDefaultFontSizeChanged;
-
- registrar_.Add(prefs::kWebKitGlobalMinimumFontSize, this);
- pref_event_map_[prefs::kWebKitGlobalMinimumFontSize] =
- kOnMinimumFontSizeChanged;
+ AddPrefToObserve(prefs::kWebKitGlobalDefaultFixedFontSize,
+ kOnDefaultFixedFontSizeChanged,
+ kPixelSizeKey);
+ AddPrefToObserve(prefs::kWebKitGlobalDefaultFontSize,
+ kOnDefaultFontSizeChanged,
+ kPixelSizeKey);
+ AddPrefToObserve(prefs::kWebKitGlobalMinimumFontSize,
+ kOnMinimumFontSizeChanged,
+ kPixelSizeKey);
+ AddPrefToObserve(prefs::kGlobalDefaultCharset,
+ kOnDefaultCharacterSetChanged,
+ kCharsetKey);
registrar_.Add(prefs::kWebKitGlobalStandardFontFamily, this);
registrar_.Add(prefs::kWebKitGlobalSerifFontFamily, this);
@@ -172,6 +176,13 @@ void ExtensionFontSettingsEventRouter::Init() {
prefs::kWebKitFantasyFontFamilyMap, this);
}
+void ExtensionFontSettingsEventRouter::AddPrefToObserve(const char* pref_name,
+ const char* event_name,
+ const char* key) {
+ registrar_.Add(pref_name, this);
+ pref_event_map_[pref_name] = std::make_pair(event_name, key);
+}
+
void ExtensionFontSettingsEventRouter::Observe(
int type,
const content::NotificationSource& source,
@@ -185,19 +196,21 @@ void ExtensionFontSettingsEventRouter::Observe(
bool incognito = (pref_service != profile_->GetPrefs());
// We're only observing pref changes on the regular profile.
DCHECK(!incognito);
- const std::string* pref_key =
+ const std::string* pref_name =
content::Details<const std::string>(details).ptr();
- PrefEventMap::iterator iter = pref_event_map_.find(*pref_key);
+ PrefEventMap::iterator iter = pref_event_map_.find(*pref_name);
if (iter != pref_event_map_.end()) {
- OnFontSizePrefChanged(pref_service, *pref_key, iter->second, incognito);
+ const std::string& event_name = iter->second.first;
+ const std::string& key = iter->second.second;
+ OnFontPrefChanged(pref_service, *pref_name, event_name, key, incognito);
return;
}
std::string generic_family;
std::string script;
- if (ParseFontNamePrefPath(*pref_key, &generic_family, &script)) {
- OnFontNamePrefChanged(pref_service, *pref_key, generic_family, script,
+ if (ParseFontNamePrefPath(*pref_name, &generic_family, &script)) {
+ OnFontNamePrefChanged(pref_service, *pref_name, generic_family, script,
incognito);
return;
}
@@ -207,12 +220,12 @@ void ExtensionFontSettingsEventRouter::Observe(
void ExtensionFontSettingsEventRouter::OnFontNamePrefChanged(
PrefService* pref_service,
- const std::string& pref_key,
+ const std::string& pref_name,
const std::string& generic_family,
const std::string& script,
bool incognito) {
const PrefService::Preference* pref = pref_service->FindPreference(
- pref_key.c_str());
+ pref_name.c_str());
CHECK(pref);
std::string font_name;
@@ -236,28 +249,23 @@ void ExtensionFontSettingsEventRouter::OnFontNamePrefChanged(
&args,
ExtensionAPIPermission::kExperimental,
incognito,
- pref_key);
+ pref_name);
}
-void ExtensionFontSettingsEventRouter::OnFontSizePrefChanged(
+void ExtensionFontSettingsEventRouter::OnFontPrefChanged(
PrefService* pref_service,
- const std::string& pref_key,
+ const std::string& pref_name,
const std::string& event_name,
+ const std::string& key,
bool incognito) {
const PrefService::Preference* pref = pref_service->FindPreference(
- pref_key.c_str());
+ pref_name.c_str());
CHECK(pref);
- int size;
- if (!pref->GetValue()->GetAsInteger(&size)) {
- NOTREACHED();
- return;
- }
-
ListValue args;
DictionaryValue* dict = new DictionaryValue();
args.Append(dict);
- dict->SetInteger(kPixelSizeKey, size);
+ dict->Set(key, pref->GetValue()->DeepCopy());
extension_preference_helpers::DispatchEventToExtensions(
profile_,
@@ -265,7 +273,7 @@ void ExtensionFontSettingsEventRouter::OnFontSizePrefChanged(
&args,
ExtensionAPIPermission::kExperimental,
incognito,
- pref_key);
+ pref_name);
}
bool GetFontFunction::RunImpl() {
@@ -353,28 +361,29 @@ bool GetFontListFunction::CopyFontsToResult(ListValue* fonts) {
return true;
}
-bool GetFontSizeExtensionFunction::RunImpl() {
+bool GetFontPrefExtensionFunction::RunImpl() {
PrefService* prefs = profile_->GetPrefs();
- int size = prefs->GetInteger(GetPrefName());
+ const PrefService::Preference* pref = prefs->FindPreference(GetPrefName());
+ EXTENSION_FUNCTION_VALIDATE(pref);
DictionaryValue* result = new DictionaryValue();
- result->SetInteger(kPixelSizeKey, size);
+ result->Set(GetKey(), pref->GetValue()->DeepCopy());
result_.reset(result);
return true;
}
-bool SetFontSizeExtensionFunction::RunImpl() {
+bool SetFontPrefExtensionFunction::RunImpl() {
DictionaryValue* details = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
- int size;
- EXTENSION_FUNCTION_VALIDATE(details->GetInteger(kPixelSizeKey, &size));
+ Value* value;
+ EXTENSION_FUNCTION_VALIDATE(details->Get(GetKey(), &value));
ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs();
prefs->SetExtensionControlledPref(extension_id(),
GetPrefName(),
kExtensionPrefsScopeRegular,
- Value::CreateIntegerValue(size));
+ value->DeepCopy());
return true;
}
@@ -382,22 +391,62 @@ const char* GetDefaultFontSizeFunction::GetPrefName() {
return prefs::kWebKitGlobalDefaultFontSize;
}
+const char* GetDefaultFontSizeFunction::GetKey() {
+ return kPixelSizeKey;
+}
+
const char* SetDefaultFontSizeFunction::GetPrefName() {
return prefs::kWebKitGlobalDefaultFontSize;
}
+const char* SetDefaultFontSizeFunction::GetKey() {
+ return kPixelSizeKey;
+}
+
const char* GetDefaultFixedFontSizeFunction::GetPrefName() {
return prefs::kWebKitGlobalDefaultFixedFontSize;
}
+const char* GetDefaultFixedFontSizeFunction::GetKey() {
+ return kPixelSizeKey;
+}
+
const char* SetDefaultFixedFontSizeFunction::GetPrefName() {
return prefs::kWebKitGlobalDefaultFixedFontSize;
}
+const char* SetDefaultFixedFontSizeFunction::GetKey() {
+ return kPixelSizeKey;
+}
+
const char* GetMinimumFontSizeFunction::GetPrefName() {
return prefs::kWebKitGlobalMinimumFontSize;
}
+const char* GetMinimumFontSizeFunction::GetKey() {
+ return kPixelSizeKey;
+}
+
const char* SetMinimumFontSizeFunction::GetPrefName() {
return prefs::kWebKitGlobalMinimumFontSize;
}
+
+const char* SetMinimumFontSizeFunction::GetKey() {
+ return kPixelSizeKey;
+}
+
+const char* GetDefaultCharacterSetFunction::GetPrefName() {
+ return prefs::kGlobalDefaultCharset;
+}
+
+const char* GetDefaultCharacterSetFunction::GetKey() {
+ return kCharsetKey;
+}
+
+const char* SetDefaultCharacterSetFunction::GetPrefName() {
+ return prefs::kGlobalDefaultCharset;
+}
+
+const char* SetDefaultCharacterSetFunction::GetKey() {
+ return kCharsetKey;
+}
diff --git a/chrome/browser/extensions/extension_font_settings_api.h b/chrome/browser/extensions/extension_font_settings_api.h
index 8415f0e..5003c0b 100644
--- a/chrome/browser/extensions/extension_font_settings_api.h
+++ b/chrome/browser/extensions/extension_font_settings_api.h
@@ -19,26 +19,36 @@ class ExtensionFontSettingsEventRouter : public content::NotificationObserver {
void Init();
private:
- typedef std::map<std::string, std::string> PrefEventMap;
+ typedef std::pair<std::string, std::string> EventAndKeyPair;
+ // Map of pref name to a pair of event name and key (defined in the API) for
+ // dispatching a pref changed event. For example,
+ // "webkit.webprefs.default_font_size" to ("onDefaultFontSizedChanged",
+ // "pixelSize").
+ typedef std::map<std::string, EventAndKeyPair> PrefEventMap;
+
+ void AddPrefToObserve(const char* pref_name,
+ const char* event_name,
+ const char* key);
// content::NotificationObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+
void OnFontNamePrefChanged(PrefService* pref_service,
- const std::string& pref_key,
+ const std::string& pref_name,
const std::string& generic_family,
const std::string& script,
bool incognito);
- void OnFontSizePrefChanged(PrefService* pref_service,
- const std::string& pref_key,
- const std::string& event_name,
- bool incognito);
+ void OnFontPrefChanged(PrefService* pref_service,
+ const std::string& pref_name,
+ const std::string& event_name,
+ const std::string& key,
+ bool incognito);
PrefChangeRegistrar registrar_;
- // Map of pref key to event name.
- std::map<std::string, std::string> pref_event_map_;
+ PrefEventMap pref_event_map_;
// Weak, owns us (transitively via ExtensionService).
Profile* profile_;
@@ -68,76 +78,112 @@ class GetFontListFunction : public AsyncExtensionFunction {
bool CopyFontsToResult(base::ListValue* fonts);
};
-// Base class for functions that get a font size.
-class GetFontSizeExtensionFunction : public SyncExtensionFunction {
+// Base class for functions that get a font pref.
+class GetFontPrefExtensionFunction : public SyncExtensionFunction {
protected:
virtual bool RunImpl() OVERRIDE;
- // Implementations should return the name of the font size preference to get.
+ // Implementations should return the name of the preference to get, like
+ // "webkit.webprefs.default_font_size".
virtual const char* GetPrefName() = 0;
+
+ // Implementations should return the key for the value in the extension API,
+ // like "pixelSize".
+ virtual const char* GetKey() = 0;
};
-// Base class for functions that set a font size.
-class SetFontSizeExtensionFunction : public SyncExtensionFunction {
+// Base class for functions that set a font pref.
+class SetFontPrefExtensionFunction : public SyncExtensionFunction {
protected:
virtual bool RunImpl() OVERRIDE;
- // Implementations should return the name of the font size preference to set.
+ // Implementations should return the name of the preference to set, like
+ // "webkit.webprefs.default_font_size".
virtual const char* GetPrefName() = 0;
+
+ // Implementations should return the key for the value in the extension API,
+ // like "pixelSize".
+ virtual const char* GetKey() = 0;
};
-class GetDefaultFontSizeFunction : public GetFontSizeExtensionFunction {
+class GetDefaultFontSizeFunction : public GetFontPrefExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.fontSettings.getDefaultFontSize")
protected:
virtual const char* GetPrefName() OVERRIDE;
+ virtual const char* GetKey() OVERRIDE;
};
-class SetDefaultFontSizeFunction : public SetFontSizeExtensionFunction {
+class SetDefaultFontSizeFunction : public SetFontPrefExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.fontSettings.setDefaultFontSize")
protected:
virtual const char* GetPrefName() OVERRIDE;
+ virtual const char* GetKey() OVERRIDE;
};
-class GetDefaultFixedFontSizeFunction : public GetFontSizeExtensionFunction {
+class GetDefaultFixedFontSizeFunction : public GetFontPrefExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.fontSettings.getDefaultFixedFontSize")
protected:
virtual const char* GetPrefName() OVERRIDE;
+ virtual const char* GetKey() OVERRIDE;
};
-class SetDefaultFixedFontSizeFunction : public SetFontSizeExtensionFunction {
+class SetDefaultFixedFontSizeFunction : public SetFontPrefExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.fontSettings.setDefaultFixedFontSize")
protected:
virtual const char* GetPrefName() OVERRIDE;
+ virtual const char* GetKey() OVERRIDE;
};
-class GetMinimumFontSizeFunction : public GetFontSizeExtensionFunction {
+class GetMinimumFontSizeFunction : public GetFontPrefExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.fontSettings.getMinimumFontSize")
protected:
virtual const char* GetPrefName() OVERRIDE;
+ virtual const char* GetKey() OVERRIDE;
};
-class SetMinimumFontSizeFunction : public SetFontSizeExtensionFunction {
+class SetMinimumFontSizeFunction : public SetFontPrefExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.fontSettings.setMinimumFontSize")
protected:
virtual const char* GetPrefName() OVERRIDE;
+ virtual const char* GetKey() OVERRIDE;
+};
+
+class GetDefaultCharacterSetFunction : public GetFontPrefExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION_NAME(
+ "experimental.fontSettings.getDefaultCharacterSet")
+
+ protected:
+ virtual const char* GetPrefName() OVERRIDE;
+ virtual const char* GetKey() OVERRIDE;
+};
+
+class SetDefaultCharacterSetFunction : public SetFontPrefExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION_NAME(
+ "experimental.fontSettings.setDefaultCharacterSet")
+
+ protected:
+ virtual const char* GetPrefName() OVERRIDE;
+ virtual const char* GetKey() OVERRIDE;
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__
diff --git a/chrome/browser/extensions/extension_function_registry.cc b/chrome/browser/extensions/extension_function_registry.cc
index bae3c16..a7d3f8b 100644
--- a/chrome/browser/extensions/extension_function_registry.cc
+++ b/chrome/browser/extensions/extension_function_registry.cc
@@ -430,6 +430,8 @@ void ExtensionFunctionRegistry::ResetFunctions() {
RegisterFunction<SetDefaultFixedFontSizeFunction>();
RegisterFunction<GetMinimumFontSizeFunction>();
RegisterFunction<SetMinimumFontSizeFunction>();
+ RegisterFunction<GetDefaultCharacterSetFunction>();
+ RegisterFunction<SetDefaultCharacterSetFunction>();
// ChromeAuth settings.
RegisterFunction<SetCloudPrintCredentialsFunction>();
diff --git a/chrome/common/extensions/api/experimental.fontSettings.json b/chrome/common/extensions/api/experimental.fontSettings.json
index 9b9af41..7e880134 100644
--- a/chrome/common/extensions/api/experimental.fontSettings.json
+++ b/chrome/common/extensions/api/experimental.fontSettings.json
@@ -283,6 +283,57 @@
"parameters": []
}
]
+ },
+ {
+ "name": "getDefaultCharacterSet",
+ "description": "Gets the default character set.",
+ "parameters": [
+ {
+ "name": "details",
+ "type": "object",
+ "optional": true,
+ "description": "This parameter is currently unused."
+ },
+ {
+ "name": "callback",
+ "type": "function",
+ "optional": true,
+ "parameters": [
+ {
+ "name": "details",
+ "type": "object",
+ "properties": {
+ "charset": {
+ "type": "string",
+ "description": "The default character set, such as \"ISO-8859-1\"."
+ }
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "setDefaultCharacterSet",
+ "description": "Sets the default character set.",
+ "parameters": [
+ {
+ "name": "details",
+ "type": "object",
+ "properties": {
+ "charset": {
+ "type": "string",
+ "description": "The character set."
+ }
+ }
+ },
+ {
+ "name": "callback",
+ "type": "function",
+ "optional": true,
+ "parameters": []
+ }
+ ]
}
],
"events": [
@@ -371,6 +422,26 @@
}
}
]
+ },
+ {
+ "name": "onDefaultCharacterSetChanged",
+ "description": "Fired when the default character set setting changes.",
+ "parameters": [
+ {
+ "type": "object",
+ "name": "details",
+ "properties": {
+ "charset": {
+ "type": "string",
+ "description": "The character set."
+ },
+ "levelOfControl": {
+ "$ref": "LevelOfControl",
+ "description": "The level of control this extension has over the setting."
+ }
+ }
+ }
+ ]
}
]
}
diff --git a/chrome/common/extensions/docs/experimental.fontSettings.html b/chrome/common/extensions/docs/experimental.fontSettings.html
index f1598cd..fa8c27f 100644
--- a/chrome/common/extensions/docs/experimental.fontSettings.html
+++ b/chrome/common/extensions/docs/experimental.fontSettings.html
@@ -211,6 +211,8 @@
<a href="#global-methods">Methods</a>
<ol>
<li>
+ <a href="#method-getDefaultCharacterSet">getDefaultCharacterSet</a>
+ </li><li>
<a href="#method-getDefaultFixedFontSize">getDefaultFixedFontSize</a>
</li><li>
<a href="#method-getDefaultFontSize">getDefaultFontSize</a>
@@ -221,6 +223,8 @@
</li><li>
<a href="#method-getMinimumFontSize">getMinimumFontSize</a>
</li><li>
+ <a href="#method-setDefaultCharacterSet">setDefaultCharacterSet</a>
+ </li><li>
<a href="#method-setDefaultFixedFontSize">setDefaultFixedFontSize</a>
</li><li>
<a href="#method-setDefaultFontSize">setDefaultFontSize</a>
@@ -235,6 +239,8 @@
<a href="#global-events">Events</a>
<ol>
<li>
+ <a href="#event-onDefaultCharacterSetChanged">onDefaultCharacterSetChanged</a>
+ </li><li>
<a href="#event-onDefaultFixedFontSizeChanged">onDefaultFixedFontSizeChanged</a>
</li><li>
<a href="#event-onDefaultFontSizeChanged">onDefaultFontSizeChanged</a>
@@ -340,6 +346,144 @@ directory. For other examples and for help in viewing the source code, see
<h3>Methods</h3>
<!-- iterates over all functions -->
<div class="apiItem">
+ <a name="method-getDefaultCharacterSet"></a> <!-- method-anchor -->
+ <h4>getDefaultCharacterSet</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>chrome.experimental.fontSettings.getDefaultCharacterSet</span>(<span class="optional"><span>object</span>
+ <var><span>details</span></var></span><span class="optional"><span>, </span><span>function</span>
+ <var><span>callback</span></var></span>)</div>
+ <div class="description">
+ <p>Gets the default character set.</p>
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>details</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>object</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>This parameter is currently unused.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>callback</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>function</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <div>
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ If you specify the <em>callback</em> parameter, it should
+ specify a function that looks like this:
+ </p>
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span>object details</span>) <span class="subdued">{...}</span>;</pre>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>details</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>object</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <!-- OBJECT PROPERTIES -->
+ <dd>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>charset</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>The default character set, such as "ISO-8859-1".</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </dd>
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div>
+ </div>
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div><div class="apiItem">
<a name="method-getDefaultFixedFontSize"></a> <!-- method-anchor -->
<h4>getDefaultFixedFontSize</h4>
<div class="summary">
@@ -1035,6 +1179,119 @@ directory. For other examples and for help in viewing the source code, see
<!-- MIN_VERSION -->
</div> <!-- /description -->
</div><div class="apiItem">
+ <a name="method-setDefaultCharacterSet"></a> <!-- method-anchor -->
+ <h4>setDefaultCharacterSet</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>chrome.experimental.fontSettings.setDefaultCharacterSet</span>(<span class="null"><span>object</span>
+ <var><span>details</span></var></span><span class="optional"><span>, </span><span>function</span>
+ <var><span>callback</span></var></span>)</div>
+ <div class="description">
+ <p>Sets the default character set.</p>
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>details</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>object</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <!-- OBJECT PROPERTIES -->
+ <dd>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>charset</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>The character set.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </dd>
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>callback</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>function</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <div>
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ If you specify the <em>callback</em> parameter, it should
+ specify a function that looks like this:
+ </p>
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span></span>) <span class="subdued">{...}</span>;</pre>
+ <dl>
+ </dl>
+ </div>
+ </div>
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div><div class="apiItem">
<a name="method-setDefaultFixedFontSize"></a> <!-- method-anchor -->
<h4>setDefaultFixedFontSize</h4>
<div class="summary">
@@ -1541,6 +1798,103 @@ directory. For other examples and for help in viewing the source code, see
<h3>Events</h3>
<!-- iterates over all events -->
<div class="apiItem">
+ <a name="event-onDefaultCharacterSetChanged"></a>
+ <h4>onDefaultCharacterSetChanged</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span class="subdued">chrome.experimental.fontSettings.</span><span>onDefaultCharacterSetChanged</span><span class="subdued">.addListener</span>(function(<span>object details</span>) <span class="subdued">{...}</span><span></span>);
+ </div>
+ <div class="description">
+ <p>Fired when the default character set setting changes.</p>
+ <!-- LISTENER PARAMETERS -->
+ <div>
+ <h4>Listener parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>details</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>object</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <!-- OBJECT PROPERTIES -->
+ <dd>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>charset</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>The character set.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>levelOfControl</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <a href="experimental.fontSettings.html#type-LevelOfControl">LevelOfControl</a>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>The level of control this extension has over the setting.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </dd>
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div>
+ <!-- EXTRA PARAMETERS -->
+ <!-- LISTENER RETURN VALUE -->
+ <dl>
+ </dl>
+ </div> <!-- /description -->
+ </div><div class="apiItem">
<a name="event-onDefaultFixedFontSizeChanged"></a>
<h4>onDefaultFixedFontSizeChanged</h4>
<div class="summary">
diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json
index 37f3fed..2346e14 100644
--- a/chrome/common/extensions/docs/samples.json
+++ b/chrome/common/extensions/docs/samples.json
@@ -121,15 +121,18 @@
"chrome.experimental.devtools.console.onMessageAdded": "experimental.devtools.console.html#event-onMessageAdded",
"chrome.experimental.dns.resolve": "experimental.dns.html#method-resolve",
"chrome.experimental.downloads.download": "experimental.downloads.html#method-download",
+ "chrome.experimental.fontSettings.getDefaultCharacterSet": "experimental.fontSettings.html#method-getDefaultCharacterSet",
"chrome.experimental.fontSettings.getDefaultFixedFontSize": "experimental.fontSettings.html#method-getDefaultFixedFontSize",
"chrome.experimental.fontSettings.getDefaultFontSize": "experimental.fontSettings.html#method-getDefaultFontSize",
"chrome.experimental.fontSettings.getFont": "experimental.fontSettings.html#method-getFont",
"chrome.experimental.fontSettings.getFontList": "experimental.fontSettings.html#method-getFontList",
"chrome.experimental.fontSettings.getMinimumFontSize": "experimental.fontSettings.html#method-getMinimumFontSize",
+ "chrome.experimental.fontSettings.onDefaultCharacterSetChanged": "experimental.fontSettings.html#event-onDefaultCharacterSetChanged",
"chrome.experimental.fontSettings.onDefaultFixedFontSizeChanged": "experimental.fontSettings.html#event-onDefaultFixedFontSizeChanged",
"chrome.experimental.fontSettings.onDefaultFontSizeChanged": "experimental.fontSettings.html#event-onDefaultFontSizeChanged",
"chrome.experimental.fontSettings.onFontChanged": "experimental.fontSettings.html#event-onFontChanged",
"chrome.experimental.fontSettings.onMinimumFontSizeChanged": "experimental.fontSettings.html#event-onMinimumFontSizeChanged",
+ "chrome.experimental.fontSettings.setDefaultCharacterSet": "experimental.fontSettings.html#method-setDefaultCharacterSet",
"chrome.experimental.fontSettings.setDefaultFixedFontSize": "experimental.fontSettings.html#method-setDefaultFixedFontSize",
"chrome.experimental.fontSettings.setDefaultFontSize": "experimental.fontSettings.html#method-setDefaultFontSize",
"chrome.experimental.fontSettings.setFont": "experimental.fontSettings.html#method-setFont",
diff --git a/chrome/test/data/extensions/api_test/font_settings/test.js b/chrome/test/data/extensions/api_test/font_settings/test.js
index 33994ef..b08bef8 100644
--- a/chrome/test/data/extensions/api_test/font_settings/test.js
+++ b/chrome/test/data/extensions/api_test/font_settings/test.js
@@ -130,6 +130,20 @@ chrome.test.runTests([
}, chrome.test.callbackPass());
},
+ function setDefaultCharacterSet() {
+ var charset = 'GBK';
+ chrome.test.listenOnce(fs.onDefaultCharacterSetChanged, function(details) {
+ chrome.test.assertEq(details, {
+ charset: charset,
+ levelOfControl: 'controlled_by_this_extension'
+ });
+ });
+
+ fs.setDefaultCharacterSet({
+ charset: charset
+ }, chrome.test.callbackPass());
+ },
+
function getDefaultFontSize() {
var expected = 22;
var message = 'Setting for default font size should be ' + expected;
@@ -152,5 +166,11 @@ chrome.test.runTests([
var expected = 7;
var message = 'Setting for minimum font size should be ' + expected;
fs.getMinimumFontSize({}, expect({pixelSize: expected}, message));
- }
+ },
+
+ function getDefaultCharacterSet() {
+ var expected = 'GBK';
+ var message = 'Setting for default character set should be ' + expected;
+ fs.getDefaultCharacterSet(expect({charset: expected}, message));
+ },
]);