Commit db8a4433 authored by falken@google.com's avatar falken@google.com

Font Settings Extension API: Rename get/setFontName to get/setFont.

BUG=none
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10108007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132535 0039d316-1c4b-4281-b951-d872f2087c98
parent aa5b3ee5
...@@ -34,8 +34,7 @@ const char kLocalizedNameKey[] = "localizedName"; ...@@ -34,8 +34,7 @@ const char kLocalizedNameKey[] = "localizedName";
const char kPixelSizeKey[] = "pixelSize"; const char kPixelSizeKey[] = "pixelSize";
const char kScriptKey[] = "script"; const char kScriptKey[] = "script";
const char kOnFontNameChanged[] = const char kOnFontChanged[] = "experimental.fontSettings.onFontChanged";
"experimental.fontSettings.onFontNameChanged";
// Format for per-script font preference keys. // Format for per-script font preference keys.
// E.g., "webkit.webprefs.fonts.standard.Hrkt" // E.g., "webkit.webprefs.fonts.standard.Hrkt"
...@@ -196,14 +195,14 @@ void ExtensionFontSettingsEventRouter::Observe( ...@@ -196,14 +195,14 @@ void ExtensionFontSettingsEventRouter::Observe(
extension_preference_helpers::DispatchEventToExtensions( extension_preference_helpers::DispatchEventToExtensions(
profile_, profile_,
kOnFontNameChanged, kOnFontChanged,
&args, &args,
ExtensionAPIPermission::kExperimental, ExtensionAPIPermission::kExperimental,
incognito, incognito,
*pref_key); *pref_key);
} }
bool GetFontNameFunction::RunImpl() { bool GetFontFunction::RunImpl() {
DictionaryValue* details = NULL; DictionaryValue* details = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
...@@ -225,7 +224,7 @@ bool GetFontNameFunction::RunImpl() { ...@@ -225,7 +224,7 @@ bool GetFontNameFunction::RunImpl() {
return true; return true;
} }
bool SetFontNameFunction::RunImpl() { bool SetFontFunction::RunImpl() {
DictionaryValue* details = NULL; DictionaryValue* details = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
......
...@@ -30,16 +30,16 @@ class ExtensionFontSettingsEventRouter : public content::NotificationObserver { ...@@ -30,16 +30,16 @@ class ExtensionFontSettingsEventRouter : public content::NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(ExtensionFontSettingsEventRouter); DISALLOW_COPY_AND_ASSIGN(ExtensionFontSettingsEventRouter);
}; };
class GetFontNameFunction : public SyncExtensionFunction { class GetFontFunction : public SyncExtensionFunction {
public: public:
virtual bool RunImpl() OVERRIDE; virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFontName") DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFont")
}; };
class SetFontNameFunction : public SyncExtensionFunction { class SetFontFunction : public SyncExtensionFunction {
public: public:
virtual bool RunImpl() OVERRIDE; virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.setFontName") DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.setFont")
}; };
class GetFontListFunction : public AsyncExtensionFunction { class GetFontListFunction : public AsyncExtensionFunction {
......
...@@ -423,8 +423,8 @@ void ExtensionFunctionRegistry::ResetFunctions() { ...@@ -423,8 +423,8 @@ void ExtensionFunctionRegistry::ResetFunctions() {
// Font settings. // Font settings.
RegisterFunction<GetFontListFunction>(); RegisterFunction<GetFontListFunction>();
RegisterFunction<GetFontNameFunction>(); RegisterFunction<GetFontFunction>();
RegisterFunction<SetFontNameFunction>(); RegisterFunction<SetFontFunction>();
RegisterFunction<GetDefaultFontSizeFunction>(); RegisterFunction<GetDefaultFontSizeFunction>();
RegisterFunction<SetDefaultFontSizeFunction>(); RegisterFunction<SetDefaultFontSizeFunction>();
RegisterFunction<GetDefaultFixedFontSizeFunction>(); RegisterFunction<GetDefaultFixedFontSizeFunction>();
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
], ],
"functions": [ "functions": [
{ {
"name": "getFontName", "name": "getFont",
"description": "Gets the font name of the current setting for a given script and generic font family.", "description": "Gets the current font setting for a given script and generic font family.",
"parameters": [ "parameters": [
{ {
"name": "details", "name": "details",
...@@ -78,8 +78,8 @@ ...@@ -78,8 +78,8 @@
] ]
}, },
{ {
"name": "setFontName", "name": "setFont",
"description": "Sets the font name of the current setting for a given script and generic font family.", "description": "Sets the font setting for a given script and generic font family.",
"parameters": [ "parameters": [
{ {
"name": "details", "name": "details",
...@@ -281,8 +281,8 @@ ...@@ -281,8 +281,8 @@
], ],
"events": [ "events": [
{ {
"name": "onFontNameChanged", "name": "onFontChanged",
"description": "Fired when a font name preference changes.", "description": "Fired when a font setting changes.",
"parameters": [ "parameters": [
{ {
"type": "object", "type": "object",
......
...@@ -61,7 +61,7 @@ function getFontChangeHandler(fontList, genericFamily) { ...@@ -61,7 +61,7 @@ function getFontChangeHandler(fontList, genericFamily) {
if (script != DEFAULT_SCRIPT) if (script != DEFAULT_SCRIPT)
details.script = script; details.script = script;
chrome.experimental.fontSettings.setFontName(details); chrome.experimental.fontSettings.setFont(details);
}; };
} }
...@@ -82,8 +82,8 @@ function setSelectedFont(fontList, fontName) { ...@@ -82,8 +82,8 @@ function setSelectedFont(fontList, fontName) {
} }
// Returns a callback function that sets the selected value of |list| to the // Returns a callback function that sets the selected value of |list| to the
// font returned from |chrome.experimental.fontSettings.getFontName|. // font returned from |chrome.experimental.fontSettings.getFont|.
function getFontNameHandler(list) { function getFontHandler(list) {
return function(details) { return function(details) {
setSelectedFont(list, details.fontName); setSelectedFont(list, details.fontName);
}; };
...@@ -102,8 +102,8 @@ function updateListSelections() { ...@@ -102,8 +102,8 @@ function updateListSelections() {
if (script != DEFAULT_SCRIPT) if (script != DEFAULT_SCRIPT)
details.script = script; details.script = script;
chrome.experimental.fontSettings.getFontName(details, chrome.experimental.fontSettings.getFont(details,
getFontNameHandler(list)); getFontHandler(list));
} }
} }
......
...@@ -122,13 +122,13 @@ ...@@ -122,13 +122,13 @@
"chrome.experimental.downloads.download": "experimental.downloads.html#method-download", "chrome.experimental.downloads.download": "experimental.downloads.html#method-download",
"chrome.experimental.fontSettings.getDefaultFixedFontSize": "experimental.fontSettings.html#method-getDefaultFixedFontSize", "chrome.experimental.fontSettings.getDefaultFixedFontSize": "experimental.fontSettings.html#method-getDefaultFixedFontSize",
"chrome.experimental.fontSettings.getDefaultFontSize": "experimental.fontSettings.html#method-getDefaultFontSize", "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.getFontList": "experimental.fontSettings.html#method-getFontList",
"chrome.experimental.fontSettings.getFontName": "experimental.fontSettings.html#method-getFontName",
"chrome.experimental.fontSettings.getMinimumFontSize": "experimental.fontSettings.html#method-getMinimumFontSize", "chrome.experimental.fontSettings.getMinimumFontSize": "experimental.fontSettings.html#method-getMinimumFontSize",
"chrome.experimental.fontSettings.onFontNameChanged": "experimental.fontSettings.html#event-onFontNameChanged", "chrome.experimental.fontSettings.onFontChanged": "experimental.fontSettings.html#event-onFontChanged",
"chrome.experimental.fontSettings.setDefaultFixedFontSize": "experimental.fontSettings.html#method-setDefaultFixedFontSize", "chrome.experimental.fontSettings.setDefaultFixedFontSize": "experimental.fontSettings.html#method-setDefaultFixedFontSize",
"chrome.experimental.fontSettings.setDefaultFontSize": "experimental.fontSettings.html#method-setDefaultFontSize", "chrome.experimental.fontSettings.setDefaultFontSize": "experimental.fontSettings.html#method-setDefaultFontSize",
"chrome.experimental.fontSettings.setFontName": "experimental.fontSettings.html#method-setFontName", "chrome.experimental.fontSettings.setFont": "experimental.fontSettings.html#method-setFont",
"chrome.experimental.fontSettings.setMinimumFontSize": "experimental.fontSettings.html#method-setMinimumFontSize", "chrome.experimental.fontSettings.setMinimumFontSize": "experimental.fontSettings.html#method-setMinimumFontSize",
"chrome.experimental.infobars.show": "experimental.infobars.html#method-show", "chrome.experimental.infobars.show": "experimental.infobars.html#method-show",
"chrome.experimental.keybinding.onCommand": "experimental.keybinding.html#event-onCommand", "chrome.experimental.keybinding.onCommand": "experimental.keybinding.html#event-onCommand",
...@@ -1079,10 +1079,10 @@ ...@@ -1079,10 +1079,10 @@
{ {
"api_calls": [ "api_calls": [
"chrome.experimental.fontSettings.getDefaultFontSize", "chrome.experimental.fontSettings.getDefaultFontSize",
"chrome.experimental.fontSettings.getFont",
"chrome.experimental.fontSettings.getFontList", "chrome.experimental.fontSettings.getFontList",
"chrome.experimental.fontSettings.getFontName",
"chrome.experimental.fontSettings.setDefaultFontSize", "chrome.experimental.fontSettings.setDefaultFontSize",
"chrome.experimental.fontSettings.setFontName" "chrome.experimental.fontSettings.setFont"
], ],
"crx_path": null, "crx_path": null,
"description": "Sample extension for Font Settings API", "description": "Sample extension for Font Settings API",
...@@ -1097,13 +1097,13 @@ ...@@ -1097,13 +1097,13 @@
"packaged_app": false, "packaged_app": false,
"path": "examples\/api\/fontSettings\/", "path": "examples\/api\/fontSettings\/",
"protocols": [], "protocols": [],
"search_string": "FONT SETTINGS SAMPLE EXTENSION FOR FONT SETTINGS API BROWSER_ACTION EXPERIMENTAL POPUP CHROME.EXPERIMENTAL.FONTSETTINGS.GETDEFAULTFONTSIZE CHROME.EXPERIMENTAL.FONTSETTINGS.GETFONTLIST CHROME.EXPERIMENTAL.FONTSETTINGS.GETFONTNAME CHROME.EXPERIMENTAL.FONTSETTINGS.SETDEFAULTFONTSIZE CHROME.EXPERIMENTAL.FONTSETTINGS.SETFONTNAME", "search_string": "FONT SETTINGS SAMPLE EXTENSION FOR FONT SETTINGS API BROWSER_ACTION EXPERIMENTAL POPUP CHROME.EXPERIMENTAL.FONTSETTINGS.GETDEFAULTFONTSIZE CHROME.EXPERIMENTAL.FONTSETTINGS.GETFONT CHROME.EXPERIMENTAL.FONTSETTINGS.GETFONTLIST CHROME.EXPERIMENTAL.FONTSETTINGS.SETDEFAULTFONTSIZE CHROME.EXPERIMENTAL.FONTSETTINGS.SETFONT",
"source_files": [ "source_files": [
"manifest.json", "manifest.json",
"popup.html", "popup.html",
"popup.js" "popup.js"
], ],
"source_hash": "b5febada226fcd2d38461121c039c55ebcb3decf", "source_hash": "5dab5f989ab4e02b4b184f189d1e061102d5add6",
"zip_path": "examples\/api\/fontSettings.zip" "zip_path": "examples\/api\/fontSettings.zip"
}, },
{ {
......
...@@ -42,7 +42,7 @@ to use for compatibility purposes.</p> ...@@ -42,7 +42,7 @@ to use for compatibility purposes.</p>
<h2 id="examples">Examples</h2> <h2 id="examples">Examples</h2>
<p>The following code gets the standard font for Arabic.</p> <p>The following code gets the standard font for Arabic.</p>
<pre> <pre>
chrome.experimental.fontSettings.getFontName( chrome.experimental.fontSettings.getFont(
{ genericFamily: 'standard', script: 'Arab' }, { genericFamily: 'standard', script: 'Arab' },
function(details) { console.log(details.fontName); } function(details) { console.log(details.fontName); }
); );
...@@ -50,7 +50,7 @@ chrome.experimental.fontSettings.getFontName( ...@@ -50,7 +50,7 @@ chrome.experimental.fontSettings.getFontName(
<p>The next snippet sets the sans-serif font for Japanese.</p> <p>The next snippet sets the sans-serif font for Japanese.</p>
<pre> <pre>
chrome.experimental.fontSettings.setFontName( chrome.experimental.fontSettings.setFont(
{ genericFamily: 'sansserif', script: 'Hrkt', fontName: 'IPAPGothic' } { genericFamily: 'sansserif', script: 'Hrkt', fontName: 'IPAPGothic' }
); );
</pre> </pre>
......
...@@ -16,12 +16,12 @@ function expect(expected, message) { ...@@ -16,12 +16,12 @@ function expect(expected, message) {
chrome.test.runTests([ chrome.test.runTests([
// This test may fail on Windows if the font is not installed on the // This test may fail on Windows if the font is not installed on the
// system. See crbug.com/122303 // system. See crbug.com/122303
function setPerScriptFontName() { function setPerScriptFont() {
var script = 'Hang'; var script = 'Hang';
var genericFamily = 'standard'; var genericFamily = 'standard';
var fontName = 'Verdana'; var fontName = 'Verdana';
chrome.test.listenOnce(fs.onFontNameChanged, function(details) { chrome.test.listenOnce(fs.onFontChanged, function(details) {
chrome.test.assertEq(details, { chrome.test.assertEq(details, {
script: script, script: script,
genericFamily: genericFamily, genericFamily: genericFamily,
...@@ -30,7 +30,7 @@ chrome.test.runTests([ ...@@ -30,7 +30,7 @@ chrome.test.runTests([
}); });
}); });
fs.setFontName({ fs.setFont({
script: script, script: script,
genericFamily: genericFamily, genericFamily: genericFamily,
fontName: fontName fontName: fontName
...@@ -41,7 +41,7 @@ chrome.test.runTests([ ...@@ -41,7 +41,7 @@ chrome.test.runTests([
var expected = 'Verdana'; var expected = 'Verdana';
var message = 'Setting for Hangul standard font should be ' + expected; var message = 'Setting for Hangul standard font should be ' + expected;
fs.getFontName({ fs.getFont({
script: 'Hang', script: 'Hang',
genericFamily: 'standard' genericFamily: 'standard'
}, expect({fontName: expected}, message)); }, expect({fontName: expected}, message));
...@@ -53,7 +53,7 @@ chrome.test.runTests([ ...@@ -53,7 +53,7 @@ chrome.test.runTests([
var fontName = 'Tahoma'; var fontName = 'Tahoma';
var genericFamily = 'sansserif'; var genericFamily = 'sansserif';
chrome.test.listenOnce(fs.onFontNameChanged, function(details) { chrome.test.listenOnce(fs.onFontChanged, function(details) {
chrome.test.assertEq(details, { chrome.test.assertEq(details, {
genericFamily: genericFamily, genericFamily: genericFamily,
fontName: fontName, fontName: fontName,
...@@ -61,7 +61,7 @@ chrome.test.runTests([ ...@@ -61,7 +61,7 @@ chrome.test.runTests([
}); });
}); });
fs.setFontName({ fs.setFont({
genericFamily: 'sansserif', genericFamily: 'sansserif',
fontName: 'Tahoma' fontName: 'Tahoma'
}, chrome.test.callbackPass()); }, chrome.test.callbackPass());
...@@ -72,7 +72,7 @@ chrome.test.runTests([ ...@@ -72,7 +72,7 @@ chrome.test.runTests([
var message = var message =
'Setting for global sansserif font should be ' + expected; 'Setting for global sansserif font should be ' + expected;
fs.getFontName({ fs.getFont({
genericFamily: 'sansserif' genericFamily: 'sansserif'
}, expect({fontName: expected}, message)); }, expect({fontName: expected}, message));
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment