From abe80cc31d5a40ebed743085011fbcda0c1a9a10 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Tue, 23 Apr 2019 15:32:23 -0400 Subject: Issue #1053 - Drop support Android and remove Fennec - Part 1a: Remove mobile/android --- mobile/android/chrome/content/.eslintrc | 23 - mobile/android/chrome/content/ActionBarHandler.js | 731 -- mobile/android/chrome/content/CastingApps.js | 850 --- mobile/android/chrome/content/ConsoleAPI.js | 96 - mobile/android/chrome/content/EmbedRT.js | 82 - mobile/android/chrome/content/FeedHandler.js | 120 - mobile/android/chrome/content/Feedback.js | 64 - mobile/android/chrome/content/FindHelper.js | 197 - mobile/android/chrome/content/InputWidgetHelper.js | 98 - mobile/android/chrome/content/Linkify.js | 108 - mobile/android/chrome/content/MasterPassword.js | 67 - mobile/android/chrome/content/MemoryObserver.js | 88 - mobile/android/chrome/content/OfflineApps.js | 77 - mobile/android/chrome/content/PermissionsHelper.js | 188 - mobile/android/chrome/content/PluginHelper.js | 221 - mobile/android/chrome/content/PresentationView.js | 63 - mobile/android/chrome/content/PresentationView.xul | 15 - mobile/android/chrome/content/PrintHelper.js | 73 - mobile/android/chrome/content/Reader.js | 290 - mobile/android/chrome/content/RemoteDebugger.js | 355 - mobile/android/chrome/content/SelectHelper.js | 161 - mobile/android/chrome/content/WebcompatReporter.js | 144 - mobile/android/chrome/content/WebrtcUI.js | 302 - mobile/android/chrome/content/about.js | 151 - mobile/android/chrome/content/about.xhtml | 77 - mobile/android/chrome/content/aboutAddons.js | 609 -- mobile/android/chrome/content/aboutAddons.xhtml | 63 - mobile/android/chrome/content/aboutCertError.xhtml | 264 - mobile/android/chrome/content/aboutDownloads.js | 373 -- mobile/android/chrome/content/aboutDownloads.xhtml | 62 - mobile/android/chrome/content/aboutHealthReport.js | 192 - .../android/chrome/content/aboutHealthReport.xhtml | 32 - mobile/android/chrome/content/aboutHome.xhtml | 22 - mobile/android/chrome/content/aboutLogins.js | 517 -- mobile/android/chrome/content/aboutLogins.xhtml | 90 - .../android/chrome/content/aboutPrivateBrowsing.js | 32 - .../chrome/content/aboutPrivateBrowsing.xhtml | 43 - mobile/android/chrome/content/aboutRights.xhtml | 95 - .../android/chrome/content/bindings/checkbox.xml | 75 - .../android/chrome/content/bindings/settings.xml | 66 - mobile/android/chrome/content/blockedSite.xhtml | 195 - mobile/android/chrome/content/browser.css | 7 - mobile/android/chrome/content/browser.js | 6961 -------------------- mobile/android/chrome/content/browser.xul | 17 - mobile/android/chrome/content/config.js | 673 -- mobile/android/chrome/content/config.xhtml | 86 - mobile/android/chrome/content/content.js | 159 - mobile/android/chrome/content/geckoview.js | 32 - mobile/android/chrome/content/geckoview.xul | 16 - .../android/chrome/content/healthreport-prefs.js | 6 - mobile/android/chrome/content/languages.properties | 114 - mobile/android/chrome/content/netError.xhtml | 406 -- mobile/android/chrome/jar.mn | 69 - mobile/android/chrome/moz.build | 13 - 54 files changed, 15930 deletions(-) delete mode 100644 mobile/android/chrome/content/.eslintrc delete mode 100644 mobile/android/chrome/content/ActionBarHandler.js delete mode 100644 mobile/android/chrome/content/CastingApps.js delete mode 100644 mobile/android/chrome/content/ConsoleAPI.js delete mode 100644 mobile/android/chrome/content/EmbedRT.js delete mode 100644 mobile/android/chrome/content/FeedHandler.js delete mode 100644 mobile/android/chrome/content/Feedback.js delete mode 100644 mobile/android/chrome/content/FindHelper.js delete mode 100644 mobile/android/chrome/content/InputWidgetHelper.js delete mode 100644 mobile/android/chrome/content/Linkify.js delete mode 100644 mobile/android/chrome/content/MasterPassword.js delete mode 100644 mobile/android/chrome/content/MemoryObserver.js delete mode 100644 mobile/android/chrome/content/OfflineApps.js delete mode 100644 mobile/android/chrome/content/PermissionsHelper.js delete mode 100644 mobile/android/chrome/content/PluginHelper.js delete mode 100644 mobile/android/chrome/content/PresentationView.js delete mode 100644 mobile/android/chrome/content/PresentationView.xul delete mode 100644 mobile/android/chrome/content/PrintHelper.js delete mode 100644 mobile/android/chrome/content/Reader.js delete mode 100644 mobile/android/chrome/content/RemoteDebugger.js delete mode 100644 mobile/android/chrome/content/SelectHelper.js delete mode 100644 mobile/android/chrome/content/WebcompatReporter.js delete mode 100644 mobile/android/chrome/content/WebrtcUI.js delete mode 100644 mobile/android/chrome/content/about.js delete mode 100644 mobile/android/chrome/content/about.xhtml delete mode 100644 mobile/android/chrome/content/aboutAddons.js delete mode 100644 mobile/android/chrome/content/aboutAddons.xhtml delete mode 100644 mobile/android/chrome/content/aboutCertError.xhtml delete mode 100644 mobile/android/chrome/content/aboutDownloads.js delete mode 100644 mobile/android/chrome/content/aboutDownloads.xhtml delete mode 100644 mobile/android/chrome/content/aboutHealthReport.js delete mode 100644 mobile/android/chrome/content/aboutHealthReport.xhtml delete mode 100644 mobile/android/chrome/content/aboutHome.xhtml delete mode 100644 mobile/android/chrome/content/aboutLogins.js delete mode 100644 mobile/android/chrome/content/aboutLogins.xhtml delete mode 100644 mobile/android/chrome/content/aboutPrivateBrowsing.js delete mode 100644 mobile/android/chrome/content/aboutPrivateBrowsing.xhtml delete mode 100644 mobile/android/chrome/content/aboutRights.xhtml delete mode 100644 mobile/android/chrome/content/bindings/checkbox.xml delete mode 100644 mobile/android/chrome/content/bindings/settings.xml delete mode 100644 mobile/android/chrome/content/blockedSite.xhtml delete mode 100644 mobile/android/chrome/content/browser.css delete mode 100644 mobile/android/chrome/content/browser.js delete mode 100644 mobile/android/chrome/content/browser.xul delete mode 100644 mobile/android/chrome/content/config.js delete mode 100644 mobile/android/chrome/content/config.xhtml delete mode 100644 mobile/android/chrome/content/content.js delete mode 100644 mobile/android/chrome/content/geckoview.js delete mode 100644 mobile/android/chrome/content/geckoview.xul delete mode 100644 mobile/android/chrome/content/healthreport-prefs.js delete mode 100644 mobile/android/chrome/content/languages.properties delete mode 100644 mobile/android/chrome/content/netError.xhtml delete mode 100644 mobile/android/chrome/jar.mn delete mode 100644 mobile/android/chrome/moz.build (limited to 'mobile/android/chrome') diff --git a/mobile/android/chrome/content/.eslintrc b/mobile/android/chrome/content/.eslintrc deleted file mode 100644 index 32513189a..000000000 --- a/mobile/android/chrome/content/.eslintrc +++ /dev/null @@ -1,23 +0,0 @@ -globals: - # TODO: Maybe this should be by file - BrowserApp: false - Cc: false - Ci: false - Cu: false - NativeWindow: false - PageActions: false - ReaderMode: false - SimpleServiceDiscovery: false - TabMirror: false - MediaPlayerApp: false - RokuApp: false - SearchEngines: false - ConsoleAPI: true - Point: false - Rect: false - -rules: - # Disabled stuff - no-console: 0 # TODO: Can we use console? - no-cond-assign: 0 - no-fallthrough: 0 diff --git a/mobile/android/chrome/content/ActionBarHandler.js b/mobile/android/chrome/content/ActionBarHandler.js deleted file mode 100644 index 190021043..000000000 --- a/mobile/android/chrome/content/ActionBarHandler.js +++ /dev/null @@ -1,731 +0,0 @@ -// -*- indent-tabs-mode: nil; js-indent-level: 2 -*- -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm"); - -const PHONE_REGEX = /^\+?[0-9\s,-.\(\)*#pw]{1,30}$/; // Are we a phone #? - - -/** - * ActionBarHandler Object and methods. Interface between Gecko Text Selection code - * (AccessibleCaret, etc) and the Mobile ActionBar UI. - */ -var ActionBarHandler = { - // Error codes returned from _init(). - START_TOUCH_ERROR: { - NO_CONTENT_WINDOW: "No valid content Window found.", - NONE: "", - }, - - _nextSelectionID: 1, // Next available. - _selectionID: null, // Unique Selection ID, assigned each time we _init(). - - _boundingClientRect: null, // Current selections boundingClientRect. - _actionBarActions: null, // Most-recent set of actions sent to ActionBar. - - /** - * Receive and act on AccessibleCarets caret state-change - * (mozcaretstatechanged) events. - */ - caretStateChangedHandler: function(e) { - // Close an open ActionBar, if carets no longer logically visible. - if (this._selectionID && !e.caretVisible) { - this._uninit(false); - return; - } - - if (!this._selectionID && e.collapsed) { - switch (e.reason) { - case 'longpressonemptycontent': - case 'taponcaret': - // Show ActionBar when long pressing on an empty input or single - // tapping on the caret. - this._init(e.boundingClientRect); - break; - - case 'updateposition': - // Do not show ActionBar when single tapping on an non-empty editable - // input. - break; - - default: - break; - } - return; - } - - // Open a closed ActionBar if carets actually visible. - if (!this._selectionID && e.caretVisuallyVisible) { - this._init(e.boundingClientRect); - return; - } - - // Else, update an open ActionBar. - if (this._selectionID) { - if (!this._selectionHasChanged()) { - // Still the same active selection. - if (e.reason == 'presscaret' || e.reason == 'scroll') { - // boundingClientRect doesn't matter since we are hiding the floating - // toolbar. - this._updateVisibility(); - } else { - // Selection changes update boundingClientRect. - this._boundingClientRect = e.boundingClientRect; - let forceUpdate = e.reason == 'updateposition' || e.reason == 'releasecaret'; - this._sendActionBarActions(forceUpdate); - } - } else { - // We've started a new selection entirely. - this._uninit(false); - this._init(e.boundingClientRect); - } - } - }, - - /** - * ActionBarHandler notification observers. - */ - observe: function(subject, topic, data) { - switch (topic) { - // User click an ActionBar button. - case "TextSelection:Action": { - if (!this._selectionID) { - break; - } - for (let type in this.actions) { - let action = this.actions[type]; - if (action.id == data) { - action.action(this._targetElement, this._contentWindow); - break; - } - } - break; - } - - // Provide selected text to FindInPageBar on request. - case "TextSelection:Get": { - Messaging.sendRequest({ - type: "TextSelection:Data", - requestId: data, - text: this._getSelectedText(), - }); - - this._uninit(); - break; - } - - // User closed ActionBar by clicking "checkmark" button. - case "TextSelection:End": { - // End the requested selection only. - if (this._selectionID == JSON.parse(data).selectionID) { - this._uninit(); - } - break; - } - } - }, - - /** - * Called when Gecko AccessibleCaret becomes visible. - */ - _init: function(boundingClientRect) { - let [element, win] = this._getSelectionTargets(); - if (!win) { - return this.START_TOUCH_ERROR.NO_CONTENT_WINDOW; - } - - // Hold the ActionBar ID provided by Gecko. - this._selectionID = this._nextSelectionID++; - [this._targetElement, this._contentWindow] = [element, win]; - this._boundingClientRect = boundingClientRect; - - // Open the ActionBar, send it's actions list. - Messaging.sendRequest({ - type: "TextSelection:ActionbarInit", - selectionID: this._selectionID, - }); - this._sendActionBarActions(true); - - return this.START_TOUCH_ERROR.NONE; - }, - - /** - * Called when content is scrolled and handles are hidden. - */ - _updateVisibility: function() { - Messaging.sendRequest({ - type: "TextSelection:Visibility", - selectionID: this._selectionID, - }); - }, - - /** - * Determines the window containing the selection, and its - * editable element if present. - */ - _getSelectionTargets: function() { - let [element, win] = [Services.focus.focusedElement, Services.focus.focusedWindow]; - if (!element) { - // No focused editable. - return [null, win]; - } - - // Return focused editable text element and its window. - if (((element instanceof HTMLInputElement) && element.mozIsTextField(false)) || - (element instanceof HTMLTextAreaElement) || - element.isContentEditable) { - return [element, win]; - } - - // Focused element can't contain text. - return [null, win]; - }, - - /** - * The active Selection has changed, if the current focused element / win, - * pair, or state of the win's designMode changes. - */ - _selectionHasChanged: function() { - let [element, win] = this._getSelectionTargets(); - return (this._targetElement !== element || - this._contentWindow !== win || - this._isInDesignMode(this._contentWindow) !== this._isInDesignMode(win)); - }, - - /** - * Called when Gecko AccessibleCaret becomes hidden, - * ActionBar is closed by user "close" request, or as a result of object - * methods such as SELECT_ALL, PASTE, etc. - */ - _uninit: function(clearSelection = true) { - // Bail if there's no active selection. - if (!this._selectionID) { - return; - } - - // Close the ActionBar. - Messaging.sendRequest({ - type: "TextSelection:ActionbarUninit", - }); - - // Clear the selection ID to complete the uninit(), but leave our reference - // to selectionTargets (_targetElement, _contentWindow) in case we need - // a final clearSelection(). - this._selectionID = null; - this._boundingClientRect = null; - - // Clear selection required if triggered by self, or TextSelection icon - // actions. If called by Gecko CaretStateChangedEvent, - // visibility state is already correct. - if (clearSelection) { - this._clearSelection(); - } - }, - - /** - * Final UI cleanup when Actionbar is closed by icon click, or where - * we terminate selection state after before/after actionbar actions - * (Cut, Copy, Paste, Search, Share, Call). - */ - _clearSelection: function(element = this._targetElement, win = this._contentWindow) { - // Commit edit compositions, and clear focus from editables. - if (element) { - let imeSupport = this._getEditor(element, win).QueryInterface(Ci.nsIEditorIMESupport); - if (imeSupport.composing) { - imeSupport.forceCompositionEnd(); - } - element.blur(); - } - - // Remove Selection from non-editables and now-unfocused contentEditables. - if (!element || element.isContentEditable) { - this._getSelection().removeAllRanges(); - } - }, - - /** - * Called to determine current ActionBar actions and send to TextSelection - * handler. By default we only send if current action state differs from - * the previous. - * @param By default we only send an ActionBarStatus update message if - * there is a change from the previous state. sendAlways can be - * set by init() for example, where we want to always send the - * current state. - */ - _sendActionBarActions: function(sendAlways) { - let actions = this._getActionBarActions(); - - let actionCountUnchanged = this._actionBarActions && - actions.length === this._actionBarActions.length; - let actionsMatch = actionCountUnchanged && - this._actionBarActions.every((e,i) => { - return e.id === actions[i].id; - }); - - if (sendAlways || !actionsMatch) { - Messaging.sendRequest({ - type: "TextSelection:ActionbarStatus", - selectionID: this._selectionID, - actions: actions, - x: this._boundingClientRect.x, - y: this._boundingClientRect.y, - width: this._boundingClientRect.width, - height: this._boundingClientRect.height - }); - } - - this._actionBarActions = actions; - }, - - /** - * Determine and return current ActionBar state. - */ - _getActionBarActions: function(element = this._targetElement, win = this._contentWindow) { - let actions = []; - - for (let type in this.actions) { - let action = this.actions[type]; - if (action.selector.matches(element, win)) { - let a = { - id: action.id, - label: this._getActionValue(action, "label", "", element), - icon: this._getActionValue(action, "icon", "drawable://ic_status_logo", element), - order: this._getActionValue(action, "order", 0, element), - floatingOrder: this._getActionValue(action, "floatingOrder", 9, element), - showAsAction: this._getActionValue(action, "showAsAction", true, element), - }; - actions.push(a); - } - } - actions.sort((a, b) => b.order - a.order); - - return actions; - }, - - /** - * Provides a value from an action. If the action defines the value as a function, - * we return the result of calling the function. Otherwise, we return the value - * itself. If the value isn't defined for this action, will return a default. - */ - _getActionValue: function(obj, name, defaultValue, element) { - if (!(name in obj)) - return defaultValue; - - if (typeof obj[name] == "function") - return obj[name](element); - - return obj[name]; - }, - - /** - * Actionbar callback methods. - */ - actions: { - - SELECT_ALL: { - id: "selectall_action", - label: Strings.browser.GetStringFromName("contextmenu.selectAll"), - icon: "drawable://ab_select_all", - order: 5, - floatingOrder: 5, - - selector: { - matches: function(element, win) { - // For editable, check its length. For default contentWindow, assume - // true, else there'd been nothing to long-press to open ActionBar. - return (element) ? element.textLength != 0 : true; - }, - }, - - action: function(element, win) { - // Some Mobile keyboards such as SwiftKeyboard, provide auto-suggest - // style highlights via composition selections in editables. - if (element) { - // If we have an active composition string, commit it, and - // ensure proper element focus. - let imeSupport = ActionBarHandler._getEditor(element, win). - QueryInterface(Ci.nsIEditorIMESupport); - if (imeSupport.composing) { - element.blur(); - element.focus(); - } - } - - // Close ActionBarHandler, then selectAll, and display handles. - ActionBarHandler._getSelectAllController(element, win).selectAll(); - UITelemetry.addEvent("action.1", "actionbar", null, "select_all"); - }, - }, - - CUT: { - id: "cut_action", - label: Strings.browser.GetStringFromName("contextmenu.cut"), - icon: "drawable://ab_cut", - order: 4, - floatingOrder: 1, - - selector: { - matches: function(element, win) { - // Can cut from editable, or design-mode document. - if (!element && !ActionBarHandler._isInDesignMode(win)) { - return false; - } - // Don't allow "cut" from password fields. - if (element instanceof Ci.nsIDOMHTMLInputElement && - !element.mozIsTextField(true)) { - return false; - } - // Don't allow "cut" from disabled/readonly fields. - if (element && (element.disabled || element.readOnly)) { - return false; - } - // Allow if selected text exists. - return (ActionBarHandler._getSelectedText().length > 0); - }, - }, - - action: function(element, win) { - // First copy the selection text to the clipboard. - let selectedText = ActionBarHandler._getSelectedText(); - let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"]. - getService(Ci.nsIClipboardHelper); - clipboard.copyString(selectedText); - - let msg = Strings.browser.GetStringFromName("selectionHelper.textCopied"); - Snackbars.show(msg, Snackbars.LENGTH_LONG); - - // Then cut the selection text. - ActionBarHandler._getSelection(element, win).deleteFromDocument(); - - ActionBarHandler._uninit(); - UITelemetry.addEvent("action.1", "actionbar", null, "cut"); - }, - }, - - COPY: { - id: "copy_action", - label: Strings.browser.GetStringFromName("contextmenu.copy"), - icon: "drawable://ab_copy", - order: 3, - floatingOrder: 2, - - selector: { - matches: function(element, win) { - // Don't allow "copy" from password fields. - if (element instanceof Ci.nsIDOMHTMLInputElement && - !element.mozIsTextField(true)) { - return false; - } - // Allow if selected text exists. - return (ActionBarHandler._getSelectedText().length > 0); - }, - }, - - action: function(element, win) { - let selectedText = ActionBarHandler._getSelectedText(); - let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"]. - getService(Ci.nsIClipboardHelper); - clipboard.copyString(selectedText); - - let msg = Strings.browser.GetStringFromName("selectionHelper.textCopied"); - Snackbars.show(msg, Snackbars.LENGTH_LONG); - - ActionBarHandler._uninit(); - UITelemetry.addEvent("action.1", "actionbar", null, "copy"); - }, - }, - - PASTE: { - id: "paste_action", - label: Strings.browser.GetStringFromName("contextmenu.paste"), - icon: "drawable://ab_paste", - order: 2, - floatingOrder: 3, - - selector: { - matches: function(element, win) { - // Can paste to editable, or design-mode document. - if (!element && !ActionBarHandler._isInDesignMode(win)) { - return false; - } - // Can't paste into disabled/readonly fields. - if (element && (element.disabled || element.readOnly)) { - return false; - } - // Can't paste if Clipboard empty. - let flavors = ["text/unicode"]; - return Services.clipboard.hasDataMatchingFlavors(flavors, flavors.length, - Ci.nsIClipboard.kGlobalClipboard); - }, - }, - - action: function(element, win) { - // Paste the clipboard, then close the ActionBarHandler and ActionBar. - ActionBarHandler._getEditor(element, win). - paste(Ci.nsIClipboard.kGlobalClipboard); - ActionBarHandler._uninit(); - UITelemetry.addEvent("action.1", "actionbar", null, "paste"); - }, - }, - - CALL: { - id: "call_action", - label: Strings.browser.GetStringFromName("contextmenu.call"), - icon: "drawable://phone", - order: 1, - floatingOrder: 0, - - selector: { - matches: function(element, win) { - return (ActionBarHandler._getSelectedPhoneNumber() != null); - }, - }, - - action: function(element, win) { - BrowserApp.loadURI("tel:" + - ActionBarHandler._getSelectedPhoneNumber()); - - ActionBarHandler._uninit(); - UITelemetry.addEvent("action.1", "actionbar", null, "call"); - }, - }, - - SEARCH: { - id: "search_action", - label: () => Strings.browser.formatStringFromName("contextmenu.search", - [Services.search.defaultEngine.name], 1), - icon: "drawable://ab_search", - order: 1, - floatingOrder: 6, - - selector: { - matches: function(element, win) { - // Allow if selected text exists. - return (ActionBarHandler._getSelectedText().length > 0); - }, - }, - - action: function(element, win) { - let selectedText = ActionBarHandler._getSelectedText(); - ActionBarHandler._uninit(); - - // Set current tab as parent of new tab, - // and set new tab as private if the parent is. - let searchSubmission = Services.search.defaultEngine.getSubmission(selectedText); - let parent = BrowserApp.selectedTab; - let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(parent.browser); - BrowserApp.addTab(searchSubmission.uri.spec, - { parentId: parent.id, - selected: true, - isPrivate: isPrivate, - } - ); - - UITelemetry.addEvent("action.1", "actionbar", null, "search"); - }, - }, - - SEARCH_ADD: { - id: "search_add_action", - label: Strings.browser.GetStringFromName("contextmenu.addSearchEngine3"), - icon: "drawable://ab_add_search_engine", - order: 0, - floatingOrder: 8, - - selector: { - matches: function(element, win) { - if(!(element instanceof HTMLInputElement)) { - return false; - } - let form = element.form; - if (!form || element.type == "password") { - return false; - } - - let method = form.method.toUpperCase(); - let canAddEngine = (method == "GET") || - (method == "POST" && (form.enctype != "text/plain" && form.enctype != "multipart/form-data")); - if (!canAddEngine) { - return false; - } - - // If SearchEngine query finds it, then we don't want action to add displayed. - if (SearchEngines.visibleEngineExists(element)) { - return false; - } - - return true; - }, - }, - - action: function(element, win) { - UITelemetry.addEvent("action.1", "actionbar", null, "add_search_engine"); - - // Engines are added asynch. If required, update SelectionUI on callback. - SearchEngines.addEngine(element, (result) => { - if (result) { - ActionBarHandler._sendActionBarActions(true); - } - }); - }, - }, - - SHARE: { - id: "share_action", - label: Strings.browser.GetStringFromName("contextmenu.share"), - icon: "drawable://ic_menu_share", - order: 0, - floatingOrder: 4, - - selector: { - matches: function(element, win) { - if (!ParentalControls.isAllowed(ParentalControls.SHARE)) { - return false; - } - // Allow if selected text exists. - return (ActionBarHandler._getSelectedText().length > 0); - }, - }, - - action: function(element, win) { - Messaging.sendRequest({ - type: "Share:Text", - text: ActionBarHandler._getSelectedText(), - }); - - ActionBarHandler._uninit(); - UITelemetry.addEvent("action.1", "actionbar", null, "share"); - }, - }, - }, - - /** - * Provides UUID service for generating action ID's. - */ - get _idService() { - delete this._idService; - return this._idService = Cc["@mozilla.org/uuid-generator;1"]. - getService(Ci.nsIUUIDGenerator); - }, - - /** - * The targetElement holds an editable element containing a - * selection or a caret. - */ - get _targetElement() { - if (this._targetElementRef) - return this._targetElementRef.get(); - return null; - }, - - set _targetElement(element) { - this._targetElementRef = Cu.getWeakReference(element); - }, - - /** - * The contentWindow holds the selection, or the targetElement - * if it's an editable. - */ - get _contentWindow() { - if (this._contentWindowRef) - return this._contentWindowRef.get(); - return null; - }, - - set _contentWindow(aContentWindow) { - this._contentWindowRef = Cu.getWeakReference(aContentWindow); - }, - - /** - * If we have an active selection, is it part of a designMode document? - */ - _isInDesignMode: function(win) { - return this._selectionID && (win.document.designMode === "on"); - }, - - /** - * Provides the currently selected text, for either an editable, - * or for the default contentWindow. - */ - _getSelectedText: function() { - // Can be called from FindInPageBar "TextSelection:Get", when there - // is no active selection. - if (!this._selectionID) { - return ""; - } - - let selection = this._getSelection(); - - // Textarea can contain LF, etc. - if (this._targetElement instanceof Ci.nsIDOMHTMLTextAreaElement) { - let flags = Ci.nsIDocumentEncoder.OutputPreformatted | - Ci.nsIDocumentEncoder.OutputRaw; - return selection.QueryInterface(Ci.nsISelectionPrivate). - toStringWithFormat("text/plain", flags, 0); - } - - // Return explicitly selected text. - return selection.toString(); - }, - - /** - * Provides the nsISelection for either an editor, or from the - * default window. - */ - _getSelection: function(element = this._targetElement, win = this._contentWindow) { - return (element instanceof Ci.nsIDOMNSEditableElement) ? - this._getEditor(element).selection : - win.getSelection(); - }, - - /** - * Returns an nsEditor or nsHTMLEditor. - */ - _getEditor: function(element = this._targetElement, win = this._contentWindow) { - if (element instanceof Ci.nsIDOMNSEditableElement) { - return element.QueryInterface(Ci.nsIDOMNSEditableElement).editor; - } - - return win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIEditingSession). - getEditorForWindow(win); - }, - - /** - * Returns a selection controller. - */ - _getSelectionController: function(element = this._targetElement, win = this._contentWindow) { - if (element instanceof Ci.nsIDOMNSEditableElement) { - return this._getEditor(element, win).selectionController; - } - - return win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay). - QueryInterface(Ci.nsISelectionController); - }, - - /** - * For selectAll(), provides the editor, or the default window selection Controller. - */ - _getSelectAllController: function(element = this._targetElement, win = this._contentWindow) { - let editor = this._getEditor(element, win); - return (editor) ? - editor : this._getSelectionController(element, win); - }, - - /** - * Call / Phone Helper methods. - */ - _getSelectedPhoneNumber: function() { - let selectedText = this._getSelectedText().trim(); - return this._isPhoneNumber(selectedText) ? - selectedText : null; - }, - - _isPhoneNumber: function(selectedText) { - return (PHONE_REGEX.test(selectedText)); - }, -}; diff --git a/mobile/android/chrome/content/CastingApps.js b/mobile/android/chrome/content/CastingApps.js deleted file mode 100644 index 76773c4d8..000000000 --- a/mobile/android/chrome/content/CastingApps.js +++ /dev/null @@ -1,850 +0,0 @@ -// -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -XPCOMUtils.defineLazyModuleGetter(this, "PageActions", - "resource://gre/modules/PageActions.jsm"); - -// Define service devices. We should consider moving these to their respective -// JSM files, but we left them here to allow for better lazy JSM loading. -var rokuDevice = { - id: "roku:ecp", - target: "roku:ecp", - factory: function(aService) { - Cu.import("resource://gre/modules/RokuApp.jsm"); - return new RokuApp(aService); - }, - types: ["video/mp4"], - extensions: ["mp4"] -}; - -var mediaPlayerDevice = { - id: "media:router", - target: "media:router", - factory: function(aService) { - Cu.import("resource://gre/modules/MediaPlayerApp.jsm"); - return new MediaPlayerApp(aService); - }, - types: ["video/mp4", "video/webm", "application/x-mpegurl"], - extensions: ["mp4", "webm", "m3u", "m3u8"], - init: function() { - Services.obs.addObserver(this, "MediaPlayer:Added", false); - Services.obs.addObserver(this, "MediaPlayer:Changed", false); - Services.obs.addObserver(this, "MediaPlayer:Removed", false); - }, - observe: function(subject, topic, data) { - if (topic === "MediaPlayer:Added") { - let service = this.toService(JSON.parse(data)); - SimpleServiceDiscovery.addService(service); - } else if (topic === "MediaPlayer:Changed") { - let service = this.toService(JSON.parse(data)); - SimpleServiceDiscovery.updateService(service); - } else if (topic === "MediaPlayer:Removed") { - SimpleServiceDiscovery.removeService(data); - } - }, - toService: function(display) { - // Convert the native data into something matching what is created in _processService() - return { - location: display.location, - target: "media:router", - friendlyName: display.friendlyName, - uuid: display.uuid, - manufacturer: display.manufacturer, - modelName: display.modelName, - mirror: display.mirror - }; - } -}; - -var fxOSTVDevice = { - id: "app://fling-player.gaiamobile.org", - target: "app://fling-player.gaiamobile.org/index.html", - factory: function(aService) { - Cu.import("resource://gre/modules/PresentationApp.jsm"); - let request = new window.PresentationRequest(this.target); - return new PresentationApp(aService, request); - }, - init: function() { - Services.obs.addObserver(this, "presentation-device-change", false); - SimpleServiceDiscovery.addExternalDiscovery(this); - }, - observe: function(subject, topic, data) { - let device = subject.QueryInterface(Ci.nsIPresentationDevice); - let service = this.toService(device); - switch (data) { - case "add": - SimpleServiceDiscovery.addService(service); - break; - case "update": - SimpleServiceDiscovery.updateService(service); - break; - case "remove": - if(SimpleServiceDiscovery.findServiceForID(device.id)) { - SimpleServiceDiscovery.removeService(device.id); - } - break; - } - }, - toService: function(device) { - return { - location: device.id, - target: fxOSTVDevice.target, - friendlyName: device.name, - uuid: device.id, - manufacturer: "Firefox OS TV", - modelName: "Firefox OS TV", - }; - }, - startDiscovery: function() { - window.navigator.mozPresentationDeviceInfo.forceDiscovery(); - - // need to update the lastPing time for known device. - window.navigator.mozPresentationDeviceInfo.getAll() - .then(function(devices) { - for (let device of devices) { - let service = fxOSTVDevice.toService(device); - SimpleServiceDiscovery.addService(service); - } - }); - }, - stopDiscovery: function() { - // do nothing - }, - types: ["video/mp4", "video/webm"], - extensions: ["mp4", "webm"], -}; - -var CastingApps = { - _castMenuId: -1, - mirrorStartMenuId: -1, - mirrorStopMenuId: -1, - _blocked: null, - _bound: null, - _interval: 120 * 1000, // 120 seconds - - init: function ca_init() { - if (!this.isCastingEnabled()) { - return; - } - - // Register targets - SimpleServiceDiscovery.registerDevice(rokuDevice); - - // MediaPlayerDevice will notify us any time the native device list changes. - mediaPlayerDevice.init(); - SimpleServiceDiscovery.registerDevice(mediaPlayerDevice); - - // Presentation Device will notify us any time the available device list changes. - if (window.PresentationRequest) { - fxOSTVDevice.init(); - SimpleServiceDiscovery.registerDevice(fxOSTVDevice); - } - - // Search for devices continuously - SimpleServiceDiscovery.search(this._interval); - - this._castMenuId = NativeWindow.contextmenus.add( - Strings.browser.GetStringFromName("contextmenu.sendToDevice"), - this.filterCast, - this.handleContextMenu.bind(this) - ); - - Services.obs.addObserver(this, "Casting:Play", false); - Services.obs.addObserver(this, "Casting:Pause", false); - Services.obs.addObserver(this, "Casting:Stop", false); - Services.obs.addObserver(this, "Casting:Mirror", false); - Services.obs.addObserver(this, "ssdp-service-found", false); - Services.obs.addObserver(this, "ssdp-service-lost", false); - Services.obs.addObserver(this, "application-background", false); - Services.obs.addObserver(this, "application-foreground", false); - - BrowserApp.deck.addEventListener("TabSelect", this, true); - BrowserApp.deck.addEventListener("pageshow", this, true); - BrowserApp.deck.addEventListener("playing", this, true); - BrowserApp.deck.addEventListener("ended", this, true); - BrowserApp.deck.addEventListener("MozAutoplayMediaBlocked", this, true); - // Note that the XBL binding is untrusted - BrowserApp.deck.addEventListener("MozNoControlsVideoBindingAttached", this, true, true); - }, - - _mirrorStarted: function(stopMirrorCallback) { - this.stopMirrorCallback = stopMirrorCallback; - NativeWindow.menu.update(this.mirrorStartMenuId, { visible: false }); - NativeWindow.menu.update(this.mirrorStopMenuId, { visible: true }); - }, - - serviceAdded: function(aService) { - if (this.isMirroringEnabled() && aService.mirror && this.mirrorStartMenuId == -1) { - this.mirrorStartMenuId = NativeWindow.menu.add({ - name: Strings.browser.GetStringFromName("casting.mirrorTab"), - callback: function() { - let callbackFunc = function(aService) { - let app = SimpleServiceDiscovery.findAppForService(aService); - if (app) { - app.mirror(function() {}, window, BrowserApp.selectedTab.getViewport(), this._mirrorStarted.bind(this), window.BrowserApp.selectedBrowser.contentWindow); - } - }.bind(this); - - this.prompt(callbackFunc, aService => aService.mirror); - }.bind(this), - parent: NativeWindow.menu.toolsMenuID - }); - - this.mirrorStopMenuId = NativeWindow.menu.add({ - name: Strings.browser.GetStringFromName("casting.mirrorTabStop"), - callback: function() { - if (this.tabMirror) { - this.tabMirror.stop(); - this.tabMirror = null; - } else if (this.stopMirrorCallback) { - this.stopMirrorCallback(); - this.stopMirrorCallback = null; - } - NativeWindow.menu.update(this.mirrorStartMenuId, { visible: true }); - NativeWindow.menu.update(this.mirrorStopMenuId, { visible: false }); - }.bind(this), - }); - } - if (this.mirrorStartMenuId != -1) { - NativeWindow.menu.update(this.mirrorStopMenuId, { visible: false }); - } - }, - - serviceLost: function(aService) { - if (aService.mirror && this.mirrorStartMenuId != -1) { - let haveMirror = false; - SimpleServiceDiscovery.services.forEach(function(service) { - if (service.mirror) { - haveMirror = true; - } - }); - if (!haveMirror) { - NativeWindow.menu.remove(this.mirrorStartMenuId); - this.mirrorStartMenuId = -1; - } - } - }, - - isCastingEnabled: function isCastingEnabled() { - return Services.prefs.getBoolPref("browser.casting.enabled"); - }, - - isMirroringEnabled: function isMirroringEnabled() { - return Services.prefs.getBoolPref("browser.mirroring.enabled"); - }, - - observe: function (aSubject, aTopic, aData) { - switch (aTopic) { - case "Casting:Play": - if (this.session && this.session.remoteMedia.status == "paused") { - this.session.remoteMedia.play(); - } - break; - case "Casting:Pause": - if (this.session && this.session.remoteMedia.status == "started") { - this.session.remoteMedia.pause(); - } - break; - case "Casting:Stop": - if (this.session) { - this.closeExternal(); - } - break; - case "Casting:Mirror": - { - Cu.import("resource://gre/modules/TabMirror.jsm"); - this.tabMirror = new TabMirror(aData, window); - NativeWindow.menu.update(this.mirrorStartMenuId, { visible: false }); - NativeWindow.menu.update(this.mirrorStopMenuId, { visible: true }); - } - break; - case "ssdp-service-found": - this.serviceAdded(SimpleServiceDiscovery.findServiceForID(aData)); - break; - case "ssdp-service-lost": - this.serviceLost(SimpleServiceDiscovery.findServiceForID(aData)); - break; - case "application-background": - // Turn off polling while in the background - this._interval = SimpleServiceDiscovery.search(0); - SimpleServiceDiscovery.stopSearch(); - break; - case "application-foreground": - // Turn polling on when app comes back to foreground - SimpleServiceDiscovery.search(this._interval); - break; - } - }, - - handleEvent: function(aEvent) { - switch (aEvent.type) { - case "TabSelect": { - let tab = BrowserApp.getTabForBrowser(aEvent.target); - this._updatePageActionForTab(tab, aEvent); - break; - } - case "pageshow": { - let tab = BrowserApp.getTabForWindow(aEvent.originalTarget.defaultView); - this._updatePageActionForTab(tab, aEvent); - break; - } - case "playing": - case "ended": { - let video = aEvent.target; - if (video instanceof HTMLVideoElement) { - // If playing, send the