Firefox OS启动过程分析-system应用启动
2015-09-28 13:51
302 查看
Firefox OS的system应用启动是通过加载一个内部资源页
来实现的,我们先看下这个文件的部分内容:
该html加载时,主要加载以及运行两个js文件:
shell.js中:
几个问题:
homeURL(b2g.system_startup_url):
manifestURL:
system app实际上是一个iframe
该iframe是放在shell.html中id为”container”中:
4.systemapp的iframe实际上有一系列属性:
system app的iframe里放的是 ‘blank.html’。其它属性:
system app刚开始加载的是
也就是没有界面的,之后开始加载
“system.gaiamobile.org”,实际上就是gaia里的system app。该app负责系统ui的显示以及home应用的加载等工作。
问题是:
我们下节再说。
chrome://b2g/content/shell.html
来实现的,我们先看下这个文件的部分内容:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" id="shell" windowtype="navigator:browser" > <head> <link rel="stylesheet" href="shell.css" type="text/css"> <script type="application/javascript;version=1.8" src="chrome://b2g/content/settings.js"> </script> <script type="application/javascript;version=1.8" src="chrome://b2g/content/shell.js"> </script> <!-- this file is only loaded on Gonk to manage ADB state --> <script type="application/javascript;version=1.8" src="chrome://b2g/content/devtools/adb.js"> </script> <!-- manages DevTools server state --> <script type="application/javascript;version=1.8" src="chrome://b2g/content/devtools/debugger.js"> </script> </head> <body id="container"> <!-- The html:iframe containing the UI is created here. --> </body> </html>
该html加载时,主要加载以及运行两个js文件:
<script type="application/javascript;version=1.8" src="chrome://b2g/content/settings.js"> </script> <script type="application/javascript;version=1.8" src="chrome://b2g/content/shell.js"> </script>
shell.js中:
bootstrap: function() { //... this.start(); }, start: function shell_start() { // ... let homeURL = this.homeURL; if (!homeURL) { let msg = 'Fatal error during startup: No homescreen found: try setting B2G_HOMESCREEN'; alert(msg); return; } let manifestURL = this.manifestURL; // <html:iframe id="systemapp" // mozbrowser="true" allowfullscreen="true" // style="overflow: hidden; height: 100%; width: 100%; border: none;" // src="data:text/html;charset=utf-8,%3C!DOCTYPE html>%3Cbody style='background:black;'>"/> let systemAppFrame = document.createElementNS('http://www.w3.org/1999/xhtml', 'html:iframe'); systemAppFrame.setAttribute('id', 'systemapp'); systemAppFrame.setAttribute('mozbrowser', 'true'); systemAppFrame.setAttribute('mozapp', manifestURL); systemAppFrame.setAttribute('allowfullscreen', 'true'); systemAppFrame.setAttribute('src', 'blank.html'); let container = document.getElementById('container'); #ifdef MOZ_WIDGET_COCOA // See shell.html let hotfix = document.getElementById('placeholder'); if (hotfix) { container.removeChild(hotfix); } #endif this.contentBrowser = container.appendChild(systemAppFrame); systemAppFrame.contentWindow .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebNavigation) .sessionHistory = Cc["@mozilla.org/browser/shistory;1"] .createInstance(Ci.nsISHistory); this.allowedAudioChannels = new Map(); let audioChannels = systemAppFrame.allowedAudioChannels; audioChannels && audioChannels.forEach(function(audioChannel) { this.allowedAudioChannels.set(audioChannel.name, audioChannel); audioChannel.addEventListener('activestatechanged', this); // Set all audio channels as unmuted by default // because some audio in System app will be played // before AudioChannelService[1] is Gaia is loaded. // [1]: https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/audio_channel_service.js audioChannel.setMuted(false); }.bind(this)); // On firefox mulet, shell.html is loaded in a tab // and we have to listen on the chrome event handler // to catch key events let chromeEventHandler = window.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebNavigation) .QueryInterface(Ci.nsIDocShell) .chromeEventHandler || window; // Capture all key events so we can filter out hardware buttons // And send them to Gaia via mozChromeEvents. // Ideally, hardware buttons wouldn't generate key events at all, or // if they did, they would use keycodes that conform to DOM 3 Events. // See discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=762362 chromeEventHandler.addEventListener('keydown', this, true); chromeEventHandler.addEventListener('keyup', this, true); window.addEventListener('MozApplicationManifest', this); window.addEventListener('MozAfterPaint', this); window.addEventListener('sizemodechange', this); window.addEventListener('unload', this); this.contentBrowser.addEventListener('mozbrowserloadstart', this, true); this.contentBrowser.addEventListener('mozbrowserselectionstatechanged', this, true); this.contentBrowser.addEventListener('mozbrowserscrollviewchange', this, true); this.contentBrowser.addEventListener('mozbrowsercaretstatechanged', this); CustomEventManager.init(); WebappsHelper.init(); UserAgentOverrides.init(); CaptivePortalLoginHelper.init(); this.contentBrowser.src = homeURL; },
几个问题:
homeURL(b2g.system_startup_url):
app://system.gaiamobile.org/index.html "app:// for packaged app resources"
manifestURL:
app://system.gaiamobile.org/manifest.webapp "app:// for packaged app resources"
system app实际上是一个iframe
let systemAppFrame = document.createElementNS('http://www.w3.org/1999/xhtml', 'html:iframe');
该iframe是放在shell.html中id为”container”中:
let container = document.getElementById('container'); ... this.contentBrowser = container.appendChild(systemAppFrame); ...
4.systemapp的iframe实际上有一系列属性:
systemAppFrame.setAttribute('id', 'systemapp'); systemAppFrame.setAttribute('mozbrowser', 'true'); systemAppFrame.setAttribute('mozapp', manifestURL); systemAppFrame.setAttribute('allowfullscreen', 'true'); systemAppFrame.setAttribute('src', 'blank.html');
system app的iframe里放的是 ‘blank.html’。其它属性:
mozbrowser: An "iframe" is turned into a browser frame by setting the mozbrowser attribute mozapp: see [mozapp](https://wiki.mozilla.org/Security/Reviews/B2G/mozapp)
system app刚开始加载的是
'blank.html',
也就是没有界面的,之后开始加载
homeURL,即"app://system.gaiamobile.org/index.html"
“system.gaiamobile.org”,实际上就是gaia里的system app。该app负责系统ui的显示以及home应用的加载等工作。
问题是:
b2g进程、system进程与Home进程的关系是什么样的? Home进程是如何创建出来的?
我们下节再说。
相关文章推荐
- [leetcode 287]Find the Duplicate Number
- 如何深入理解 StatsD 与 Graphite ?
- liunx 定时器
- Android实现复制粘贴
- JAVA算法_快速排序
- protobuf-2.5.0安装
- 如何使Android应用程序获取系统权限
- flume读取日志数据写入kafka
- ffmpeg入门小结(三)—— 傅里叶变换之美
- AngularJS
- 如何深入理解 StatsD 与 Graphite ?
- Android隐藏虚拟按键(底部导航栏)
- JSON对象和字符串之间的相互转换
- 写给自己--钝感力
- hive 远程debug
- linux定时关机命令
- cocos2dx lua
- Mac OS X 10.10.5 中 VirtualBox 5.0 里的 Win7 虚拟机无法使用 USB 3.0 设备的解决办法
- src 和 href 区别(转载)
- 瑞星推出虚拟化系统安全软件试用活动 全面普及虚拟化安全