This component listens to the messages and signals sent by the inputMapper
component in the content
scripts and then calls the action invokers according to the received message.
The component can be used by creating its instance or by making a custom component using the grade.
// Either create an instance of the messageListener.
var messageListenerInstanceOne = gamepad.messageListener();
// Otherwise create a custom component using the messageListener grade.
fluid.defaults("my.messageListener.grade", {
gradeNames: ["gamepad.messageListener", "my.CustomGrade"]
});
var messageListenerInstanceTwo = my.messageListener.grade();
This component does not provide any configuration options.
- Returns: Nothing.
Listens to the messages received from the inputMapper
component in the content scripts by using
chrome.runtime.onMessage.addListener
and triggers
the actionExecutor invoker as a callback function.
actionData {Object}
The message object received from theinputMapper
component in the content scripts. (see below)- Returns: Nothing.
Identifies and triggers the navigation-producing invokers according to the actionData
. The navigation-producing
invoker is triggered only if the component provides it. Each of these invokers accepts the following arguments:
tabId
: ID of the currently active tab.invert
: Whether direction of the given action should be in the opposite order (for thumbsticks).active
: Whether a new tab or window should be focused when opened.homepageURL
: The URL that a new tab or window should load when opened.left
: Position of the current browser window from the screen's left edge (in pixels).
The invokers use only those arguments required to perform their specific action. Some of these arguments are extracted
from the actionData
object recieved from the content scripts. Below is an example of the actionData
object.
{
action: "openNewTab",
active: true,
homepageURL: "https://www.google.com/"
}
active {Boolean}
Whether a new browser tab should be focused when opened.homepageURL {String}
The URL that a new browser tab should load when opened.- Returns: Nothing.
Opens a new tab in the current browser window using the
chrome.tabs.create
method.
tabId {Number}
ID of the currently active tab.- Returns: Nothing.
Closes the current tab in the active browser window using the
chrome.tabs.remove
method.
- Returns: Nothing.
Switches from the current tab to the previous tab in the active browser window. If the active tab is the first tab in the list, then the focus will move to the last tab.
- Returns: Nothing.
Switches from the current tab to the next tab in the active browser window. If the active tab is the last tab in the list, then the focus will move to the first tab.
active {Boolean}
Whether a new browser window should be focused when opened.homepageURL {String}
The URL that a new browser window should load when opened.- Returns: Nothing.
Opens a new browser window using the
chrome.windows.create
method.
- Returns: Nothing.
Closes the currently active browser window using the
chrome.windows.getCurrent
and
chrome.windows.remove
methods.
- Returns: Nothing.
Switches from the currently active browser window to the previous browser window. If the active window is the first window in the list, then the focus will move to the last window.
- Returns: Nothing.
Switches from the currently active browser window to the next browser window. If the active window is the last window in the list, then the focus will move to the first window.
- Returns: Nothing.
Zoom in on the current tab in the active browser window using the
chrome.tabs.query
,
chrome.tabs.getZoom
, and
chrome.tabs.setZoom
methods.
- Returns: Nothing.
Zoom out on the current tab in the active browser window using the
chrome.tabs.query
,
chrome.tabs.getZoom
, and
chrome.tabs.setZoom
methods.
left {Number}
Position of the current browser window from the screen's left edge (in pixels).- Returns: Nothing.
Maximize the current browser window. Saves the browser window's position and dimensions inside the windowProperties
member variable before the window is maximized.
left {Number}
Position of the current browser window from the screen's left edge (in pixels).- Returns: Nothing.
Restores the size of the currently active browser window. The previous dimensions and positions are taken from the
windowProperties
member variable if stored previously. Otherwise, a set of default values are used for the window's
position and dimensions.
- Returns: Nothing.
Reopens the last closed browser tab or window using the
chrome.sessions.restore
method.