Commit 19b9d90c authored by Phil Ringnalda's avatar Phil Ringnalda
Browse files

Back out 47afa45afdfb and ccb20a1169f1 (bug 697309) and c30bdfd14362 and...

Back out 47afa45afdfb and ccb20a1169f1 (bug 697309) and c30bdfd14362 and 618b680315ee (bug 736278) for Android native Talos bustage
parent c47e91db
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -485,7 +485,6 @@ pref("app.faqURL", "http://www.mozilla.com/%LOCALE%/mobile/beta/faq/");
pref("app.featuresURL", "http://www.mozilla.com/%LOCALE%/mobile/features/");
pref("app.faqURL", "http://www.mozilla.com/%LOCALE%/mobile/faq/");
#endif
pref("app.marketplaceURL", "https://marketplace.mozilla.org/");

// Name of alternate about: page for certificate errors (when undefined, defaults to about:neterror)
pref("security.alternate_certificate_error_page", "certerror");
+1 −26
Original line number Diff line number Diff line
@@ -43,11 +43,9 @@ import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

@@ -55,8 +53,6 @@ import org.json.JSONObject;
import org.json.JSONException;

public class DoorHanger extends LinearLayout implements Button.OnClickListener {
    private static final String LOGTAG = "DoorHanger";

    private Context mContext;
    private LinearLayout mChoicesLayout;
    private TextView mTextView;
@@ -65,9 +61,6 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
    // value used to identify the notification
    private String mValue;

    // Optional checkbox added underneath message text
    private CheckBox mCheckBox;

    static private LayoutInflater mInflater;

    private int mPersistence = 0;
@@ -106,18 +99,7 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
    }

    public void onClick(View v) {
        JSONObject response = new JSONObject();
        try {
            response.put("callback", v.getTag().toString());

            // If the checkbox is being used, pass its value
            if (mCheckBox != null)
                response.put("checked", mCheckBox.isChecked());
        } catch (JSONException ex) {
            Log.e(LOGTAG, "Error creating onClick response: " + ex);
        }

        GeckoEvent e = GeckoEvent.createBroadcastEvent("Doorhanger:Reply", response.toString());
        GeckoEvent e = GeckoEvent.createBroadcastEvent("Doorhanger:Reply", v.getTag().toString());
        GeckoAppShell.sendEventToGecko(e);
        mTab.removeDoorHanger(mValue);

@@ -184,13 +166,6 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
            mTextView.setText(titleWithLink);
            mTextView.setMovementMethod(LinkMovementMethod.getInstance());
        } catch (JSONException e) { }

        try {
            String checkBoxText = options.getString("checkbox");
            mCheckBox = (CheckBox) findViewById(R.id.doorhanger_checkbox);
            mCheckBox.setText(checkBoxText);
            mCheckBox.setVisibility(VISIBLE);
        } catch (JSONException e) { }
    }

    // This method checks with persistence and timeout options to see if
+0 −6
Original line number Diff line number Diff line
@@ -9,12 +9,6 @@
              android:textColorLink="@color/doorhanger_link"
              android:padding="10dp"/>

    <CheckBox android:id="@+id/doorhanger_checkbox"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:checked="true"
              android:visibility="gone"/>

    <LinearLayout android:id="@+id/doorhanger_choices"
                  style="@android:style/ButtonBar"
                  android:layout_width="fill_parent"
+0 −160
Original line number Diff line number Diff line
/* ***** BEGIN LICENSE BLOCK *****
 *
 * 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/.
 *
 * ***** END LICENSE BLOCK ***** */

let Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;

Cu.import("resource://gre/modules/Services.jsm")
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Webapps.jsm");

let gStrings = Services.strings.createBundle("chrome://browser/locale/aboutApps.properties");

XPCOMUtils.defineLazyGetter(window, "gChromeWin", function()
  window.QueryInterface(Ci.nsIInterfaceRequestor)
    .getInterface(Ci.nsIWebNavigation)
    .QueryInterface(Ci.nsIDocShellTreeItem)
    .rootTreeItem
    .QueryInterface(Ci.nsIInterfaceRequestor)
    .getInterface(Ci.nsIDOMWindow)
    .QueryInterface(Ci.nsIDOMChromeWindow));

var AppsUI = {
  uninstall: null,
  shortcut: null
};

function onLoad(aEvent) {
  try {
    let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);
    let link = document.getElementById("marketplaceURL");
    let url = formatter.formatURLPref(link.getAttribute("pref"));
    link.setAttribute("href", url);
  } catch (e) {}

  navigator.mozApps.mgmt.oninstall = onInstall;
  navigator.mozApps.mgmt.onuninstall = onUninstall;
  updateList();

  let contextmenus = gChromeWin.NativeWindow.contextmenus;
  AppsUI.shortcut = contextmenus.add(gStrings.GetStringFromName("appsContext.shortcut"), contextmenus.SelectorContext("div[mozApp]"),
    function(aTarget) {
      let manifest = aTarget.manifest;
      createShortcut(manifest.name, manifest.fullLaunchPath(), manifest.iconURLForSize("64"), "webapp");
    });
  AppsUI.uninstall = contextmenus.add(gStrings.GetStringFromName("appsContext.uninstall"), contextmenus.SelectorContext("div[mozApp]"),
    function(aTarget) {
      aTarget.app.uninstall();
    });
}

