该页面翻译自 Google Chrome Extensions 与 Google Chrome Apps。除非特别说明,该页面的内容遵循 Creative Commons Attribution 3.0 License,代码示例遵循 BSD License。
主题背景是一种特殊的扩展程序,可以改变浏览器的外观。主题背景的打包与普通的扩展程序类似,但是它们不包含 JavaScript 或 HTML 代码。
您可以在 Chrome 网上应用店中寻找与尝试各种主题背景。
以下是用于主题背景的
manifest.json
例子:
{
"version": "2.6",
"name": "camo theme",
"theme": {
"images" : {
"theme_frame" : "images/theme_frame_camo.png",
"theme_frame_overlay" : "images/theme_frame_stripe.png",
"theme_toolbar" : "images/theme_toolbar_camo.png",
"theme_ntp_background" : "images/theme_ntp_background_norepeat.png",
"theme_ntp_attribution" : "images/attribution.png"
},
"colors" : {
"frame" : [71, 105, 91],
"toolbar" : [207, 221, 192],
"ntp_text" : [20, 40, 0],
"ntp_link" : [36, 70, 0],
"ntp_section" : [207, 221, 192],
"button_background" : [255, 255, 255]
},
"tints" : {
"buttons" : [0.33, 0.5, 0.47]
},
"properties" : {
"ntp_background_alignment" : "bottom"
}
}
}
颜色以 RGB 形式表示。您可以在
theme_service.cc
文件中 kColor* 字符串部分找到您可以在此使用的字符串。
图片资源使用相对于扩展程序根目录的路径。您可以替换
theme_service.cc
文件中 kThemeableImages
指定的任何图片,只要将“IDR_”删除并将剩余字符转换为小写。例如,IDR_THEME_NTP_BACKGROUND(kThemeableImages
用来指定新标签窗格的背景)对应 "theme_ntp_background"。
这一字段让您指定诸如背景对齐、背景重复、替代标志等属性。有关属性的名称以及它们的值,请参见
theme_service.cc。
您可以指定应用于用户界面某些部分的色调,例如按钮、框架和后台标签页。Google Chrome
浏览器支持色调而不是图片,因为图片不一定能跨平台使用,并且在增加新按钮时不适用。有关您可以在
"tints" 中使用的字符串,请在
theme_service.cc
中寻找 kTint* 字符串。
色调以色调-饱和度-亮度(HSL)的格式指定,使用 0~1.0 之间的浮点数:
您还可以对任意 HSL 值使用 -1.0 表示没有变化。
由社区编写的帮您编写主题背景的文档在这里(英文):
https://code.google.com/p/chromium/wiki/ThemeCreationGuide