mail/base/content/specialTabs.js
author Edmund Wong <ewong@pw-wspx.org>
Fri, 10 Aug 2012 09:16:34 +0800
changeset 10843 2019e8845fbfd133c0d6dc246c1ae6392dc4cfa6
parent 10589 6446a293fb93cdebe043d27c09e87f41c336da5b
child 11082 11aa11518cee116da537534fdc8d0f3312ec18dc
permissions -rw-r--r--
Bug 778035 - Add extra else block to set CC/CXX for cases that don't have clang installed. r=Callek
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10318
Gervase Markham <gerv@gerv.net>
parents: 10009
diff changeset
     1
/* This Source Code Form is subject to the terms of the Mozilla Public
Gervase Markham <gerv@gerv.net>
parents: 10009
diff changeset
     2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Gervase Markham <gerv@gerv.net>
parents: 10009
diff changeset
     3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
     4
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
     5
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
6400
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
     6
Components.utils.import("resource://gre/modules/Services.jsm");
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
     7
Components.utils.import("resource://gre/modules/AddonManager.jsm");
8567
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
     8
Components.utils.import("resource:///modules/StringBundle.js");
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
     9
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    10
function tabProgressListener(aTab, aStartsBlank) {
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    11
  this.mTab = aTab;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    12
  this.mBrowser = aTab.browser;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    13
  this.mBlank = aStartsBlank;
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    14
  this.mProgressListener = null;
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    15
}
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    16
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    17
tabProgressListener.prototype =
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    18
{
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    19
  mTab: null,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    20
  mBrowser: null,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    21
  mBlank: null,
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    22
  mProgressListener: null,
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    23
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    24
  // cache flags for correct status bar update after tab switching
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    25
  mStateFlags: 0,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    26
  mStatus: 0,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    27
  mMessage: "",
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    28
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    29
  // count of open requests (should always be 0 or 1)
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    30
  mRequestCount: 0,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    31
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    32
  addProgressListener: function tPL_addProgressListener(aProgressListener) {
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    33
    this.mProgressListener = aProgressListener;
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    34
  },
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    35
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    36
  onProgressChange: function tPL_onProgressChange(aWebProgress, aRequest,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    37
                                                  aCurSelfProgress,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    38
                                                  aMaxSelfProgress,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    39
                                                  aCurTotalProgress,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    40
                                                  aMaxTotalProgress) {
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    41
    if (this.mProgressListener)
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    42
      this.mProgressListener.onProgressChange(aWebProgress, aRequest,
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    43
        aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress,
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    44
        aMaxTotalProgress);
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    45
  },
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    46
  onProgressChange64: function tPL_onProgressChange64(aWebProgress, aRequest,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    47
                                                      aCurSelfProgress,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    48
                                                      aMaxSelfProgress,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    49
                                                      aCurTotalProgress,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    50
                                                      aMaxTotalProgress) {
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    51
    if (this.mProgressListener)
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    52
      this.mProgressListener.onProgressChange64(aWebProgress, aRequest,
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    53
        aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress,
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    54
        aMaxTotalProgress);
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    55
  },
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    56
  onLocationChange: function tPL_onLocationChange(aWebProgress, aRequest,
8839
846450e2dfe4d719ac83768e68e613bbbce3455c add aFlag to state change events, r=bienvenu, bug 701679, editor changes by bienvenu CLOSED TREE
O. Atsushi <torisugari@gmail.com>
parents: 8833
diff changeset
    57
                                                  aLocationURI, aFlags) {
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    58
    if (this.mProgressListener)
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    59
      this.mProgressListener.onLocationChange(aWebProgress, aRequest,
8839
846450e2dfe4d719ac83768e68e613bbbce3455c add aFlag to state change events, r=bienvenu, bug 701679, editor changes by bienvenu CLOSED TREE
O. Atsushi <torisugari@gmail.com>
parents: 8833
diff changeset
    60
        aLocationURI, aFlags);
7067
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    61
    // onLocationChange is called for both the top-level content
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    62
    // and the subframes.
3959
21e93a577fa3f5cc7e257da7096c4ed5265e0c19 Bug 519041 Implement context menu for contentTabs - add options for stop, reload, undo, cut and paste. r=mkmelin,ui-review=clarkbw,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3755
diff changeset
    63
    if (aWebProgress.DOMWindow == this.mBrowser.contentWindow) {
7067
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    64
      // Don't clear the favicon if this onLocationChange was triggered
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    65
      // by a pushState or a replaceState. See bug 550565.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    66
      if (aWebProgress.isLoadingDocument &&
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    67
          !(this.mBrowser.docShell.loadType &
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    68
            Components.interfaces.nsIDocShell.LOAD_CMD_PUSHSTATE))
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    69
        this.mBrowser.mIconURL = null;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    70
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    71
      var location = aLocationURI ? aLocationURI.spec : "";
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    72
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    73
      // Set the reload command only if this is a report that is coming in about
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    74
      // the top-level content location change.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    75
      if (aWebProgress.DOMWindow == this.mBrowser.contentWindow) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    76
        // Although we're unlikely to be loading about:blank, we'll check it
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    77
        // anyway just in case. The second condition is for new tabs, otherwise
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    78
        // the reload function is enabled until tab is refreshed.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    79
        this.mTab.reloadEnabled =
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    80
          !((location == "about:blank" && !this.mBrowser.contentWindow.opener) ||
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    81
            location == "");
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
    82
      }
3959
21e93a577fa3f5cc7e257da7096c4ed5265e0c19 Bug 519041 Implement context menu for contentTabs - add options for stop, reload, undo, cut and paste. r=mkmelin,ui-review=clarkbw,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3755
diff changeset
    83
    }
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    84
  },
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    85
  onStateChange: function tPL_onStateChange(aWebProgress, aRequest, aStateFlags,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    86
                                            aStatus) {
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    87
    if (this.mProgressListener)
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    88
      this.mProgressListener.onStateChange(aWebProgress, aRequest, aStateFlags,
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    89
        aStatus);
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
    90
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    91
    if (!aRequest)
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    92
      return;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    93
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    94
    var oldBlank = this.mBlank;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    95
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    96
    const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    97
    const nsIChannel = Components.interfaces.nsIChannel;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    98
    let tabmail = document.getElementById("tabmail");
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
    99
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   100
    if (aStateFlags & nsIWebProgressListener.STATE_START) {
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   101
      this.mRequestCount++;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   102
    }
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   103
    else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   104
      // Since we (try to) only handle STATE_STOP of the last request,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   105
      // the count of open requests should now be 0.
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   106
      this.mRequestCount = 0;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   107
    }
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   108
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   109
    if (aStateFlags & nsIWebProgressListener.STATE_START &&
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   110
        aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   111
      if (!this.mBlank) {
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   112
        this.mTab.title = specialTabs.contentTabType.loadingTabString;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   113
        tabmail.setTabBusy(this.mTab, true);
4286
7c25972181652c1321812f1906e9007147adc192 Bug 517607 - "errorHook: tabmail.setTabtitle is not a function@chrome://messenger/content/specialTabs.js.100" [r=Standard8]
Myk Melez <myk@mozilla.org>
parents: 4012
diff changeset
   114
        tabmail.setTabTitle(this.mTab);
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   115
      }
6919
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   116
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   117
      // Set our unit testing variables accordingly
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   118
      this.mTab.pageLoading = true;
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   119
      this.mTab.pageLoaded = false;
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   120
    }
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   121
    else if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   122
             aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   123
      this.mBlank = false;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   124
      tabmail.setTabBusy(this.mTab, false);
4983
e6c5631dce79e5001419cfa9be9e3b7f59e12283 Bug 525848 Content tabs don't display 'Loading...' string between page loads. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 4372
diff changeset
   125
      tabmail.setTabTitle(this.mTab);
6919
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   126
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   127
      // Set our unit testing variables accordingly
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   128
      this.mTab.pageLoading = false;
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   129
      this.mTab.pageLoaded = true;
7067
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   130
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   131
      // If we've finished loading, and we've not had an icon loaded from a
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   132
      // link element, then we try using the default icon for the site.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   133
      if (aWebProgress.DOMWindow == this.mBrowser.contentWindow &&
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   134
        !this.mBrowser.mIconURL)
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   135
        specialTabs.useDefaultIcon(this.mTab);
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   136
    }
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   137
  },
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   138
  onStatusChange: function tPL_onStatusChange(aWebProgress, aRequest, aStatus,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   139
                                              aMessage) {
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   140
    if (this.mProgressListener)
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   141
      this.mProgressListener.onStatusChange(aWebProgress, aRequest, aStatus,
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   142
        aMessage);
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   143
  },
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   144
  onSecurityChange: function tPL_onSecurityChange(aWebProgress, aRequest,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   145
                                                  aState) {
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   146
    if (this.mProgressListener)
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   147
      this.mProgressListener.onSecurityChange(aWebProgress, aRequest, aState);
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   148
  },
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   149
  onRefreshAttempted: function tPL_OnRefreshAttempted(aWebProgress, aURI,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   150
                                                      aDelay, aSameURI) {
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   151
    if (this.mProgressListener)
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   152
      this.mProgressListener.onRefreshAttempted(aWebProgress, aURI, aDelay,
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   153
        aSameURI);
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   154
  },
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   155
  QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIWebProgressListener,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   156
                                         Components.interfaces.nsIWebProgressListener2,
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   157
                                         Components.interfaces.nsISupportsWeakReference])
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   158
};
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   159
7067
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   160
const DOMLinkHandler = {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   161
  handleEvent: function (event) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   162
    switch (event.type) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   163
    case "DOMLinkAdded":
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   164
      this.onLinkAdded(event);
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   165
      break;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   166
    }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   167
  },
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   168
  onLinkAdded: function (event) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   169
    let link = event.originalTarget;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   170
    let rel = link.rel && link.rel.toLowerCase();
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   171
    if (!link || !link.ownerDocument || !rel || !link.href)
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   172
      return;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   173
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   174
    if (rel.split(/\s+/).indexOf("icon") != -1) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   175
      if (!Services.prefs.getBoolPref("browser.chrome.site_icons"))
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   176
        return;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   177
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   178
      let targetDoc = link.ownerDocument;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   179
      let uri = makeURI(link.href, targetDoc.characterSet);
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   180
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   181
      // Is this a failed icon?
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   182
      if (specialTabs.mFaviconService.isFailedFavicon(uri))
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   183
        return;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   184
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   185
      // Verify that the load of this icon is legal.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   186
      // Some error or special pages can load their favicon.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   187
      // To be on the safe side, only allow chrome:// favicons.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   188
      let isAllowedPage = [
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   189
        /^about:neterror\?/,
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   190
        /^about:blocked\?/,
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   191
        /^about:certerror\?/,
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   192
        /^about:home$/
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   193
      ].some(function (re) { re.test(targetDoc.documentURI); });
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   194
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   195
      if (!isAllowedPage || !uri.schemeIs("chrome")) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   196
        // Be extra paraniod and just make sure we're not going to load
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   197
        // something we shouldn't. Firefox does this, so we're doing the same.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   198
        let ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   199
          .getService(Components.interfaces.nsIScriptSecurityManager);
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   200
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   201
          try {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   202
            ssm.checkLoadURIWithPrincipal(targetDoc.nodePrincipal, uri,
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   203
                                          Components.interfaces.nsIScriptSecurityManager.DISALLOW_SCRIPT);
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   204
          }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   205
          catch (ex) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   206
            return;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   207
          }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   208
      }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   209
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   210
      const nsIContentPolicy = Components.interfaces.nsIContentPolicy;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   211
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   212
      try {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   213
        var contentPolicy = Components.classes["@mozilla.org/layout/content-policy;1"]
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   214
          .getService(nsIContentPolicy);
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   215
      }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   216
      catch (e) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   217
        // Refuse to load if we can't do a security check.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   218
        return;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   219
      }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   220
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   221
      // Security says okay, now ask content policy. This is probably trying to
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   222
      // ensure that the image loaded always obeys the content policy. There
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   223
      // may have been a chance that it was cached and we're trying to load it
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   224
      // direct from the cache and not the normal route.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   225
      if (contentPolicy.shouldLoad(nsIContentPolicy.TYPE_IMAGE,
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   226
                                   uri, targetDoc.documentURIObject,
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   227
                                   link, link.type, null) !=
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   228
                                   nsIContentPolicy.ACCEPT)
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   229
        return;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   230
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   231
      let tab = document.getElementById("tabmail")
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   232
                        .getBrowserForDocument(targetDoc.defaultView);
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   233
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   234
      // If we don't have a browser/tab, then don't load the icon.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   235
      if (!tab)
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   236
        return;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   237
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   238
      // Just set the url on the browser and we'll display the actual icon
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   239
      // when we finish loading the page.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   240
      specialTabs.setTabIcon(tab, link.href);
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   241
    }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   242
  }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   243
};
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   244
8567
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   245
const kTelemetryPrompted    = "toolkit.telemetry.prompted";
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   246
const kTelemetryEnabled     = "toolkit.telemetry.enabled";
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   247
const kTelemetryServerOwner = "toolkit.telemetry.server_owner";
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   248
8812
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   249
var contentTabBaseType = {
9028
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   250
  inContentWhitelist: ['about:addons'],
8812
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   251
  shouldSwitchTo: function onSwitchTo({contentPage: aContentPage}) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   252
    let tabmail = document.getElementById("tabmail");
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   253
    let tabInfo = tabmail.tabInfo;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   254
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   255
    // Remove any anchors - especially for the about: pages, we just want
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   256
    // to re-use the same tab.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   257
    let regEx = new RegExp("#.*");
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   258
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   259
    let contentUrl = aContentPage.replace(regEx, "");
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   260
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   261
    for (let selectedIndex = 0; selectedIndex < tabInfo.length;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   262
         ++selectedIndex) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   263
      if (tabInfo[selectedIndex].mode.name == this.name &&
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   264
          tabInfo[selectedIndex].browser.currentURI.spec
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   265
                                .replace(regEx, "") == contentUrl) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   266
        // Ensure we go to the correct location on the page.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   267
        tabInfo[selectedIndex].browser
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   268
                              .setAttribute("src", aContentPage);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   269
        return selectedIndex;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   270
      }
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   271
    }
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   272
    return -1;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   273
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   274
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   275
  closeTab: function onTabClosed(aTab) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   276
    aTab.browser.removeEventListener("DOMTitleChanged",
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   277
                                     aTab.titleListener, true);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   278
    aTab.browser.removeEventListener("DOMWindowClose",
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   279
                                     aTab.closeListener, true);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   280
    aTab.browser.removeEventListener("DOMLinkAdded", DOMLinkHandler, false);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   281
    gPluginHandler.removeEventListeners(aTab.browser);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   282
    aTab.browser.webProgress.removeProgressListener(aTab.filter);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   283
    aTab.filter.removeProgressListener(aTab.progressListener);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   284
    aTab.browser.destroy();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   285
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   286
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   287
  saveTabState: function onSaveTabState(aTab) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   288
    aTab.browser.setAttribute("type", "content-targetable");
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   289
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   290
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   291
  showTab: function onShowTab(aTab) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   292
    aTab.browser.setAttribute("type", "content-primary");
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   293
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   294
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   295
  getBrowser: function getBrowser(aTab) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   296
    return aTab.browser;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   297
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   298
9028
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   299
  hideChromeForLocation: function hideChromeForLocation(aLocation) {
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   300
    return this.inContentWhitelist.indexOf(aLocation) != -1;
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   301
  },
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   302
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   303
  /* _setUpLoadListener attaches a load listener to the tab browser that
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   304
   * checks the loaded URL to see if it matches the inContentWhitelist.
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   305
   * If so, then we apply the disablechrome attribute to the contentTab
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   306
   * container.
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   307
   */
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   308
  _setUpLoadListener: function setUpLoadListener(aTab) {
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   309
    let self = this;
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   310
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   311
    function onLoad(aEvent) {
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   312
      let doc = aEvent.originalTarget;
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   313
      if (self.hideChromeForLocation(doc.defaultView.location.href)) {
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   314
        aTab.root.setAttribute("disablechrome", "true");
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   315
      } else {
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   316
        doc.documentElement.removeAttribute("disablechrome");
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   317
      }
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   318
    }
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   319
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   320
    aTab.loadListener = onLoad;
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   321
    aTab.browser.addEventListener("load", aTab.loadListener, true);
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   322
  },
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   323
8812
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   324
  // Internal function used to set up the title listener on a content tab.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   325
  _setUpTitleListener: function setUpTitleListener(aTab) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   326
    function onDOMTitleChanged(aEvent) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   327
      aTab.title = aTab.browser.contentTitle;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   328
      document.getElementById("tabmail").setTabTitle(aTab);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   329
    }
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   330
    // Save the function we'll use as listener so we can remove it later.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   331
    aTab.titleListener = onDOMTitleChanged;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   332
    // Add the listener.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   333
    aTab.browser.addEventListener("DOMTitleChanged", aTab.titleListener, true);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   334
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   335
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   336
    /**
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   337
     * Internal function used to set up the close window listener on a content
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   338
     * tab.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   339
     */
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   340
  _setUpCloseWindowListener: function setUpCloseWindowListener(aTab) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   341
    function onDOMWindowClose(aEvent) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   342
      if (!aEvent.isTrusted)
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   343
        return;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   344
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   345
      // Redirect any window.close events to closing the tab. As a 3-pane tab
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   346
      // must be open, we don't need to worry about being the last tab open.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   347
      document.getElementById("tabmail").closeTab(aTab);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   348
      aEvent.preventDefault();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   349
    }
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   350
    // Save the function we'll use as listener so we can remove it later.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   351
    aTab.closeListener = onDOMWindowClose;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   352
    // Add the listener.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   353
    aTab.browser.addEventListener("DOMWindowClose", aTab.closeListener, true);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   354
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   355
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   356
  supportsCommand: function supportsCommand(aCommand, aTab) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   357
    switch (aCommand) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   358
      case "cmd_fullZoomReduce":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   359
      case "cmd_fullZoomEnlarge":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   360
      case "cmd_fullZoomReset":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   361
      case "cmd_fullZoomToggle":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   362
      case "cmd_find":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   363
      case "cmd_findAgain":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   364
      case "cmd_findPrevious":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   365
      case "cmd_printSetup":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   366
      case "cmd_print":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   367
      case "button_print":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   368
      case "cmd_stop":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   369
      case "cmd_reload":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   370
      // XXX print preview not currently supported - bug 497994 to implement.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   371
      // case "cmd_printpreview":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   372
        return true;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   373
      default:
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   374
        return false;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   375
    }
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   376
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   377
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   378
  isCommandEnabled: function isCommandEnabled(aCommand, aTab) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   379
    switch (aCommand) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   380
      case "cmd_fullZoomReduce":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   381
      case "cmd_fullZoomEnlarge":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   382
      case "cmd_fullZoomReset":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   383
      case "cmd_fullZoomToggle":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   384
      case "cmd_find":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   385
      case "cmd_findAgain":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   386
      case "cmd_findPrevious":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   387
      case "cmd_printSetup":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   388
      case "cmd_print":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   389
      case "button_print":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   390
      // XXX print preview not currently supported - bug 497994 to implement.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   391
      // case "cmd_printpreview":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   392
        return true;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   393
      case "cmd_reload":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   394
        return aTab.reloadEnabled;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   395
      case "cmd_stop":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   396
        return aTab.busy;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   397
      default:
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   398
        return false;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   399
    }
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   400
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   401
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   402
  doCommand: function doCommand(aCommand, aTab) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   403
    switch (aCommand) {
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   404
      case "cmd_fullZoomReduce":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   405
        ZoomManager.reduce();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   406
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   407
      case "cmd_fullZoomEnlarge":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   408
        ZoomManager.enlarge();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   409
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   410
      case "cmd_fullZoomReset":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   411
        ZoomManager.reset();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   412
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   413
      case "cmd_fullZoomToggle":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   414
        ZoomManager.toggleZoom();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   415
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   416
      case "cmd_find":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   417
        aTab.findbar.onFindCommand();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   418
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   419
      case "cmd_findAgain":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   420
        aTab.findbar.onFindAgainCommand(false);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   421
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   422
      case "cmd_findPrevious":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   423
        aTab.findbar.onFindAgainCommand(true);
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   424
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   425
      case "cmd_printSetup":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   426
        PrintUtils.showPageSetup();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   427
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   428
      case "cmd_print":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   429
        PrintUtils.print();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   430
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   431
      // XXX print preview not currently supported - bug 497994 to implement.
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   432
      //case "cmd_printpreview":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   433
      //  PrintUtils.printPreview();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   434
      //  break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   435
      case "cmd_stop":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   436
        aTab.browser.stop();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   437
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   438
      case "cmd_reload":
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   439
        aTab.browser.reload();
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   440
        break;
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   441
    }
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   442
  },
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   443
};
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   444
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   445
var specialTabs = {
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   446
  _kAboutRightsVersion: 1,
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   447
  get _protocolSvc() {
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   448
    delete this._protocolSvc;
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   449
    return this._protocolSvc =
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   450
      Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   451
                .getService(Components.interfaces.nsIExternalProtocolService);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   452
  },
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   453
7067
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   454
  get mFaviconService() {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   455
    delete this.mFaviconService;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   456
    return this.mFaviconService =
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   457
      Components.classes["@mozilla.org/browser/favicon-service;1"]
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   458
                .getService(Components.interfaces.nsIFaviconService);
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   459
  },
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   460
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   461
  // This will open any special tabs if necessary on startup.
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   462
  openSpecialTabsOnStartup: function() {
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
   463
    window.addEventListener("unload", specialTabs.onunload, false);
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
   464
6400
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   465
    let browser = document.getElementById("dummycontentbrowser");
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   466
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   467
    // Manually hook up session and global history for the first browser
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   468
    // so that we don't have to load global history before bringing up a
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   469
    // window.
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   470
    // Wire up session and global history before any possible
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   471
    // progress notifications for back/forward button updating
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   472
    browser.webNavigation.sessionHistory =
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   473
      Components.classes["@mozilla.org/browser/shistory;1"]
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   474
                .createInstance(Components.interfaces.nsISHistory);
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   475
    Services.obs.addObserver(browser, "browser:purge-session-history", false);
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   476
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   477
    // remove the disablehistory attribute so the browser cleans up, as
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   478
    // though it had done this work itself
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   479
    browser.removeAttribute("disablehistory");
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   480
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   481
    // enable global history
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   482
    try {
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   483
      browser.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory)
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   484
             .useGlobalHistory = true;
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   485
    } catch(ex) {
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   486
      Components.utils.reportError("Places database may be locked: " + ex);
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   487
    }
1804f025138327d6bf54a952b8ec32d2289c63e8 Bug 571759 - Move Add-on Manager to be in a content tab; r=bwinton.
Mark Banner <bugzilla@standard8.plus.com>
parents: 5492
diff changeset
   488
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
   489
    Services.obs.addObserver(specialTabs, "mail-startup-done", false);
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
   490
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   491
    let tabmail = document.getElementById('tabmail');
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   492
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   493
    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   494
                          .getService(Components.interfaces.nsIPrefBranch);
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   495
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   496
    tabmail.registerTabType(this.contentTabType);
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   497
    tabmail.registerTabType(this.chromeTabType);
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   498
10562
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   499
    // If we've upgraded (note: always get these values so that we set
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   500
    // the mstone preference for the new version):
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   501
    let [fromVer, toVer] = this.getApplicationUpgradeVersions(prefs);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   502
10562
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   503
    // Although this might not be really necessary because of the version checks, we'll
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   504
    // check this pref anyway and clear it so that we are consistent with what Firefox
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   505
    // actually does. It will help developers switching between branches without updating.
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   506
    if (Services.prefs.prefHasUserValue("app.update.postupdate")) {
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   507
      // Only show what's new tab if this is actually an upgraded version,
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   508
      // not just a new installation/profile (and don't show if the major version
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   509
      // hasn't changed).
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   510
      if (fromVer && ((fromVer[0] != toVer[0]) || (fromVer[1] != toVer[1]))) {
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   511
          // showWhatsNewPage checks the details of the update manager before
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   512
          // showing the page.
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   513
          this.showWhatsNewPage();
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   514
      }
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   515
      Services.prefs.clearUserPref("app.update.postupdate");
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   516
    }
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   517
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   518
    // Show the about rights notification if we need to.
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   519
    if (this.shouldShowAboutRightsNotification(prefs))
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   520
      this.showAboutRightsNotification(prefs);
8567
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   521
    else if (this.shouldShowTelemetryNotification(prefs))
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   522
      this.showTelemetryNotification(prefs);
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   523
  },
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   524
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   525
  /**
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   526
   * A tab to show content pages.
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   527
   */
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   528
  contentTabType: {
8812
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   529
    __proto__: contentTabBaseType,
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   530
    name: "contentTab",
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   531
    perTabPanel: "vbox",
2781
d4dc984c7653697a259d32225bc6f3bd0fc739b7 Bug 495818 Zoom menu applies to the message pane rather than the browser in the selected tab. r=philringnalda
Mark Banner <bugzilla@standard8.plus.com>
parents: 2475
diff changeset
   532
    lastBrowserId: 0,
2808
61d5f8fd0fe2d3bca890b4b7e69af89c270df8f0 Bug 496647 Set content tab titles from the actual content not pre-stored values. r=philringnalda,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 2781
diff changeset
   533
    get loadingTabString() {
61d5f8fd0fe2d3bca890b4b7e69af89c270df8f0 Bug 496647 Set content tab titles from the actual content not pre-stored values. r=philringnalda,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 2781
diff changeset
   534
      delete this.loadingTabString;
61d5f8fd0fe2d3bca890b4b7e69af89c270df8f0 Bug 496647 Set content tab titles from the actual content not pre-stored values. r=philringnalda,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 2781
diff changeset
   535
      return this.loadingTabString = document.getElementById("bundle_messenger")
61d5f8fd0fe2d3bca890b4b7e69af89c270df8f0 Bug 496647 Set content tab titles from the actual content not pre-stored values. r=philringnalda,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 2781
diff changeset
   536
                                             .getString("loadingTab");
61d5f8fd0fe2d3bca890b4b7e69af89c270df8f0 Bug 496647 Set content tab titles from the actual content not pre-stored values. r=philringnalda,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 2781
diff changeset
   537
    },
61d5f8fd0fe2d3bca890b4b7e69af89c270df8f0 Bug 496647 Set content tab titles from the actual content not pre-stored values. r=philringnalda,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 2781
diff changeset
   538
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   539
    modes: {
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   540
      contentTab: {
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   541
        type: "contentTab",
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   542
        maxTabs: 10
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   543
      }
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   544
    },
2475
eaae6740e85e9da0b2720cbb2dec521b0d3881ad Bug 489154 Allow openTab for contentTab tab panels to switch to, rather than open, existing tabs. r=mkmelin
Mark Banner <bugzilla@standard8.plus.com>
parents: 2385
diff changeset
   545
7324
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   546
    /**
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   547
     * This is the internal function used by content tabs to open a new tab. To
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   548
     * open a contentTab, use specialTabs.openTab("contentTab", aArgs)
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   549
     *
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   550
     * @param aArgs The options that content tabs accept.
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   551
     * @param aArgs.contentPage A string that holds the URL that is to be opened
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   552
     * @param aArgs.clickHandler The click handler for that content tab. See the
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   553
     *  "Content Tabs" article on MDC.
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   554
     * @param aArgs.onLoad A function that takes an Event and a DOMNode. It is
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   555
     *  called when the content page is done loading. The first argument is the
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   556
     *  load event, and the second argument is the xul:browser that holds the
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   557
     *  contentPage. You can access the inner tab's window object by accessing
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   558
     *  the second parameter's contentWindow property.
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   559
     */
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   560
    openTab: function contentTab_onTabOpened(aTab, aArgs) {
3482
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   561
      if (!"contentPage" in aArgs)
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   562
        throw("contentPage must be specified");
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   563
3396
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   564
      // First clone the page and set up the basics.
3299
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   565
      let clone = document.getElementById("contentTab").firstChild.cloneNode(true);
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   566
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   567
      clone.setAttribute("id", "contentTab" + this.lastBrowserId);
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   568
      clone.setAttribute("collapsed", false);
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   569
10589
6446a293fb93cdebe043d27c09e87f41c336da5b Bug 770133 - Fix duplicated IDs. r=mconley
teramako <teramako@gmail.com>
parents: 10562
diff changeset
   570
      let toolbox = clone.firstChild;
6446a293fb93cdebe043d27c09e87f41c336da5b Bug 770133 - Fix duplicated IDs. r=mconley
teramako <teramako@gmail.com>
parents: 10562
diff changeset
   571
      toolbox.setAttribute("id", "contentTabToolbox" + this.lastBrowserId);
6446a293fb93cdebe043d27c09e87f41c336da5b Bug 770133 - Fix duplicated IDs. r=mconley
teramako <teramako@gmail.com>
parents: 10562
diff changeset
   572
      toolbox.firstChild.setAttribute("id", "contentTabToolbar" + this.lastBrowserId);
6446a293fb93cdebe043d27c09e87f41c336da5b Bug 770133 - Fix duplicated IDs. r=mconley
teramako <teramako@gmail.com>
parents: 10562
diff changeset
   573
3299
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   574
      aTab.panel.appendChild(clone);
9028
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   575
      aTab.root = clone;
3299
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   576
3396
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   577
      // Start setting up the browser.
3299
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   578
      aTab.browser = aTab.panel.getElementsByTagName("browser")[0];
9028
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   579
      aTab.toolbar = aTab.panel.getElementsByClassName("contentTabToolbar")[0];
3299
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   580
3482
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   581
      // As we're opening this tab, showTab may not get called, so set
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   582
      // the type according to if we're opening in background or not.
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   583
      let background = ("background" in aArgs) && aArgs.background;
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   584
      aTab.browser.setAttribute("type", background ? "content-targetable" :
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   585
                                                     "content-primary");
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   586
3299
6c421b0b5d95dae3b25ba2f2dced971e903d9f09 Bug 510302 Provide an overlay for content tab elements. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 2979
diff changeset
   587
      aTab.browser.setAttribute("id", "contentTabBrowser" + this.lastBrowserId);
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   588
7789
4d710242ad6ec02f7d9c9a75281a86aa430c3505 Bug 635693 - Clicking on links in add-on manager brings up tabs with addons.mozilla.org but you can't do anything in those tabs (e.g. Personas installation); r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7638
diff changeset
   589
      aTab.clickHandler = "clickHandler" in aArgs && aArgs.clickHandler ?
4d710242ad6ec02f7d9c9a75281a86aa430c3505 Bug 635693 - Clicking on links in add-on manager brings up tabs with addons.mozilla.org but you can't do anything in those tabs (e.g. Personas installation); r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7638
diff changeset
   590
                          aArgs.clickHandler :
4d710242ad6ec02f7d9c9a75281a86aa430c3505 Bug 635693 - Clicking on links in add-on manager brings up tabs with addons.mozilla.org but you can't do anything in those tabs (e.g. Personas installation); r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7638
diff changeset
   591
                          "specialTabs.defaultClickHandler(event);";
4d710242ad6ec02f7d9c9a75281a86aa430c3505 Bug 635693 - Clicking on links in add-on manager brings up tabs with addons.mozilla.org but you can't do anything in those tabs (e.g. Personas installation); r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7638
diff changeset
   592
      aTab.browser.setAttribute("onclick", aTab.clickHandler);
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   593
7067
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   594
      // Set this attribute so that when favicons fail to load, we remove the
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   595
      // image attribute and just show the default tab icon.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   596
      aTab.tabNode.setAttribute("onerror", "this.removeAttribute('image');");
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   597
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   598
      aTab.browser.addEventListener("DOMLinkAdded", DOMLinkHandler, false);
8570
9fa12b677b96af32705c70646afa5ce7fc871f17 Bug 661410 - Implement UI for out-of-process plugins. r=Standard8
Mike Conley <mconley@mozilla.com>
parents: 8567
diff changeset
   599
      gPluginHandler.addEventListeners(aTab.browser);
7067
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
   600
3396
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   601
      // Now initialise the find bar.
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   602
      aTab.findbar = aTab.panel.getElementsByTagName("findbar")[0];
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   603
      aTab.findbar.setAttribute("browserid",
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   604
                                "contentTabBrowser" + this.lastBrowserId);
2808
61d5f8fd0fe2d3bca890b4b7e69af89c270df8f0 Bug 496647 Set content tab titles from the actual content not pre-stored values. r=philringnalda,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 2781
diff changeset
   605
3959
21e93a577fa3f5cc7e257da7096c4ed5265e0c19 Bug 519041 Implement context menu for contentTabs - add options for stop, reload, undo, cut and paste. r=mkmelin,ui-review=clarkbw,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3755
diff changeset
   606
      // Default to reload being disabled.
21e93a577fa3f5cc7e257da7096c4ed5265e0c19 Bug 519041 Implement context menu for contentTabs - add options for stop, reload, undo, cut and paste. r=mkmelin,ui-review=clarkbw,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3755
diff changeset
   607
      aTab.reloadEnabled = false;
21e93a577fa3f5cc7e257da7096c4ed5265e0c19 Bug 519041 Implement context menu for contentTabs - add options for stop, reload, undo, cut and paste. r=mkmelin,ui-review=clarkbw,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3755
diff changeset
   608
3396
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   609
      // Now set up the listeners.
9028
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   610
      this._setUpLoadListener(aTab);
3396
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   611
      this._setUpTitleListener(aTab);
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   612
      this._setUpCloseWindowListener(aTab);
9028
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
   613
7324
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   614
      if ("onLoad" in aArgs) {
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   615
        aTab.browser.addEventListener("load", function _contentTab_onLoad (event) {
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   616
          aArgs.onLoad(event, aTab.browser);
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   617
          aTab.browser.removeEventListener("load", _contentTab_onLoad, true);
7324
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   618
        }, true);
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   619
      }
3396
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   620
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   621
      // Create a filter and hook it up to our browser
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   622
      let filter = Components.classes["@mozilla.org/appshell/component/browser-status-filter;1"]
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   623
                             .createInstance(Components.interfaces.nsIWebProgress);
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   624
      aTab.filter = filter;
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   625
      aTab.browser.webProgress.addProgressListener(filter, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   626
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   627
      // Wire up a progress listener to the filter for this browser
4012
d4529d3c242951b31137bba32e25f79ff559da65 Bug 519951 Closing a contentTab leaks an nsBrowserStatusFilter and others. r=bienvenu,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3980
diff changeset
   628
      aTab.progressListener = new tabProgressListener(aTab, false);
d4529d3c242951b31137bba32e25f79ff559da65 Bug 519951 Closing a contentTab leaks an nsBrowserStatusFilter and others. r=bienvenu,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3980
diff changeset
   629
d4529d3c242951b31137bba32e25f79ff559da65 Bug 519951 Closing a contentTab leaks an nsBrowserStatusFilter and others. r=bienvenu,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3980
diff changeset
   630
      filter.addProgressListener(aTab.progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
3755
f5e0cd5b5c9d85ef4024651639ac7f538d3730eb Bug 511240 Provide feedback for loading of content within content tabs. r=asuth,a=Standard8
Mark Banner <bugzilla@standard8.plus.com>
parents: 3515
diff changeset
   631
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   632
      if ("onListener" in aArgs)
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   633
        aArgs.onListener(aTab.browser, aTab.progressListener);
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
   634
6919
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   635
      // Initialize our unit testing variables.
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   636
      aTab.pageLoading = false;
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   637
      aTab.pageLoaded = false;
6f67325cc686e901274da4d05523887edb653967 Bug 623503 - Factor out MozMill content-tab helper code into a separate file. r=Standard8
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6400
diff changeset
   638
3396
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   639
      // Now start loading the content.
2808
61d5f8fd0fe2d3bca890b4b7e69af89c270df8f0 Bug 496647 Set content tab titles from the actual content not pre-stored values. r=philringnalda,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 2781
diff changeset
   640
      aTab.title = this.loadingTabString;
61d5f8fd0fe2d3bca890b4b7e69af89c270df8f0 Bug 496647 Set content tab titles from the actual content not pre-stored values. r=philringnalda,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 2781
diff changeset
   641
3482
014559d2105b491a9e47f691a0786d579df4fb49 Bug 513653 Fix switching to an existing tab when trying to open a content tab with the same url. Also fix correctly setting content-primary on a newly opened tab. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3397
diff changeset
   642
      aTab.browser.loadURI(aArgs.contentPage);
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   643
2781
d4dc984c7653697a259d32225bc6f3bd0fc739b7 Bug 495818 Zoom menu applies to the message pane rather than the browser in the selected tab. r=philringnalda
Mark Banner <bugzilla@standard8.plus.com>
parents: 2475
diff changeset
   644
      this.lastBrowserId++;
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   645
    },
7638
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
   646
    tryCloseTab: function onTryCloseTab(aTab) {
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
   647
      let docShell = aTab.browser.docShell;
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
   648
      // If we have a docshell, a contentViewer, and it forbids us from closing
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
   649
      // the tab, then we return false, which means, we can't close the tab. All
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
   650
      // other cases return true.
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
   651
      return !(docShell && docShell.contentViewer
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
   652
        && !docShell.contentViewer.permitUnload());
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
   653
    },
3397
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   654
    persistTab: function onPersistTab(aTab) {
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   655
      if (aTab.browser.currentURI.spec == "about:blank")
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   656
        return null;
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   657
7789
4d710242ad6ec02f7d9c9a75281a86aa430c3505 Bug 635693 - Clicking on links in add-on manager brings up tabs with addons.mozilla.org but you can't do anything in those tabs (e.g. Personas installation); r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7638
diff changeset
   658
      let onClick = aTab.clickHandler;
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   659
3397
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   660
      return {
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   661
        tabURI: aTab.browser.currentURI.spec,
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   662
        clickHandler: onClick ? onClick : null
3397
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   663
      };
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   664
    },
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   665
    restoreTab: function onRestoreTab(aTabmail, aPersistedState) {
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   666
      aTabmail.openTab("contentTab", { contentPage: aPersistedState.tabURI,
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   667
                                       clickHandler: aPersistedState.clickHandler,
3397
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   668
                                       background: true } );
c36a73422b327994ca6f8b574428c02b8d0c2b4d Bug 512245 Implement tab persist for content tabs. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3396
diff changeset
   669
    },
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   670
  },
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   671
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   672
  /**
8642
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   673
   * Split a version number into a triple (major, minor, extension)
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   674
   * For example, 7.0.1 => [7, 0, 1]
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   675
   *             10.1a3 => [10, 1, a3]
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   676
   *             10.0 => [10, 0, ""]
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   677
   * This could be a static function, but no current reason for it to
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   678
   * be available outside this object's scope; as a method, it doesn't
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   679
   * pollute anyone else's namespace
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   680
   */
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   681
  splitVersion: function(version) {
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   682
    let re = /^(\d+)\.(\d+)\.?(.*)$/;
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   683
    let fields = re.exec(version);
8849
6183e7eb32db275e50c8ff6b3b09965f28eca110 Bug 702086 - Don't throw when version is null in specialTabs.splitVersion; r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8839
diff changeset
   684
    if (fields === null)
6183e7eb32db275e50c8ff6b3b09965f28eca110 Bug 702086 - Don't throw when version is null in specialTabs.splitVersion; r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8839
diff changeset
   685
      return null;
8642
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   686
    /* First element of the array from regex match is the entire string; drop that */
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   687
    fields.shift();
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   688
    return fields;
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   689
  },
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   690
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   691
  /**
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   692
   * In the case of an upgrade, returns the version we're upgrading
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   693
   * from, as well as the current version.  In the case of a fresh profile,
3965
0a124a4beb0b11c1b274c4685d8c977825efef0b Bustage follow up to bug 516884 - respect mailnews.start_page_override.mstone = ignore again.
Mark Banner <bugzilla@standard8.plus.com>
parents: 3963
diff changeset
   694
   * or the pref being set to ignore - return null and the current version.
0a124a4beb0b11c1b274c4685d8c977825efef0b Bustage follow up to bug 516884 - respect mailnews.start_page_override.mstone = ignore again.
Mark Banner <bugzilla@standard8.plus.com>
parents: 3963
diff changeset
   695
   * In either case, updates the pref with the latest version.
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   696
   */
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   697
  getApplicationUpgradeVersions: function(prefs) {
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   698
    let savedAppVersion = null;
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   699
    let prefstring = "mailnews.start_page_override.mstone";
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   700
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   701
    try {
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   702
      savedAppVersion = prefs.getCharPref(prefstring);
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   703
    } catch (ex) {}
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   704
3965
0a124a4beb0b11c1b274c4685d8c977825efef0b Bustage follow up to bug 516884 - respect mailnews.start_page_override.mstone = ignore again.
Mark Banner <bugzilla@standard8.plus.com>
parents: 3963
diff changeset
   705
    let currentApplicationVersion = Application.version;
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   706
3965
0a124a4beb0b11c1b274c4685d8c977825efef0b Bustage follow up to bug 516884 - respect mailnews.start_page_override.mstone = ignore again.
Mark Banner <bugzilla@standard8.plus.com>
parents: 3963
diff changeset
   707
    if (savedAppVersion == "ignore")
8642
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   708
      return [null, this.splitVersion(currentApplicationVersion)];
3965
0a124a4beb0b11c1b274c4685d8c977825efef0b Bustage follow up to bug 516884 - respect mailnews.start_page_override.mstone = ignore again.
Mark Banner <bugzilla@standard8.plus.com>
parents: 3963
diff changeset
   709
0a124a4beb0b11c1b274c4685d8c977825efef0b Bustage follow up to bug 516884 - respect mailnews.start_page_override.mstone = ignore again.
Mark Banner <bugzilla@standard8.plus.com>
parents: 3963
diff changeset
   710
    if (savedAppVersion != currentApplicationVersion)
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   711
      prefs.setCharPref(prefstring, currentApplicationVersion);
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   712
8642
c320a8c6b331ad8fd9d7ad9ba5d44be2f70d6d68 Bug 690316 - Disable the what's new tab for users updating to minor/security release versions. r=Standard8
Irving Reid <irving@mozilla.com>
parents: 8570
diff changeset
   713
    return [this.splitVersion(savedAppVersion), this.splitVersion(currentApplicationVersion)];
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   714
  },
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   715
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   716
  /**
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   717
   * Shows the what's new page in a content tab.
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
   718
   */
2385
61ce89d965e04e9c9112b0642240e0c1bd9273e1 Part of Bug 466527 Setting the mail start page to non-redirects causes bad display of what's new tab - Load the what's new page into content. r=dmose
Mark Banner <bugzilla@standard8.plus.com>
parents: 2085
diff changeset
   719
  showWhatsNewPage: function onShowWhatsNewPage() {
10562
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   720
    let um = Components.classes["@mozilla.org/updates/update-manager;1"]
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   721
               .getService(Components.interfaces.nsIUpdateManager);
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   722
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   723
    try {
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   724
      // If the updates.xml file is deleted then getUpdateAt will throw.
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   725
      var update = um.getUpdateAt(0)
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   726
                     .QueryInterface(Components.interfaces.nsIPropertyBag);
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   727
    } catch (x) {
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   728
      Cu.reportError("Unable to find update: " + x);
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   729
      return;
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   730
    }
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   731
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   732
    let actions = update.getProperty("actions");
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   733
    if (actions && actions.indexOf("silent") != -1)
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   734
      return;
82179c85043d0656106bd47f034f9ed582780265 Bug 752867 - Support disabling of what's new prompts via the update server snippets. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 10365
diff changeset
   735
3324
0ab74a7268e0506d7e6740b2fe679506f0beb5e6 Bug 486432 Can't get back to "What's New" tab. r=mkmelin,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 3299
diff changeset
   736
    openWhatsNew();
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   737
  },
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   738
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   739
  /**
8567
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   740
   * Looks at the existing prefs and determines if we should suggest the user
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   741
   * enables telemetry or not.
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   742
   *
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   743
   * This is controlled by the pref toolkit.telemetry.prompted
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   744
   */
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   745
  shouldShowTelemetryNotification: function(prefs) {
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   746
    // toolkit has decided that the pref should have no default value
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   747
    try {
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   748
      if (prefs.getBoolPref(kTelemetryPrompted) || prefs.getBoolPref(kTelemetryEnabled))
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   749
        return false;
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   750
    } catch (e) { }
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   751
    return true;
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   752
  },
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   753
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   754
  showTelemetryNotification: function(prefs) {
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   755
    var notifyBox = document.getElementById("mail-notification-box");
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   756
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   757
    var brandBundle =
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   758
      new StringBundle("chrome://branding/locale/brand.properties");
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   759
    var telemetryBundle =
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   760
      new StringBundle("chrome://messenger/locale/telemetry.properties");
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   761
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   762
    var productName = brandBundle.get("brandFullName");
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   763
    var serverOwner = prefs.getCharPref(kTelemetryServerOwner);
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   764
    var telemetryText = telemetryBundle.get("telemetryText", [productName, serverOwner]);
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   765
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   766
    var buttons = [
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   767
      {
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   768
        label:     telemetryBundle.get("telemetryYesButtonLabel"),
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   769
        accessKey: telemetryBundle.get("telemetryYesButtonAccessKey"),
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   770
        popup:     null,
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   771
        callback:  function(aNotificationBar, aButton) {
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   772
          prefs.setBoolPref(kTelemetryEnabled, true);
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   773
        }
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   774
      },
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   775
      {
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   776
        label:     telemetryBundle.get("telemetryNoButtonLabel"),
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   777
        accessKey: telemetryBundle.get("telemetryNoButtonAccessKey"),
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   778
        popup:     null,
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   779
        callback:  function(aNotificationBar, aButton) {}
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   780
      }
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   781
    ];
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   782
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   783
    // Set pref to indicate we've shown the notification.
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   784
    prefs.setBoolPref(kTelemetryPrompted, true);
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   785
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   786
    var notification = notifyBox.appendNotification(telemetryText, "telemetry", null, notifyBox.PRIORITY_INFO_LOW, buttons);
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   787
    notification.persistence = 3; // arbitrary number, just so bar sticks around for a bit
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   788
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   789
    let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   790
    let link = notification.ownerDocument.createElementNS(XULNS, "label");
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   791
    link.className = "text-link telemetry-text-link";
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   792
    link.setAttribute("value", telemetryBundle.get("telemetryLinkLabel"));
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   793
    link.addEventListener('click', function() {
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   794
      openPrivacyPolicy('tab');
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   795
      // Remove the notification on which the user clicked
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   796
      notification.parentNode.removeNotification(notification, true);
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   797
      // Add a new notification to that tab, with no "Learn more" link
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   798
      notifyBox.appendNotification(telemetryText, "telemetry", null, notifyBox.PRIORITY_INFO_LOW, buttons);
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   799
    }, false);
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   800
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   801
    let description = notification.ownerDocument.getAnonymousElementByAttribute(notification, "anonid", "messageText");
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   802
    description.appendChild(link);
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   803
  },
5a4025abde431ca0bf401f979ab6c0de5017e72a Bug 682176 - Port Bug 652657 - Provide opt-in UI for Telemetry r=bwinton
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7789
diff changeset
   804
  /**
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   805
   * Looks at the existing prefs and determines if we should show about:rights
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   806
   * or not.
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   807
   *
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   808
   * This is controlled by two prefs:
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   809
   *
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   810
   *   mail.rights.override
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   811
   *     If this pref is set to false, always show the about:rights
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   812
   *     notification.
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   813
   *     If this pref is set to true, never show the about:rights notification.
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   814
   *     If the pref doesn't exist, then we fallback to checking
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   815
   *     mail.rights.version.
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   816
   *
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   817
   *   mail.rights.version
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   818
   *     If this pref isn't set or the value is less than the current version
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   819
   *     then we show the about:rights notification.
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   820
   */
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   821
  shouldShowAboutRightsNotification: function(prefs) {
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   822
    try {
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   823
      return !prefs.getBoolPref("mail.rights.override");
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   824
    } catch (e) { }
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   825
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   826
    return prefs.getIntPref("mail.rights.version") < this._kAboutRightsVersion;
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   827
  },
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   828
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   829
  showAboutRightsNotification: function(prefs) {
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   830
    var notifyBox = document.getElementById("mail-notification-box");
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   831
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   832
    var stringBundle =
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   833
      Components.classes["@mozilla.org/intl/stringbundle;1"]
3396
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
   834
                .getService(Components.interfaces.nsIStringBundleService);
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   835
    var brandBundle =
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   836
      stringBundle.createBundle("chrome://branding/locale/brand.properties");
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   837
    var rightsBundle =
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   838
      stringBundle.createBundle("chrome://messenger/locale/aboutRights.properties");
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   839
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   840
    var productName = brandBundle.GetStringFromName("brandFullName");
2085
a8d8b1d963710b5f62dc6ef73e9477700d147bf9 Bug 480127 about:rights info bar should use "open source software" not "open software". r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 1898
diff changeset
   841
    var notifyRightsText = rightsBundle.formatStringFromName("notifyRightsText",
a8d8b1d963710b5f62dc6ef73e9477700d147bf9 Bug 480127 about:rights info bar should use "open source software" not "open software". r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 1898
diff changeset
   842
                                                             [productName], 1);
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   843
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   844
    var buttons = [
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   845
      {
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   846
        label: rightsBundle.GetStringFromName("buttonLabel"),
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   847
        accessKey: rightsBundle.GetStringFromName("buttonAccessKey"),
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   848
        popup: null,
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   849
        callback: function(aNotificationBar, aButton) {
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   850
          // Show the about:rights tab
2979
5df43fdb39bbea29ffb2f588368b828e6e7ead6d Bug 501225 What's New and about:rights pages broken post tab mail landing. r=bienvenu
Mark Banner <bugzilla@standard8.plus.com>
parents: 2958
diff changeset
   851
          document.getElementById('tabmail')
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   852
                  .openTab("contentTab", { contentPage: "about:rights",
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   853
                                           clickHandler: "specialTabs.aboutClickHandler(event);" });
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   854
        }
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   855
      }
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   856
    ];
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   857
2085
a8d8b1d963710b5f62dc6ef73e9477700d147bf9 Bug 480127 about:rights info bar should use "open source software" not "open software". r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 1898
diff changeset
   858
    var box = notifyBox.appendNotification(notifyRightsText, "about-rights",
a8d8b1d963710b5f62dc6ef73e9477700d147bf9 Bug 480127 about:rights info bar should use "open source software" not "open software". r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 1898
diff changeset
   859
                                           null, notifyBox.PRIORITY_INFO_LOW,
a8d8b1d963710b5f62dc6ef73e9477700d147bf9 Bug 480127 about:rights info bar should use "open source software" not "open software". r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 1898
diff changeset
   860
                                           buttons);
1898
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   861
    // arbitrary number, just so bar sticks around for a bit
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   862
    box.persistence = 3;
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   863
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   864
    // Set the pref to say we've displayed the notification.
e7d4e8d57e637b550ccc5ee9692443bfc063be45 Bug 463367 Remove EULA from Thunderbird - Add notification bar and about:rights tab. r=philor,ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 1890
diff changeset
   865
    prefs.setIntPref("mail.rights.version", this._kAboutRightsVersion);
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   866
  },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   867
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   868
  /**
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   869
   * Handles links when displaying about: pages. Anything that is an about:
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   870
   * link can be loaded internally, other links are redirected to an external
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   871
   * browser.
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   872
   */
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   873
  aboutClickHandler: function aboutClickHandler(aEvent) {
4372
5af89e67d1f4a0913700562d8b8f09165eef6b45 Bug 527922 Right-clicking in a content tab on a link opens the link in a browser. r=philringnalda
Mark Banner <bugzilla@standard8.plus.com>
parents: 4351
diff changeset
   874
    // Don't handle events that: a) aren't trusted, b) have already been
5af89e67d1f4a0913700562d8b8f09165eef6b45 Bug 527922 Right-clicking in a content tab on a link opens the link in a browser. r=philringnalda
Mark Banner <bugzilla@standard8.plus.com>
parents: 4351
diff changeset
   875
    // handled or c) aren't left-click.
9373
a489b0bb0a7f639408b7e00f76a5150acdf00c47 Bug 708702 - Use defaultPrevented instead of the deprecated getPreventDefault() in front-end code. r=Standard8
Nguyen Ngoc Trung <trunga0@gmail.com>
parents: 9028
diff changeset
   876
    if (!aEvent.isTrusted || aEvent.defaultPrevented || aEvent.button)
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   877
      return true;
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   878
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   879
    let href = hRefForClickEvent(aEvent, true);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   880
    if (href) {
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   881
      let uri = makeURI(href);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   882
      if (!this._protocolSvc.isExposedProtocol(uri.scheme) ||
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   883
          uri.schemeIs("http") || uri.schemeIs("https")) {
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   884
        aEvent.preventDefault();
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   885
        openLinkExternally(href);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   886
      }
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   887
    }
10009
076c3f2bbb9becaf35f3dcff3ae33f8939af87c6 Bug 747800 - Fix code causing |Warning: function xyz does not always return a value|; r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 9373
diff changeset
   888
    return false;
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   889
  },
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   890
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   891
  /**
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   892
   * The default click handler for content tabs. Any clicks on links will get
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   893
   * redirected to an external browser - effectively keeping the user on one
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   894
   * page.
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   895
   */
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   896
  defaultClickHandler: function defaultClickHandler(aEvent) {
4372
5af89e67d1f4a0913700562d8b8f09165eef6b45 Bug 527922 Right-clicking in a content tab on a link opens the link in a browser. r=philringnalda
Mark Banner <bugzilla@standard8.plus.com>
parents: 4351
diff changeset
   897
    // Don't handle events that: a) aren't trusted, b) have already been
5af89e67d1f4a0913700562d8b8f09165eef6b45 Bug 527922 Right-clicking in a content tab on a link opens the link in a browser. r=philringnalda
Mark Banner <bugzilla@standard8.plus.com>
parents: 4351
diff changeset
   898
    // handled or c) aren't left-click.
9373
a489b0bb0a7f639408b7e00f76a5150acdf00c47 Bug 708702 - Use defaultPrevented instead of the deprecated getPreventDefault() in front-end code. r=Standard8
Nguyen Ngoc Trung <trunga0@gmail.com>
parents: 9028
diff changeset
   899
    if (!aEvent.isTrusted || aEvent.defaultPrevented || aEvent.button)
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   900
      return true;
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   901
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   902
    let href = hRefForClickEvent(aEvent, true);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   903
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   904
    // We've explicitly allowed http, https and about as additional exposed
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   905
    // protocols in our default prefs, so these are the ones we need to check
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   906
    // for here.
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   907
    if (href) {
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   908
      let uri = makeURI(href);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   909
      if (!this._protocolSvc.isExposedProtocol(uri.scheme) ||
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   910
          uri.schemeIs("http") || uri.schemeIs("https") ||
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   911
          uri.schemeIs("about")) {
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   912
        aEvent.preventDefault();
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   913
        openLinkExternally(href);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   914
      }
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   915
    }
10009
076c3f2bbb9becaf35f3dcff3ae33f8939af87c6 Bug 747800 - Fix code causing |Warning: function xyz does not always return a value|; r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 9373
diff changeset
   916
    return false;
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   917
  },
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   918
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   919
  /**
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   920
   * A site click handler for extensions to use. This does its best to limit
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   921
   * loading of links that match the regexp to within the content tab it applies
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   922
   * to within Thunderbird. Links that do not match the regexp will be loaded
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   923
   * in the external browser.
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   924
   *
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   925
   * Note: Due to the limitations of http and the possibility for redirects, if
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   926
   * sites change or use javascript, this function may not be able to ensure the
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   927
   * contentTab stays "within" a site. Extensions using this function should
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   928
   * consider this when implementing the extension.
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   929
   *
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   930
   * @param aEvent      The onclick event that is being handled.
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   931
   * @param aSiteRegexp A regexp to match against to determine if the link
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   932
   *                    clicked on should be loaded within the browser or not.
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   933
   */
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   934
  siteClickHandler: function siteClickHandler(aEvent, aSiteRegexp) {
4372
5af89e67d1f4a0913700562d8b8f09165eef6b45 Bug 527922 Right-clicking in a content tab on a link opens the link in a browser. r=philringnalda
Mark Banner <bugzilla@standard8.plus.com>
parents: 4351
diff changeset
   935
    // Don't handle events that: a) aren't trusted, b) have already been
5af89e67d1f4a0913700562d8b8f09165eef6b45 Bug 527922 Right-clicking in a content tab on a link opens the link in a browser. r=philringnalda
Mark Banner <bugzilla@standard8.plus.com>
parents: 4351
diff changeset
   936
    // handled or c) aren't left-click.
9373
a489b0bb0a7f639408b7e00f76a5150acdf00c47 Bug 708702 - Use defaultPrevented instead of the deprecated getPreventDefault() in front-end code. r=Standard8
Nguyen Ngoc Trung <trunga0@gmail.com>
parents: 9028
diff changeset
   937
    if (!aEvent.isTrusted || aEvent.defaultPrevented || aEvent.button)
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   938
      return true;
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   939
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   940
    let href = hRefForClickEvent(aEvent, true);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   941
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   942
    // We've explicitly allowed http, https and about as additional exposed
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   943
    // protocols in our default prefs, so these are the ones we need to check
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   944
    // for here.
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   945
    if (href) {
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   946
      let uri = makeURI(href);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   947
      if (!this._protocolSvc.isExposedProtocol(uri.scheme) ||
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   948
          ((uri.schemeIs("http") || uri.schemeIs("https") ||
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   949
            uri.schemeIs("about")) && !aSiteRegexp.test(uri.spec))) {
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   950
        aEvent.preventDefault();
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   951
        openLinkExternally(href);
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   952
      }
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   953
    }
10009
076c3f2bbb9becaf35f3dcff3ae33f8939af87c6 Bug 747800 - Fix code causing |Warning: function xyz does not always return a value|; r=standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 9373
diff changeset
   954
    return false;
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   955
  },
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
   956
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   957
  chromeTabType: {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   958
    name: "chromeTab",
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   959
    perTabPanel: "vbox",
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   960
    lastBrowserId: 0,
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   961
    get loadingTabString() {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   962
      delete this.loadingTabString;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   963
      return this.loadingTabString = document.getElementById("bundle_messenger")
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   964
                                             .getString("loadingTab");
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   965
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   966
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   967
    modes: {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   968
      chromeTab: {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   969
        type: "chromeTab",
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   970
        maxTabs: 10
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   971
      }
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   972
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   973
8833
b09edfb0a96b894050e608bb2be7e2e971b2d659 Bug 700993 - Chrome tabs broken after landing of bug 677421 r=squib
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 8817
diff changeset
   974
    shouldSwitchTo: function ({ chromePage: x })
b09edfb0a96b894050e608bb2be7e2e971b2d659 Bug 700993 - Chrome tabs broken after landing of bug 677421 r=squib
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 8817
diff changeset
   975
      contentTabBaseType.shouldSwitchTo({ contentPage: x }),
8812
d29730042bdf4fe317d6ec9562527d1f44b95630 Bug 677421 - Add support for OpenSearch from Thunderbird. Part 1 - refactor contentTab interfaces so that they can be reused a bit more. r=Standard8
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 8808
diff changeset
   976
7324
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   977
    /**
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   978
     * This is the internal function used by chrome tabs to open a new tab. To
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   979
     * open a chromeTab, use specialTabs.openTab("chromeTab", aArgs)
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   980
     *
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   981
     * @param aArgs The options that chrome tabs accept.
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   982
     * @param aArgs.chromePage A string that holds the URL that is to be opened
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   983
     * @param aArgs.clickHandler The click handler for that chrome tab. See the
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   984
     *  "Content Tabs" article on MDC.
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   985
     * @param aArgs.onLoad A function that takes an Event and a DOMNode. It is
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   986
     *  called when the chrome page is done loading. The first argument is the
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   987
     *  load event, and the second argument is the xul:browser that holds the
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   988
     *  chromePage. You can access the inner tab's window object by accessing
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   989
     *  the second parameter's chromeWindow property.
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   990
     */
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
   991
    openTab: function chromeTab_onTabOpened(aTab, aArgs) {
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   992
      if (!"chromePage" in aArgs)
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   993
        throw("chromePage must be specified");
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   994
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   995
      // First clone the page and set up the basics.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   996
      let clone = document.getElementById("chromeTab").firstChild.cloneNode(true);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   997
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   998
      clone.setAttribute("id", "chromeTab" + this.lastBrowserId);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
   999
      clone.setAttribute("collapsed", false);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1000
10589
6446a293fb93cdebe043d27c09e87f41c336da5b Bug 770133 - Fix duplicated IDs. r=mconley
teramako <teramako@gmail.com>
parents: 10562
diff changeset
  1001
      let toolbox = clone.firstChild;
6446a293fb93cdebe043d27c09e87f41c336da5b Bug 770133 - Fix duplicated IDs. r=mconley
teramako <teramako@gmail.com>
parents: 10562
diff changeset
  1002
      toolbox.setAttribute("id", "chromeTabToolbox" + this.lastBrowserId);
6446a293fb93cdebe043d27c09e87f41c336da5b Bug 770133 - Fix duplicated IDs. r=mconley
teramako <teramako@gmail.com>
parents: 10562
diff changeset
  1003
      toolbox.firstChild.setAttribute("id", "chromeTabToolbar" + this.lastBrowserId);
6446a293fb93cdebe043d27c09e87f41c336da5b Bug 770133 - Fix duplicated IDs. r=mconley
teramako <teramako@gmail.com>
parents: 10562
diff changeset
  1004
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1005
      aTab.panel.appendChild(clone);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1006
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1007
      // Start setting up the browser.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1008
      aTab.browser = aTab.panel.getElementsByTagName("browser")[0];
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1009
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1010
      // As we're opening this tab, showTab may not get called, so set
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1011
      // the type according to if we're opening in background or not.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1012
      let background = ("background" in aArgs) && aArgs.background;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1013
      // XXX not setting type as it's chrome
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1014
      //aTab.browser.setAttribute("type", background ? "content-targetable" :
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1015
      //                                               "content-primary");
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1016
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1017
      aTab.browser.setAttribute("onclick",
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1018
                                "clickHandler" in aArgs && aArgs.clickHandler ?
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1019
                                aArgs.clickHandler :
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1020
                                "specialTabs.defaultClickHandler(event);");
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1021
7500
7fd054a760dd9a962e3ae47a603a371c867dff42 Bug 645509: Chrome tabs should be allowed to have favicons too r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7447
diff changeset
  1022
      // Set this attribute so that when favicons fail to load, we remove the
7fd054a760dd9a962e3ae47a603a371c867dff42 Bug 645509: Chrome tabs should be allowed to have favicons too r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7447
diff changeset
  1023
      // image attribute and just show the default tab icon.
7fd054a760dd9a962e3ae47a603a371c867dff42 Bug 645509: Chrome tabs should be allowed to have favicons too r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7447
diff changeset
  1024
      aTab.tabNode.setAttribute("onerror", "this.removeAttribute('image');");
7fd054a760dd9a962e3ae47a603a371c867dff42 Bug 645509: Chrome tabs should be allowed to have favicons too r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7447
diff changeset
  1025
7fd054a760dd9a962e3ae47a603a371c867dff42 Bug 645509: Chrome tabs should be allowed to have favicons too r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7447
diff changeset
  1026
      aTab.browser.addEventListener("DOMLinkAdded", DOMLinkHandler, false);
7fd054a760dd9a962e3ae47a603a371c867dff42 Bug 645509: Chrome tabs should be allowed to have favicons too r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7447
diff changeset
  1027
7fd054a760dd9a962e3ae47a603a371c867dff42 Bug 645509: Chrome tabs should be allowed to have favicons too r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7447
diff changeset
  1028
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1029
      aTab.browser.setAttribute("id", "chromeTabBrowser" + this.lastBrowserId);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1030
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1031
      // Now set up the listeners.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1032
      this._setUpTitleListener(aTab);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1033
      this._setUpCloseWindowListener(aTab);
7324
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
  1034
      if ("onLoad" in aArgs) {
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
  1035
        aTab.browser.addEventListener("load", function _chromeTab_onLoad (event) {
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
  1036
          aArgs.onLoad(event, aTab.browser);
8817
0eb34d6ba3f391f040d321281504326a871b8414 Bug 686347 - Add Account Provisioner service for email to Thunderbird. r=Standard8.
Blake Winton <bwinton@mozilla.com>
parents: 8812
diff changeset
  1037
          aTab.browser.removeEventListener("load", _chromeTab_onLoad, true);
7324
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
  1038
        }, true);
99b7adef97b71fc9f97eced939a49fcef0630dd4 Bug 638801 - Add an extra onLoad argument to contentTab and chromeTab arguments
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7067
diff changeset
  1039
      }
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1040
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1041
      // Now start loading the content.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1042
      aTab.title = this.loadingTabString;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1043
      aTab.browser.loadURI(aArgs.chromePage);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1044
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1045
      this.lastBrowserId++;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1046
    },
7638
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
  1047
    tryCloseTab: function onTryCloseTab(aTab) {
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
  1048
      let docShell = aTab.browser.docShell;
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
  1049
      // If we have a docshell, a contentViewer, and it forbids us from closing
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
  1050
      // the tab, then we return false, which means, we can't close the tab. All
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
  1051
      // other cases return true.
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
  1052
      return !(docShell && docShell.contentViewer
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
  1053
        && !docShell.contentViewer.permitUnload());
95f70d4b2a83dd3c9dcab3e3f935da2f88ba7dd5 Bug 645552: Thunderbird's tabmail does not honor onbeforeunload event handlers r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7500
diff changeset
  1054
    },
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1055
    closeTab: function onTabClosed(aTab) {
9028
3f507b7d7ee675b220490292a88d8d291bcb2ed4 Bug 644169 - Implement Tabs on Top for Thunderbird. ui-r=bwinton,r=sid0,sr=Standard8.
Mike Conley <mconley@mozilla.com>
parents: 8849
diff changeset
  1056
      aTab.browser.removeEventListener("load", aTab.loadListener, true);
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1057
      aTab.browser.removeEventListener("DOMTitleChanged",
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1058
                                       aTab.titleListener, true);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1059
      aTab.browser.removeEventListener("DOMWindowClose",
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1060
                                       aTab.closeListener, true);
7500
7fd054a760dd9a962e3ae47a603a371c867dff42 Bug 645509: Chrome tabs should be allowed to have favicons too r=standard8
Jonathan Protzenko <jonathan.protzenko@gmail.com>
parents: 7447
diff changeset
  1061
      aTab.browser.removeEventListener("DOMLinkAdded", DOMLinkHandler, false);
5392
436e299ed6a92aa90ad0f68d2e10ab91097ace1b Bug 557477 Content/Chrome tabs leak javascript objects/functions. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 5005
diff changeset
  1062
      aTab.browser.destroy();
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1063
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1064
    saveTabState: function onSaveTabState(aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1065
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1066
    showTab: function onShowTab(aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1067
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1068
    persistTab: function onPersistTab(aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1069
      if (aTab.browser.currentURI.spec == "about:blank")
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1070
        return null;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1071
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1072
      let onClick = aTab.browser.getAttribute("onclick");
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1073
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1074
      return {
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1075
        tabURI: aTab.browser.currentURI.spec,
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1076
        clickHandler: onClick ? onClick : null
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1077
      };
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1078
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1079
    restoreTab: function onRestoreTab(aTabmail, aPersistedState) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1080
      aTabmail.openTab("chromeTab", { chromePage: aPersistedState.tabURI,
4351
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1081
                                      clickHandler: aPersistedState.clickHandler,
2d246c8d3fa4762871d6b42d37f169af17b21892 Bug 516776 Make it possible for browser elements to navigate through links/pages. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents: 4286
diff changeset
  1082
                                      background: true } );
3963
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1083
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1084
    onTitleChanged: function onTitleChanged(aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1085
      aTab.title = aTab.browser.contentDocument.title;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1086
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1087
    supportsCommand: function supportsCommand(aCommand, aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1088
      switch (aCommand) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1089
        case "cmd_fullZoomReduce":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1090
        case "cmd_fullZoomEnlarge":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1091
        case "cmd_fullZoomReset":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1092
        case "cmd_fullZoomToggle":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1093
        case "cmd_printSetup":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1094
        case "cmd_print":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1095
        case "button_print":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1096
        // XXX print preview not currently supported - bug 497994 to implement.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1097
        // case "cmd_printpreview":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1098
          return true;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1099
        default:
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1100
          return false;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1101
      }
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1102
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1103
    isCommandEnabled: function isCommandEnabled(aCommand, aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1104
      switch (aCommand) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1105
        case "cmd_fullZoomReduce":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1106
        case "cmd_fullZoomEnlarge":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1107
        case "cmd_fullZoomReset":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1108
        case "cmd_fullZoomToggle":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1109
        case "cmd_printSetup":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1110
        case "cmd_print":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1111
        case "button_print":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1112
        // XXX print preview not currently supported - bug 497994 to implement.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1113
        // case "cmd_printpreview":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1114
          return true;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1115
        default:
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1116
          return false;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1117
      }
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1118
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1119
    doCommand: function isCommandEnabled(aCommand, aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1120
      switch (aCommand) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1121
        case "cmd_fullZoomReduce":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1122
          ZoomManager.reduce();
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1123
          break;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1124
        case "cmd_fullZoomEnlarge":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1125
          ZoomManager.enlarge();
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1126
          break;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1127
        case "cmd_fullZoomReset":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1128
          ZoomManager.reset();
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1129
          break;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1130
        case "cmd_fullZoomToggle":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1131
          ZoomManager.toggleZoom();
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1132
          break;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1133
        case "cmd_printSetup":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1134
          PrintUtils.showPageSetup();
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1135
          break;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1136
        case "cmd_print":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1137
          PrintUtils.print();
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1138
          break;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1139
        // XXX print preview not currently supported - bug 497994 to implement.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1140
        //case "cmd_printpreview":
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1141
        //  PrintUtils.printPreview();
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1142
        //  break;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1143
      }
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1144
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1145
    getBrowser: function getBrowser(aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1146
      return aTab.browser;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1147
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1148
    // Internal function used to set up the title listener on a content tab.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1149
    _setUpTitleListener: function setUpTitleListener(aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1150
      function onDOMTitleChanged(aEvent) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1151
        document.getElementById("tabmail").setTabTitle(aTab);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1152
      }
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1153
      // Save the function we'll use as listener so we can remove it later.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1154
      aTab.titleListener = onDOMTitleChanged;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1155
      // Add the listener.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1156
      aTab.browser.addEventListener("DOMTitleChanged",
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1157
                                    aTab.titleListener, true);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1158
    },
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1159
    /**
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1160
     * Internal function used to set up the close window listener on a content
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1161
     * tab.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1162
     */
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1163
    _setUpCloseWindowListener: function setUpCloseWindowListener(aTab) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1164
      function onDOMWindowClose(aEvent) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1165
      try {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1166
        if (!aEvent.isTrusted)
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1167
          return;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1168
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1169
        // Redirect any window.close events to closing the tab. As a 3-pane tab
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1170
        // must be open, we don't need to worry about being the last tab open.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1171
        document.getElementById("tabmail").closeTab(aTab);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1172
        aEvent.preventDefault();
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1173
      } catch (e) {
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1174
        logException(e);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1175
      }
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1176
      }
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1177
      // Save the function we'll use as listener so we can remove it later.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1178
      aTab.closeListener = onDOMWindowClose;
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1179
      // Add the listener.
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1180
      aTab.browser.addEventListener("DOMWindowClose",
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1181
                                    aTab.closeListener, true);
13a8ea0d02a9dc65bcb415ef3109d0521b6e2770 Bug 516884 - High-level UI to control major feature changes between TB2 and TB3, r=philor,r=Standard8,ui-r=clarkbw,a=blocking-tb3
David Ascher <david.ascher@gmail.com>
parents: 3959
diff changeset
  1182
    }
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1183
  },
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1184
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1185
  observe: function (aSubject, aTopic, aData) {
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1186
    if (aTopic != "mail-startup-done")
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1187
      return;
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1188
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1189
    Services.obs.removeObserver(specialTabs, "mail-startup-done");
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1190
    Services.obs.addObserver(this.xpInstallObserver, "addon-install-disabled",
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1191
                             false);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1192
    Services.obs.addObserver(this.xpInstallObserver, "addon-install-blocked",
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1193
                             false);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1194
    Services.obs.addObserver(this.xpInstallObserver, "addon-install-failed",
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1195
                             false);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1196
    Services.obs.addObserver(this.xpInstallObserver, "addon-install-complete",
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1197
                             false);
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1198
  },
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1199
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1200
  onunload: function () {
5392
436e299ed6a92aa90ad0f68d2e10ab91097ace1b Bug 557477 Content/Chrome tabs leak javascript objects/functions. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 5005
diff changeset
  1201
    window.removeEventListener("unload", specialTabs.onunload, false);
436e299ed6a92aa90ad0f68d2e10ab91097ace1b Bug 557477 Content/Chrome tabs leak javascript objects/functions. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 5005
diff changeset
  1202
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1203
    Services.obs.removeObserver(specialTabs.xpInstallObserver,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1204
                                "addon-install-disabled");
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1205
    Services.obs.removeObserver(specialTabs.xpInstallObserver,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1206
                                "addon-install-blocked");
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1207
    Services.obs.removeObserver(specialTabs.xpInstallObserver,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1208
                                "addon-install-failed");
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1209
    Services.obs.removeObserver(specialTabs.xpInstallObserver,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1210
                                "addon-install-complete");
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1211
  },
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1212
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1213
  xpInstallObserver: {
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1214
    observe: function (aSubject, aTopic, aData) {
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1215
      const Ci = Components.interfaces;
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1216
      let brandBundle = document.getElementById("bundle_brand");
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1217
      let messengerBundle = document.getElementById("bundle_messenger");
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1218
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1219
      let installInfo = aSubject.QueryInterface(Ci.amIWebInstallInfo);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1220
      let win = installInfo.originatingWindow;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1221
      let notificationBox = getNotificationBox(win.top);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1222
      let notificationID = aTopic;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1223
      let brandShortName = brandBundle.getString("brandShortName");
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1224
      let notificationName, messageString, buttons;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1225
      const iconURL = "chrome://messenger/skin/icons/update.png";
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1226
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1227
      switch (aTopic) {
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1228
      case "addon-install-disabled":
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1229
        notificationID = "xpinstall-disabled";
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1230
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1231
        if (Services.prefs.prefIsLocked("xpinstall.enabled")) {
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1232
          messageString = messengerBundle.getString("xpinstallDisabledMessageLocked");
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1233
          buttons = [];
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1234
        }
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1235
        else {
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1236
          messageString = messengerBundle.getString("xpinstallDisabledMessage");
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1237
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1238
          buttons = [{
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1239
            label: messengerBundle.getString("xpinstallDisabledButton"),
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1240
            accessKey: messengerBundle.getString("xpinstallDisabledButton.accesskey"),
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1241
            popup: null,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1242
            callback: function editPrefs() {
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1243
              Services.prefs.setBoolPref("xpinstall.enabled", true);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1244
              return false;
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1245
            }
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1246
          }];
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1247
        }
7447
44cd5f668b253535aa0447d2e59fc37c79be3603 Bug 623151 - Migration assistant installation of add-ons no longer works on trunk builds; r=Standard8 ui-r=clarkbw
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7324
diff changeset
  1248
        if (notificationBox && !notificationBox.getNotificationWithValue(notificationID)) {
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1249
          notificationBox.appendNotification(messageString, notificationID,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1250
                                             iconURL,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1251
                                             notificationBox.PRIORITY_CRITICAL_HIGH,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1252
                                             buttons);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1253
        }
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1254
        break;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1255
      case "addon-install-blocked":
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1256
        messageString =
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1257
          messengerBundle.getFormattedString("xpinstallPromptWarning",
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1258
                                             [brandShortName, installInfo.originatingURI.host]);
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1259
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1260
        buttons = [{
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1261
          label: messengerBundle.getString("xpinstallPromptAllowButton"),
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1262
          accessKey: messengerBundle.getString("xpinstallPromptAllowButton.accesskey"),
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1263
          popup: null,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1264
          callback: function() {
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1265
            installInfo.install();
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1266
          }
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1267
        }];
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1268
7447
44cd5f668b253535aa0447d2e59fc37c79be3603 Bug 623151 - Migration assistant installation of add-ons no longer works on trunk builds; r=Standard8 ui-r=clarkbw
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7324
diff changeset
  1269
        if (notificationBox && !notificationBox.getNotificationWithValue(notificationName)) {
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1270
            notificationBox.appendNotification(messageString, notificationName,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1271
                                               iconURL,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1272
                                               notificationBox.PRIORITY_MEDIUM_HIGH,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1273
                                               buttons);
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1274
          }
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1275
        break;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1276
      case "addon-install-failed":
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1277
        // XXX TODO This isn't terribly ideal for the multiple failure case
6991
88032a4ef8386b9b5df07832307144918d8b4796 Followup fix to bug 571759: make sure we don't create any globals, and iterate over the right thing. r=Standard8 over IRC.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6957
diff changeset
  1278
        for (let [, install] in Iterator(installInfo.installs)) {
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1279
          let host = (installInfo.originatingURI instanceof Ci.nsIStandardURL) &&
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1280
                      installInfo.originatingURI.host;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1281
          if (!host)
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1282
            host = (install.sourceURI instanceof Ci.nsIStandardURL) &&
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1283
                    install.sourceURI.host;
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1284
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1285
          let error = (host || install.error == 0) ?
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1286
                       "addonError" : "addonLocalError";
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1287
          if (install.error != 0)
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1288
            error += install.error;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1289
          else if (install.addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED)
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1290
            error += "Blocklisted";
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1291
          else
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1292
            error += "Incompatible";
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1293
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1294
          messageString = messengerBundle.getString(error);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1295
          messageString = messageString.replace("#1", install.name);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1296
          if (host)
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1297
            messageString = messageString.replace("#2", host);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1298
          messageString = messageString.replace("#3", brandShortName);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1299
          messageString = messageString.replace("#4", Services.appinfo.version);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1300
7447
44cd5f668b253535aa0447d2e59fc37c79be3603 Bug 623151 - Migration assistant installation of add-ons no longer works on trunk builds; r=Standard8 ui-r=clarkbw
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7324
diff changeset
  1301
          if (notificationBox && !notificationBox.getNotificationWithValue(notificationID)) {
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1302
            notificationBox.appendNotification(messageString,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1303
                                               notificationID,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1304
                                               iconURL,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1305
                                               notificationBox.PRIORITY_CRITICAL_HIGH,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1306
                                               []);
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1307
          }
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1308
        }
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1309
        break;
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1310
      case "addon-install-complete":
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1311
        let needsRestart = installInfo.installs.some(function(i) {
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1312
            return i.addon.pendingOperations != AddonManager.PENDING_NONE;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1313
        });
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1314
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1315
        if (needsRestart) {
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1316
          messageString = messengerBundle.getString("addonsInstalledNeedsRestart");
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1317
          buttons = [{
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1318
            label: messengerBundle.getString("addonInstallRestartButton"),
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1319
            accessKey: messengerBundle.getString("addonInstallRestartButton.accesskey"),
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1320
            popup: null,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1321
            callback: function() {
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1322
              Application.restart();
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1323
            }
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1324
          }];
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1325
        }
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1326
        else {
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1327
          messageString = messengerBundle.getString("addonsInstalled");
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1328
          buttons = [{
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1329
            label: messengerBundle.getString("addonInstallManage"),
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1330
            accessKey: messengerBundle.getString("addonInstallManage.accesskey"),
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1331
            popup: null,
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1332
            callback: function() {
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1333
              // Calculate the add-on type that is most popular in the list of
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1334
              // installs.
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1335
              let types = {};
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1336
              let bestType = null;
6991
88032a4ef8386b9b5df07832307144918d8b4796 Followup fix to bug 571759: make sure we don't create any globals, and iterate over the right thing. r=Standard8 over IRC.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 6957
diff changeset
  1337
              for (let [, install] in Iterator(installInfo.installs)) {
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1338
                if (install.type in types)
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1339
                  types[install.type]++;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1340
                else
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1341
                  types[install.type] = 1;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1342
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1343
                if (!bestType || types[install.type] > types[bestType])
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1344
                  bestType = install.type;
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1345
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1346
                openAddonsMgr("addons://list/" + bestType);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1347
              }
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1348
            }
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1349
          }];
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1350
        }
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1351
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1352
        messageString = PluralForm.get(installInfo.installs.length, messageString);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1353
        messageString = messageString.replace("#1", installInfo.installs[0].name);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1354
        messageString = messageString.replace("#2", installInfo.installs.length);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1355
        messageString = messageString.replace("#3", brandShortName);
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1356
7447
44cd5f668b253535aa0447d2e59fc37c79be3603 Bug 623151 - Migration assistant installation of add-ons no longer works on trunk builds; r=Standard8 ui-r=clarkbw
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7324
diff changeset
  1357
        if (notificationBox)
44cd5f668b253535aa0447d2e59fc37c79be3603 Bug 623151 - Migration assistant installation of add-ons no longer works on trunk builds; r=Standard8 ui-r=clarkbw
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7324
diff changeset
  1358
          notificationBox.appendNotification(messageString,
44cd5f668b253535aa0447d2e59fc37c79be3603 Bug 623151 - Migration assistant installation of add-ons no longer works on trunk builds; r=Standard8 ui-r=clarkbw
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7324
diff changeset
  1359
                                             notificationID,
44cd5f668b253535aa0447d2e59fc37c79be3603 Bug 623151 - Migration assistant installation of add-ons no longer works on trunk builds; r=Standard8 ui-r=clarkbw
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7324
diff changeset
  1360
                                             iconURL,
44cd5f668b253535aa0447d2e59fc37c79be3603 Bug 623151 - Migration assistant installation of add-ons no longer works on trunk builds; r=Standard8 ui-r=clarkbw
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7324
diff changeset
  1361
                                             notificationBox.PRIORITY_INFO_MEDIUM,
44cd5f668b253535aa0447d2e59fc37c79be3603 Bug 623151 - Migration assistant installation of add-ons no longer works on trunk builds; r=Standard8 ui-r=clarkbw
Jim Porter <squibblyflabbetydoo@gmail.com>
parents: 7324
diff changeset
  1362
                                             buttons);
6957
ebb269ce8610a07f183f7f9cc30449fe486a695a Part of bug 571759 - Implement notifications for the revised add-on manager. r=sid0 ui-review=clarkbw
Mark Banner <bugzilla@standard8.plus.com>
parents: 6919
diff changeset
  1363
        break;
5005
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1364
      }
80e33dcf91ed10098a2a1576abf7524954d66b57 Bug 526733 - "Can't install application/x-xpinstall types by clicking on links in content tabs". some minor test fixes by asuth. r=asuth, ui-r=clarkbw.
Mark Banner <mark@standard8.plus.com>
parents: 4983
diff changeset
  1365
    }
7067
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1366
  },
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1367
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1368
  /**
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1369
   * Determine if we should load fav icons or not.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1370
   *
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1371
   * @param aURI  An nsIURI containing the current url.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1372
   */
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1373
  _shouldLoadFavIcon: function shouldLoadFavIcon(aURI) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1374
    return (aURI &&
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1375
            Application.prefs.getValue("browser.chrome.site_icons", false) &&
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1376
            Application.prefs.getValue("browser.chrome.favicons", false) &&
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1377
            ("schemeIs" in aURI) &&
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1378
            (aURI.schemeIs("http") || aURI.schemeIs("https")));
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1379
  },
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1380
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1381
  /**
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1382
   * Tries to use the default favicon for a webpage for the specified tab.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1383
   * If the web page is just an image, then we'll use the image itself it it
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1384
   * isn't too big.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1385
   * Otherwise we'll use the site's favicon.ico if prefs allow us to.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1386
   */
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1387
  useDefaultIcon: function useDefaultIcon(aTab) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1388
    let tabmail = document.getElementById('tabmail');
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1389
    var docURIObject = aTab.browser.contentDocument.documentURIObject;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1390
    var icon = null;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1391
    if (aTab.browser.contentDocument instanceof ImageDocument) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1392
      if (Services.prefs.getBoolPref("browser.chrome.site_icons")) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1393
        let sz = Services.prefs.getIntPref("browser.chrome.image_icons.max_size");
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1394
        try {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1395
          let req = aTab.browser.contentDocument.imageRequest;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1396
          if (req && req.image && req.image.width <= sz &&
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1397
              req.image.height <= sz)
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1398
            icon = aTab.browser.currentURI.spec;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1399
        }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1400
        catch (e) { }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1401
      }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1402
    }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1403
    // Use documentURIObject in the check for shouldLoadFavIcon so that we do
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1404
    // the right thing with about:-style error pages.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1405
    else if (this._shouldLoadFavIcon(docURIObject)) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1406
      let url = docURIObject.prePath + "/favicon.ico";
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1407
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1408
      if (!specialTabs.mFaviconService.isFailedFavicon(makeURI(url)))
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1409
        icon = url;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1410
    }
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1411
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1412
    specialTabs.setTabIcon(aTab, icon);
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1413
  },
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1414
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1415
  /**
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1416
   * This sets the specified tab to load and display the given icon for the
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1417
   * page shown in the browser. It is assumed that the preferences have already
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1418
   * been checked before calling this function apprioriately.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1419
   *
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1420
   * @param aTab  The tab to set the icon for.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1421
   * @param aIcon A string based URL of the icon to try and load.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1422
   */
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1423
  setTabIcon: function(aTab, aIcon) {
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1424
    if (aIcon && this.mFaviconService)
10365
f6e3760f12cc3b214c6c2c1b596380a9589683aa Bug 760971 - Port |Bug 728141 - Replace old synchronous favicons calls in browser| to Thunderbird r=mconley
Ian Neal <iann_cvs@blueyonder.co.uk>
parents: 10318
diff changeset
  1425
      this.mFaviconService.setAndFetchFaviconForPage(aTab.browser.currentURI,
f6e3760f12cc3b214c6c2c1b596380a9589683aa Bug 760971 - Port |Bug 728141 - Replace old synchronous favicons calls in browser| to Thunderbird r=mconley
Ian Neal <iann_cvs@blueyonder.co.uk>
parents: 10318
diff changeset
  1426
                                                     makeURI(aIcon), false);
7067
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1427
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1428
    // Save this off so we know about it later,
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1429
    aTab.browser.mIconURL = aIcon;
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1430
    // and display the new icon.
c51913c44f242036112df133b7d455172b2da9f0 Bug 516777 - Enable favicons on content tabs; r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 6991
diff changeset
  1431
    document.getElementById("tabmail").setTabIcon(aTab, aIcon);
1890
5ccc635e5a2a92ad310f07544cebf724be329088 Bug 477029 Move "special" tab definitions into their own file. r=philor
Mark Banner <bugzilla@standard8.plus.com>
parents:
diff changeset
  1432
  }
3396
06869471491937b11e5df33a59da9369350976c7 Bug 503299 window.close() from a content tab closes Thunderbird window. r=asuth
Mark Banner <bugzilla@standard8.plus.com>
parents: 3375
diff changeset
  1433
};