预置Chrome浏览器默认主页和书签
2015-09-24 19:41
597 查看
谷歌允许合作伙伴客制化Chrome的一些配置,如Chrome浏览器预置默认主页及书签,当预置成功后,将在状态栏看到主页的图标,可设置主页、主页的开启及关闭,可通过书签快捷打开对应网页。
客制化主要通过添加对应ChromeCustomizations.apk(主页) 及PartnerBookmarksProvider.apk(书签)来实现,具体实现方法如下:
一、预置chrome默认主页(http://www.baidu.com)
1)下载homepage_provider_example工程,修改默认主页URL
文件路径:src\com\android\partnerbrowsercustomizations\example\PartnerHomepageProviderExample.java
[java] view
plaincopy
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package path can be changed, but should match <manifest package="..."> in AndroidManifest.xml.
package com.android.partnerbrowsercustomizations.example;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
// Class name can be changed, but should match <provider android:name="..."> in AndroidManifest.xml.
public class PartnerHomepageProviderExample extends ContentProvider {
// "http://www.android.com/" is just an example. Please replace this to actual homepage.
// Other strings in this class must remain as it is.
private static String HOMEPAGE_URI = "http://www.baidu.com";
private static final int URI_MATCH_HOMEPAGE = 0;
private static final UriMatcher URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
static {
URI_MATCHER.addURI("com.android.partnerbrowsercustomizations", "homepage",
URI_MATCH_HOMEPAGE);
}
@Override
public boolean onCreate() {
return true;
}
@Override
public String getType(Uri uri) {
// In fact, Chrome does not call this.
// Just a recommaned ContentProvider practice in general.
switch (URI_MATCHER.match(uri)) {
case URI_MATCH_HOMEPAGE:
return "vnd.android.cursor.item/partnerhomepage";
default:
return null;
}
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
switch (URI_MATCHER.match(uri)) {
case URI_MATCH_HOMEPAGE:
MatrixCursor cursor = new MatrixCursor(new String[] { "homepage" }, 1);
cursor.addRow(new Object[] { HOMEPAGE_URI });
return cursor;
default:
return null;
}
}
@Override
public Uri insert(Uri uri, ContentValues values) {
throw new UnsupportedOperationException();
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
throw new UnsupportedOperationException();
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
throw new UnsupportedOperationException();
}
}
2)编译工程,并push生成的apk到system/vendor/app/ 目录
由于工程编译出来的名称为:homepage_provider_example.apk,所以push时要修改apk的名称为:ChromeCustomizations.apk,可用以下命令:
adb push homepage_provider_example.apk system/vendor/app/ChromeCustomizations.apk
二、预置默认书签
1)下载PartnerBookmarksProvider工程(该工程也可在源码下找到,目录路径为:packages\providers\PartnerBookmarksProvider)
2)添加书签图片资源,目录路径为res\raw
3)添加书签名称及对应的网址,目录路径为:res\values\strings.xml
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Bookmarks -->
<string name="bookmarks_folder_name">Default Bookmarks</string>
<string-array name="bookmarks">
<item>Google</item>
<item>http://www.google.com/</item>
<item>Yahoo</item>
<item>http://www.yahoo.com/</item>
<item>Picasa</item>
<item>http://picasaweb.google.com/</item>
<item>MSN</item>
<item>http://www.msn.com/</item>
<item>Twitter</item>
<item>http://twitter.com/</item>
<item>Facebook</item>
<item>http://www.facebook.com/</item>
<item>Wikipedia</item>
<item>http://www.wikipedia.org/</item>
<item>eBay</item>
<item>http://www.ebay.com/</item>
<item>CNN</item>
<item>http://www.cnn.com/</item>
<item>NY Times</item>
<item>http://www.nytimes.com/</item>
<item>ESPN</item>
<item>http://espn.com/</item>
<item>Amazon</item>
<item>http://www.amazon.com/</item>
<item>Weather Channel</item>
<item>http://www.weather.com/</item>
<item>BBC</item>
<item>http://www.bbc.co.uk/</item>
</string-array>
</resources>
4)添加书签对应的图标,目录路径为:res\values\bookmarks_icons.xml
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<array name="bookmark_preloads">
<item>@raw/favicon_google</item>
<item>@raw/touch_google</item>
<item>@raw/favicon_yahoo</item>
<item>@raw/thumb_yahoo</item>
<item>@raw/favicon_picasa</item>
<item>@raw/thumb_picasa</item>
<item>@raw/favicon_msn</item>
<item>@raw/thumb_msn</item>
<item>@raw/favicon_twitter</item>
<item>@raw/thumb_twitter</item>
<item>@raw/favicon_facebook</item>
<item>@raw/thumb_facebook</item>
<item>@raw/favicon_wikipedia</item>
<item>@raw/thumb_wikipedia</item>
<item>@raw/favicon_ebay</item>
<item>@raw/thumb_ebay</item>
<item>@raw/favicon_cnn</item>
<item>@raw/thumb_cnn</item>
<item>@raw/favicon_nytimes</item>
<item>@raw/thumb_nytimes</item>
<item>@raw/favicon_espn</item>
<item>@raw/thumb_espn</item>
<item>@raw/favicon_amazon</item>
<item>@raw/thumb_amazon</item>
<item>@raw/favicon_weatherchannel</item>
<item>@raw/thumb_weatherchannel</item>
<item>@raw/favicon_bbc</item>
<item>@raw/thumb_bbc</item>
</array>
</resources>
5)编译工程,并把工程push到system/app目录下,可用以下命令:
adb push PartnerBookmarksProvider.apk system/app
三、最终结果:
注:资源文件下载 http://download.csdn.net/detail/jiulousanti/7828169
客制化主要通过添加对应ChromeCustomizations.apk(主页) 及PartnerBookmarksProvider.apk(书签)来实现,具体实现方法如下:
一、预置chrome默认主页(http://www.baidu.com)
1)下载homepage_provider_example工程,修改默认主页URL
文件路径:src\com\android\partnerbrowsercustomizations\example\PartnerHomepageProviderExample.java
[java] view
plaincopy
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package path can be changed, but should match <manifest package="..."> in AndroidManifest.xml.
package com.android.partnerbrowsercustomizations.example;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
// Class name can be changed, but should match <provider android:name="..."> in AndroidManifest.xml.
public class PartnerHomepageProviderExample extends ContentProvider {
// "http://www.android.com/" is just an example. Please replace this to actual homepage.
// Other strings in this class must remain as it is.
private static String HOMEPAGE_URI = "http://www.baidu.com";
private static final int URI_MATCH_HOMEPAGE = 0;
private static final UriMatcher URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
static {
URI_MATCHER.addURI("com.android.partnerbrowsercustomizations", "homepage",
URI_MATCH_HOMEPAGE);
}
@Override
public boolean onCreate() {
return true;
}
@Override
public String getType(Uri uri) {
// In fact, Chrome does not call this.
// Just a recommaned ContentProvider practice in general.
switch (URI_MATCHER.match(uri)) {
case URI_MATCH_HOMEPAGE:
return "vnd.android.cursor.item/partnerhomepage";
default:
return null;
}
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
switch (URI_MATCHER.match(uri)) {
case URI_MATCH_HOMEPAGE:
MatrixCursor cursor = new MatrixCursor(new String[] { "homepage" }, 1);
cursor.addRow(new Object[] { HOMEPAGE_URI });
return cursor;
default:
return null;
}
}
@Override
public Uri insert(Uri uri, ContentValues values) {
throw new UnsupportedOperationException();
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
throw new UnsupportedOperationException();
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
throw new UnsupportedOperationException();
}
}
2)编译工程,并push生成的apk到system/vendor/app/ 目录
由于工程编译出来的名称为:homepage_provider_example.apk,所以push时要修改apk的名称为:ChromeCustomizations.apk,可用以下命令:
adb push homepage_provider_example.apk system/vendor/app/ChromeCustomizations.apk
二、预置默认书签
1)下载PartnerBookmarksProvider工程(该工程也可在源码下找到,目录路径为:packages\providers\PartnerBookmarksProvider)
2)添加书签图片资源,目录路径为res\raw
3)添加书签名称及对应的网址,目录路径为:res\values\strings.xml
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Bookmarks -->
<string name="bookmarks_folder_name">Default Bookmarks</string>
<string-array name="bookmarks">
<item>Google</item>
<item>http://www.google.com/</item>
<item>Yahoo</item>
<item>http://www.yahoo.com/</item>
<item>Picasa</item>
<item>http://picasaweb.google.com/</item>
<item>MSN</item>
<item>http://www.msn.com/</item>
<item>Twitter</item>
<item>http://twitter.com/</item>
<item>Facebook</item>
<item>http://www.facebook.com/</item>
<item>Wikipedia</item>
<item>http://www.wikipedia.org/</item>
<item>eBay</item>
<item>http://www.ebay.com/</item>
<item>CNN</item>
<item>http://www.cnn.com/</item>
<item>NY Times</item>
<item>http://www.nytimes.com/</item>
<item>ESPN</item>
<item>http://espn.com/</item>
<item>Amazon</item>
<item>http://www.amazon.com/</item>
<item>Weather Channel</item>
<item>http://www.weather.com/</item>
<item>BBC</item>
<item>http://www.bbc.co.uk/</item>
</string-array>
</resources>
4)添加书签对应的图标,目录路径为:res\values\bookmarks_icons.xml
[html] view
plaincopy
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<array name="bookmark_preloads">
<item>@raw/favicon_google</item>
<item>@raw/touch_google</item>
<item>@raw/favicon_yahoo</item>
<item>@raw/thumb_yahoo</item>
<item>@raw/favicon_picasa</item>
<item>@raw/thumb_picasa</item>
<item>@raw/favicon_msn</item>
<item>@raw/thumb_msn</item>
<item>@raw/favicon_twitter</item>
<item>@raw/thumb_twitter</item>
<item>@raw/favicon_facebook</item>
<item>@raw/thumb_facebook</item>
<item>@raw/favicon_wikipedia</item>
<item>@raw/thumb_wikipedia</item>
<item>@raw/favicon_ebay</item>
<item>@raw/thumb_ebay</item>
<item>@raw/favicon_cnn</item>
<item>@raw/thumb_cnn</item>
<item>@raw/favicon_nytimes</item>
<item>@raw/thumb_nytimes</item>
<item>@raw/favicon_espn</item>
<item>@raw/thumb_espn</item>
<item>@raw/favicon_amazon</item>
<item>@raw/thumb_amazon</item>
<item>@raw/favicon_weatherchannel</item>
<item>@raw/thumb_weatherchannel</item>
<item>@raw/favicon_bbc</item>
<item>@raw/thumb_bbc</item>
</array>
</resources>
5)编译工程,并把工程push到system/app目录下,可用以下命令:
adb push PartnerBookmarksProvider.apk system/app
三、最终结果:
注:资源文件下载 http://download.csdn.net/detail/jiulousanti/7828169
相关文章推荐
- java和javascript获取word文档的书签位置对比
- 使用java为pdf添加书签的方法(pdf书签制作)
- js在PageOffice打开的Word文档光标处插入书签
- Google Chrome Keyboard Shortcuts
- 基于WF4.0流程平台开发过程中的知识积累(三)书签实现子流程
- Chrome实验版可同时检查多种语言拼写错误
- 小书签 - 翻译
- 浏览器书签导入于导出
- 浏览器书签小记
- Chrome如何离线安装crx文件
- GOOGLE CHROME浏览器如何设置默认隐身启动及部分命令行启动参数
- Google Chrome清除缓存高级技巧
- 关于google chrome打开很慢的解决方法
- 纯css书签导航按钮
- 你不知道的Google Search
- 关于servlet+jsp+java实现Web登陆页界面的一些笔记(三)
- C# 对Word文档进行处理
- 学生信息管理系统--书签的使用
- Ubuntu12.04 Chrom
- 在eclipse中使用 书签