Chrome扩展开发教程(七)themes(主题制作)
在Chrome中,主题当做一个特殊的插件处理。主题要像普通文件一样打包,但是主题中不包含HTML或者JavaScript代码。
你可以在主题库里找到一些主题下载。
下面只是简单介绍下主题制作,详细的内容可以参考http://code.google.com/p/chromium/wiki/ThemeCreationGuide
主题是在Manifest文件中定义的。下面是个定义主题的典型例子:
{
"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"
}
}
}
我们看到在theme类下有几个元素,分为为images、colors、tints、properties。下面分别介绍他们。
colors:用来定义基本颜色。颜色需要用RGB格式表示,你可以在browser_theme_provider.cc查看到底可以定义哪些内容。
images:图 片需要用相对地址引用,你设置browser_theme_provider.cc文件中kThemeableImages数组的所有元素。去掉IDR_ 并且转化成小写格式后就是你需要设置的东西,比如IDR_THEME_NTP_BACKGROUND 需要转化为theme_ntp_background。
properties:这个地方用来定义诸如背景定位方式、背景重复等属性。browser_theme_provider.cc里面可以看到有哪些属性可以定义。
tints:你可以给部分UI着色,比如按钮、框架、背景tab标签。(这里翻译可能有问题,chromechina注)
原文 http://code.google.com/chrome/extensions/themes.html由ChromeChina翻译,转载注明出处http://dev.chromechina.com/
加支付宝好友偷能量挖...