function onUnload(aEvent) {
  let contextmenus = gChromeWin.NativeWindow.contextmenus;
  if (AppsUI.shortcut)
    contextmenus.remove(AppsUI.shortcut);
  if (AppsUI.uninstall)
    contextmenus.remove(AppsUI.uninstall);
}

function updateList() {
  let grid = document.getElementById("appgrid");
  while (grid.lastChild) {
    grid.removeChild(grid.lastChild);
  }

  let request = navigator.mozApps.mgmt.getAll();
  request.onsuccess = function() {
    for (let i = 0; i < request.result.length; i++)
      addApplication(request.result[i]);
    if (!request.result.length)
      document.getElementById("noapps").className = "";
  }
}

function addApplication(aApp) {
  let list = document.getElementById("appgrid");
  let manifest = new DOMApplicationManifest(aApp.manifest, aApp.origin);

  let container = document.createElement("div");
  container.className = "app";
  container.setAttribute("id", "app-" + aApp.origin);
  container.setAttribute("mozApp", aApp.origin);
  container.setAttribute("title", manifest.name);

  let img = document.createElement("img");
  img.src = manifest.iconURLForSize("64");
  img.setAttribute("title", manifest.name);

  let title = document.createElement("div");
  title.appendChild(document.createTextNode(manifest.name));

  container.appendChild(img);
  container.appendChild(title);
  list.appendChild(container);

  container.addEventListener("click", function(aEvent) {
    aApp.launch();
  }, false);
  container.app = aApp;
  container.manifest = manifest;
}

function onInstall(aEvent) {
  let node = document.getElementById("app-" + aEvent.application.origin);
  if (node)
    return;

  addApplication(aEvent.application);
  document.getElementById("noapps").className = "hidden";
}

function onUninstall(aEvent) {
  let node = document.getElementById("app-" + aEvent.application.origin);
  if (node) {
    let parent = node.parentNode;
    parent.removeChild(node);
    if (!parent.firstChild)
      document.getElementById("noapps").className = "";
  }
}

function createShortcut(aTitle, aURL, aIconURL, aType) {
  // The background images are 72px, but Android will resize as needed.
  // Bigger is better than too small.
  const kIconSize = 72;
  const kOverlaySize = 32;
  const kOffset = 20;

  let canvas = document.createElement("canvas");

  function _createShortcut() {
    let icon = canvas.toDataURL("image/png", "");
    canvas = null;
    try {
      let shell = Cc["@mozilla.org/browser/shell-service;1"].createInstance(Ci.nsIShellService);
      shell.createShortcut(aTitle, aURL, icon, aType);
    } catch(e) {
      Cu.reportError(e);
    }
  }

  canvas.width = canvas.height = kIconSize;
  let ctx = canvas.getContext("2d");

  let favicon = new Image();
  favicon.onload = function() {
    // Center the favicon and overlay it on the background
    ctx.drawImage(favicon, kOffset, kOffset, kOverlaySize, kOverlaySize);
    _createShortcut();
  }

  favicon.onerror = function() {
    Cu.reportError("CreateShortcut: favicon image load error");
  }

  favicon.src = aIconURL;
}
+0 −46
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>

# ***** BEGIN LICENSE BLOCK *****
#
# 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/.
#
# ***** END LICENSE BLOCK *****

<!DOCTYPE html [
  <!ENTITY % htmlDTD
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "DTD/xhtml1-strict.dtd">
  %htmlDTD;
  <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
  %globalDTD;
  <!ENTITY % aboutAppsDTD SYSTEM "chrome://browser/locale/aboutApps.dtd">
  %aboutAppsDTD;
  <!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
  %browserDTD;
]>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>&aboutApps.title;</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="icon" type="image/png" href="chrome://branding/content/favicon32.png" />
    <link rel="stylesheet" type="text/css" href="chrome://browser/skin/aboutApps.css" media="all" />
    <script type="text/javascript;version=1.8" src="chrome://browser/content/aboutApps.js"></script>
  </head>

  <body dir="&locale.dir;" onload="onLoad(event)" onunload="onUnload(event)">
    <div id="main-container">
      <div>&aboutApps.title;</div>
      <div id="noapps" class="hidden">
        &aboutApps.noApps.pre;<a id="marketplaceURL" pref="app.marketplaceURL">&aboutApps.noApps.middle;</a>&aboutApps.noApps.post;
      </div>
      <div>
        <div class="spacer" id="spacer1"> </div>
        <div id="appgrid"/>
        <div class="spacer" id="spacer1"> </div>
      </div>
    </div>
  </body>
</html>
Loading