new Screenshot()
This system module takes a screenshot of the currently running app
or homescreen and stores it with DeviceStorage when the user
presses the home and sleep buttons at the same time. It communicates
with gecko code running in b2g/chrome/content/shell.js using a private
event-based API. It is the gecko code that creates the screenshot.
This script must be used with the defer attribute.
Members
-
MAX_SCREENSHOT_SIZE :Number
-
Assumption for making sure we have enough space to save the image.
Assume that the maximum screenshot size is 4 bytes per device pixel plus a bit extra. In practice, with compression, our PNG files will be much smaller than this.
Methods
-
_getDeviceStorage(callback)
-
Get a DeviceStorage object and pass it to the callback.
Or, if device storage is not available, display a notification.Parameters:
Name Type Description callback function Callback to run.
-
_notify(titleid, body, bodyid)
-
Display a screenshot success or failure notification.
Localize the first argument, and localize the third if the second is nullParameters:
Name Type Description titleid String l10n ID of the string to show.
body String Label to show as body, or null.
bodyid String l10n ID of the label to show as body.
-
handleEvent(evt)
-
Handle screenshot events.
Parameters:
Name Type Description evt DOMEvent DOM Event to handle.
-
handleTakeScreenshotSuccess(file)
-
Handle the take-screenshot-success mozChromeEvent.
Parameters:
Name Type Description file Blob Blob object received from the event.
-
start()
-
Start to handle screenshot events.
-
stop()
-
Stop handling screenshot events.
-
takeScreenshot()
-
Actually take a screenshot (by do some check and send a mozContentEvent.)