因为AwContent和ChromeShell各有一套ContentMainDelegate,所以要选择以谁为基础,
这里为确保ChromeShell端的完整性,以ChromeShell为主编译对象,然后把AwContent的东西加进去
以Android4.4.2的Chromium_org为例,所以编译命令是ninja -C out/Release chromium_testshell
主动修改
1、先解决gyp编译脚本问题:
chrome\chrome_android.gypi中添加上Awcontent的编译target
'../android_webview/android_webview.gyp:android_webview_common',
2、加上JNI注册部分
chrome\browser\android\chrome_jni_registrar.cc中添加
android_webview\native\android_webview_jni_registrar.h
{ "AndroidWebview",
android_webview::RegisterJni },
3、ChromeMainDelegateTestShellAndroid和aw_main_delegate的结合,把aw_main_delegate的内容合入ChromeMainDelegateTestShellAndroid中
从CreateContentBrowserClient到CreateWebPreferencesPopulater
编译错误
1、去掉android_webview.gyp:android_webview_common中下面重复编译代码
Printing部分、content_app_both和aw_main_delegate
2、android_webview\common\android_webview_message_generator.h中把重复的print message也去掉
3、android_webview\native\aw_form_database.cc中删除重复定义
AutofillWebDataService::FromBrowserContext
4、android_webview\native\aw_pdf_exporter.cc中的编译错误,先删除ExportToPdf的实现
5、native\aw_web_contents_delegate 从chrome_web_contents_delegate_android去继承
删除:GetJavaScriptDialogManager 和 FindReply
CloseContents的时候加上Chrome域的CloseContents
FilesSelectedInChooser中间部分编译错误,先注释掉实现代码
cc文件中删除:LazyInstance<AwJavaScriptDialogManager>::Leaky两行
启动错误
1、BrowserContext创建问题
因为chome-shell创建的是ProfileImpl,所以要把AwBrowserContext部分合入
(应该是AwBrowserContext public from ProfileImpl)
2、存在一个创建时机问题
要在Profile CreateProfile的时候改为AwBrowserContext,但是这样代码结构就变得非常差劲
3、AwBrowserContext构造最后加上
InitializeBeforeThreadCreation();
PreMainMessageLoopRun();
4、还存在JniDependencyFactory* native_factory取不到的问题,用chrome_content_browser_client增加的static方法
5、删除从GetRequestContext到GetResourceContext的重复实现部分
经过上面的整合,编译出来的so运行于android_webview_apk是ok的,能否再用于chromium_testshell还没验证。
接下来就是通过更改渲染机制,把SurfaceView用起来,以提高性能。