зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1379833) for android lint failures a=backout
Backed out changeset 8bbf531110dd (bug 1379833) Backed out changeset c06bc2f7acd3 (bug 1379833) MozReview-Commit-ID: 5iCJ3qsMC1Q
This commit is contained in:
Родитель
4d3b3a806c
Коммит
2ec453d1bb
|
@ -16,8 +16,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "AddonManagerPrivate",
|
|||
"resource://gre/modules/AddonManager.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "AppMenuNotifications",
|
||||
"resource://gre/modules/AppMenuNotifications.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionData",
|
||||
"resource://gre/modules/Extension.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
|
||||
"resource:///modules/RecentWindow.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
||||
|
@ -252,15 +252,127 @@ this.ExtensionsUI = {
|
|||
|
||||
// Create a set of formatted strings for a permission prompt
|
||||
_buildStrings(info) {
|
||||
let result = {};
|
||||
|
||||
let bundle = Services.strings.createBundle(BROWSER_PROPERTIES);
|
||||
|
||||
let brandBundle = Services.strings.createBundle(BRAND_PROPERTIES);
|
||||
let appName = brandBundle.GetStringFromName("brandShortName");
|
||||
let addonName = `<span class="addon-webext-name">${this._sanitizeName(info.addon.name)}</span>`;
|
||||
let perms = info.permissions || {origins: [], permissions: []};
|
||||
|
||||
let info2 = Object.assign({appName, addonName}, info);
|
||||
// First classify our host permissions
|
||||
let allUrls = false, wildcards = [], sites = [];
|
||||
for (let permission of perms.origins) {
|
||||
if (permission == "<all_urls>") {
|
||||
allUrls = true;
|
||||
break;
|
||||
}
|
||||
let match = /^[htps*]+:\/\/([^/]+)\//.exec(permission);
|
||||
if (!match) {
|
||||
Cu.reportError(`Unparseable host permission ${permission}`);
|
||||
continue;
|
||||
}
|
||||
if (match[1] == "*") {
|
||||
allUrls = true;
|
||||
} else if (match[1].startsWith("*.")) {
|
||||
wildcards.push(match[1].slice(2));
|
||||
} else {
|
||||
sites.push(match[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return ExtensionData.formatPermissionStrings(info2, bundle);
|
||||
// Format the host permissions. If we have a wildcard for all urls,
|
||||
// a single string will suffice. Otherwise, show domain wildcards
|
||||
// first, then individual host permissions.
|
||||
result.msgs = [];
|
||||
if (allUrls) {
|
||||
result.msgs.push(bundle.GetStringFromName("webextPerms.hostDescription.allUrls"));
|
||||
} else {
|
||||
// Formats a list of host permissions. If we have 4 or fewer, display
|
||||
// them all, otherwise display the first 3 followed by an item that
|
||||
// says "...plus N others"
|
||||
function format(list, itemKey, moreKey) {
|
||||
function formatItems(items) {
|
||||
result.msgs.push(...items.map(item => bundle.formatStringFromName(itemKey, [item], 1)));
|
||||
}
|
||||
if (list.length < 5) {
|
||||
formatItems(list);
|
||||
} else {
|
||||
formatItems(list.slice(0, 3));
|
||||
|
||||
let remaining = list.length - 3;
|
||||
result.msgs.push(PluralForm.get(remaining, bundle.GetStringFromName(moreKey))
|
||||
.replace("#1", remaining));
|
||||
}
|
||||
}
|
||||
|
||||
format(wildcards, "webextPerms.hostDescription.wildcard",
|
||||
"webextPerms.hostDescription.tooManyWildcards");
|
||||
format(sites, "webextPerms.hostDescription.oneSite",
|
||||
"webextPerms.hostDescription.tooManySites");
|
||||
}
|
||||
|
||||
let permissionKey = perm => `webextPerms.description.${perm}`;
|
||||
|
||||
// Next, show the native messaging permission if it is present.
|
||||
const NATIVE_MSG_PERM = "nativeMessaging";
|
||||
if (perms.permissions.includes(NATIVE_MSG_PERM)) {
|
||||
let brandBundle = Services.strings.createBundle(BRAND_PROPERTIES);
|
||||
let appName = brandBundle.GetStringFromName("brandShortName");
|
||||
result.msgs.push(bundle.formatStringFromName(permissionKey(NATIVE_MSG_PERM), [appName], 1));
|
||||
}
|
||||
|
||||
// Finally, show remaining permissions, in any order.
|
||||
for (let permission of perms.permissions) {
|
||||
// Handled above
|
||||
if (permission == "nativeMessaging") {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
result.msgs.push(bundle.GetStringFromName(permissionKey(permission)));
|
||||
} catch (err) {
|
||||
// We deliberately do not include all permissions in the prompt.
|
||||
// So if we don't find one then just skip it.
|
||||
}
|
||||
}
|
||||
|
||||
// Now figure out all the rest of the notification text.
|
||||
let name = this._sanitizeName(info.addon.name);
|
||||
let addonName = `<span class="addon-webext-name">${name}</span>`;
|
||||
|
||||
result.header = bundle.formatStringFromName("webextPerms.header", [addonName], 1);
|
||||
result.text = info.unsigned ?
|
||||
bundle.GetStringFromName("webextPerms.unsignedWarning") : "";
|
||||
result.listIntro = bundle.GetStringFromName("webextPerms.listIntro");
|
||||
|
||||
result.acceptText = bundle.GetStringFromName("webextPerms.add.label");
|
||||
result.acceptKey = bundle.GetStringFromName("webextPerms.add.accessKey");
|
||||
result.cancelText = bundle.GetStringFromName("webextPerms.cancel.label");
|
||||
result.cancelKey = bundle.GetStringFromName("webextPerms.cancel.accessKey");
|
||||
|
||||
if (info.type == "sideload") {
|
||||
result.header = bundle.formatStringFromName("webextPerms.sideloadHeader", [addonName], 1);
|
||||
let key = result.msgs.length == 0 ?
|
||||
"webextPerms.sideloadTextNoPerms" : "webextPerms.sideloadText2";
|
||||
result.text = bundle.GetStringFromName(key);
|
||||
result.acceptText = bundle.GetStringFromName("webextPerms.sideloadEnable.label");
|
||||
result.acceptKey = bundle.GetStringFromName("webextPerms.sideloadEnable.accessKey");
|
||||
result.cancelText = bundle.GetStringFromName("webextPerms.sideloadCancel.label");
|
||||
result.cancelKey = bundle.GetStringFromName("webextPerms.sideloadCancel.accessKey");
|
||||
} else if (info.type == "update") {
|
||||
result.header = "";
|
||||
result.text = bundle.formatStringFromName("webextPerms.updateText", [addonName], 1);
|
||||
result.acceptText = bundle.GetStringFromName("webextPerms.updateAccept.label");
|
||||
result.acceptKey = bundle.GetStringFromName("webextPerms.updateAccept.accessKey");
|
||||
} else if (info.type == "optional") {
|
||||
result.header = bundle.formatStringFromName("webextPerms.optionalPermsHeader", [addonName], 1);
|
||||
result.text = "";
|
||||
result.listIntro = bundle.GetStringFromName("webextPerms.optionalPermsListIntro");
|
||||
result.acceptText = bundle.GetStringFromName("webextPerms.optionalPermsAllow.label");
|
||||
result.acceptKey = bundle.GetStringFromName("webextPerms.optionalPermsAllow.accessKey");
|
||||
result.cancelText = bundle.GetStringFromName("webextPerms.optionalPermsDeny.label");
|
||||
result.cancelKey = bundle.GetStringFromName("webextPerms.optionalPermsDeny.accessKey");
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
showPermissionsPrompt(browser, strings, icon, histkey) {
|
||||
|
|
|
@ -230,8 +230,6 @@ pref("extensions.compatability.locales.buildid", "0");
|
|||
/* Don't let XPIProvider install distribution add-ons; we do our own thing on mobile. */
|
||||
pref("extensions.installDistroAddons", false);
|
||||
|
||||
pref("extensions.webextPermissionPrompts", true);
|
||||
|
||||
// Add-on content security policies.
|
||||
pref("extensions.webextensions.base-content-security-policy", "script-src 'self' https://* moz-extension: blob: filesystem: 'unsafe-eval' 'unsafe-inline'; object-src 'self' https://* moz-extension: blob: filesystem:;");
|
||||
pref("extensions.webextensions.default-content-security-policy", "script-src 'self'; object-src 'self';");
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<vector android:height="24dp" android:viewportHeight="64.0"
|
||||
android:viewportWidth="64.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF66CC52" android:pathData="M42,62c2.2,0 4,-1.8 4,-4l0,-14.2c0,0 0.4,-3.7 2.8,-3.7c2.4,0 2.2,3.9 6.7,3.9c2.3,0 6.2,-1.2 6.2,-8.2c0,-7 -3.9,-7.9 -6.2,-7.9c-4.5,0 -4.3,3.7 -6.7,3.7c-2.4,0 -2.8,-3.8 -2.8,-3.8V22c0,-2.2 -1.8,-4 -4,-4H31.5c0,0 -3.4,-0.6 -3.4,-3c0,-2.4 3.8,-2.6 3.8,-7.1c0,-2.3 -1.3,-5.9 -8.3,-5.9s-8,3.6 -8,5.9c0,4.5 3.4,4.7 3.4,7.1c0,2.4 -3.4,3 -3.4,3H6c-2.2,0 -4,1.8 -4,4l0,7.8c0,0 -0.4,6 4.4,6c3.1,0 3.2,-4.1 7.3,-4.1c2,0 4,1.9 4,6c0,4.2 -2,6.3 -4,6.3c-4,0 -4.2,-4.1 -7.3,-4.1c-4.8,0 -4.4,5.8 -4.4,5.8L2,58c0,2.2 1.8,4 4,4H19c0,0 6.3,0.4 6.3,-4.4c0,-3.1 -4,-3.6 -4,-7.7c0,-2 2.2,-4.5 6.4,-4.5c4.2,0 6.6,2.5 6.6,4.5c0,4 -3.9,4.6 -3.9,7.7c0,4.9 6.3,4.4 6.3,4.4H42z"/>
|
||||
</vector>
|
|
@ -1,31 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp">
|
||||
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<ImageView android:id="@+id/extension_permission_icon"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="@dimen/doorhanger_section_padding_small"/>
|
||||
<TextView android:id="@+id/extension_permission_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/extension_permission_body"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
|
@ -89,7 +89,6 @@ import org.mozilla.gecko.delegates.ScreenshotDelegate;
|
|||
import org.mozilla.gecko.distribution.Distribution;
|
||||
import org.mozilla.gecko.distribution.DistributionStoreCallback;
|
||||
import org.mozilla.gecko.dlc.DownloadContentService;
|
||||
import org.mozilla.gecko.extensions.ExtensionPermissionsHelper;
|
||||
import org.mozilla.gecko.firstrun.FirstrunAnimationContainer;
|
||||
import org.mozilla.gecko.gfx.DynamicToolbarAnimator;
|
||||
import org.mozilla.gecko.gfx.DynamicToolbarAnimator.PinReason;
|
||||
|
@ -316,8 +315,6 @@ public class BrowserApp extends GeckoApp
|
|||
|
||||
private AccountsHelper mAccountsHelper;
|
||||
|
||||
private ExtensionPermissionsHelper mExtensionPermissionsHelper;
|
||||
|
||||
// The tab to be selected on editing mode exit.
|
||||
private Integer mTargetTabForEditingMode;
|
||||
|
||||
|
@ -821,7 +818,6 @@ public class BrowserApp extends GeckoApp
|
|||
mSharedPreferencesHelper = new SharedPreferencesHelper(appContext);
|
||||
mReadingListHelper = new ReadingListHelper(appContext, profile);
|
||||
mAccountsHelper = new AccountsHelper(appContext, profile);
|
||||
mExtensionPermissionsHelper = new ExtensionPermissionsHelper(this);
|
||||
|
||||
if (AppConstants.MOZ_ANDROID_BEAM) {
|
||||
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
|
||||
|
@ -1540,11 +1536,6 @@ public class BrowserApp extends GeckoApp
|
|||
mAccountsHelper = null;
|
||||
}
|
||||
|
||||
if (mExtensionPermissionsHelper != null) {
|
||||
mExtensionPermissionsHelper.uninit();
|
||||
mExtensionPermissionsHelper = null;
|
||||
}
|
||||
|
||||
mSearchEngineManager.unregisterListeners();
|
||||
|
||||
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.extensions;
|
||||
|
||||
import org.mozilla.gecko.EventDispatcher;
|
||||
import org.mozilla.gecko.util.BundleEventListener;
|
||||
import org.mozilla.gecko.util.EventCallback;
|
||||
import org.mozilla.gecko.util.GeckoBundle;
|
||||
import org.mozilla.gecko.util.ResourceDrawableUtils;
|
||||
import org.mozilla.gecko.R;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ExtensionPermissionsHelper implements BundleEventListener {
|
||||
private static final String LOGTAG = "GeckoAddonManager";
|
||||
private final Context mContext;
|
||||
|
||||
public ExtensionPermissionsHelper(Context context) {
|
||||
mContext = context;
|
||||
|
||||
EventDispatcher.getInstance().registerUiThreadListener(this,
|
||||
"Extension:PermissionPrompt");
|
||||
}
|
||||
|
||||
public void uninit() {
|
||||
EventDispatcher.getInstance().unregisterUiThreadListener(this,
|
||||
"Extension:PermissionPrompt");
|
||||
}
|
||||
|
||||
@Override // BundleEventListener
|
||||
public void handleMessage(final String event, final GeckoBundle message,
|
||||
final EventCallback callback) {
|
||||
if ("Extension:PermissionPrompt".equals(event)) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
||||
|
||||
final View view = LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.extension_permissions_dialog, null);
|
||||
builder.setView(view);
|
||||
((TextView) view.findViewById(R.id.extension_permission_header)).setText(message.getString("header"));
|
||||
((TextView) view.findViewById(R.id.extension_permission_body)).setText(message.getString("message"));
|
||||
|
||||
final String iconUrl = message.getString("icon");
|
||||
final ImageView iconView = (ImageView) view.findViewById(R.id.extension_permission_icon);
|
||||
|
||||
builder.setPositiveButton(message.getString("acceptText"), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
callback.sendSuccess(true);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(message.getString("cancelText"), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
callback.sendSuccess(false);
|
||||
}
|
||||
});
|
||||
|
||||
ResourceDrawableUtils.getDrawable(mContext, iconUrl, new ResourceDrawableUtils.BitmapLoader() {
|
||||
@Override
|
||||
public void onBitmapFound(final Drawable d) {
|
||||
iconView.setImageDrawable(d);
|
||||
}
|
||||
});
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -628,7 +628,6 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
|
|||
'DynamicToolbar.java',
|
||||
'EditBookmarkDialog.java',
|
||||
'Experiments.java',
|
||||
'extensions/ExtensionPermissionsHelper.java',
|
||||
'FilePicker.java',
|
||||
'FilePickerResultHandler.java',
|
||||
'FindInPageBar.java',
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionData",
|
||||
"resource://gre/modules/Extension.jsm");
|
||||
|
||||
var ExtensionPermissions = {
|
||||
// Prepare the strings needed for a permission notification.
|
||||
_prepareStrings(info) {
|
||||
let appName = Strings.brand.GetStringFromName("brandShortName");
|
||||
let info2 = Object.assign({appName, addonName: info.addon.name}, info);
|
||||
let strings = ExtensionData.formatPermissionStrings(info2, Strings.browser);
|
||||
|
||||
// We dump the main body of the dialog into a big android
|
||||
// TextView. Build a big string with the full contents here.
|
||||
let message = "";
|
||||
if (strings.msgs.length > 0) {
|
||||
message = [strings.listIntro, ...strings.msgs.map(s => `\u2022 ${s}`)].join("\n");
|
||||
}
|
||||
|
||||
return {
|
||||
header: strings.header || strings.text,
|
||||
message,
|
||||
acceptText: strings.acceptText,
|
||||
cancelText: strings.cancelText,
|
||||
};
|
||||
},
|
||||
|
||||
// Prepare an icon for a permission notification
|
||||
_prepareIcon(iconURL) {
|
||||
// We can render pngs with ResourceDrawableUtils
|
||||
if (iconURL.endsWith(".png")) {
|
||||
return iconURL;
|
||||
}
|
||||
|
||||
// If we can't render an icon, show the default
|
||||
return "drawable://ic_extension";
|
||||
},
|
||||
|
||||
async observe(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "webextension-permission-prompt": {
|
||||
let {target, info} = subject.wrappedJSObject;
|
||||
|
||||
let details = this._prepareStrings(info);
|
||||
details.icon = this._prepareIcon(info.icon);
|
||||
details.type = "Extension:PermissionPrompt";
|
||||
let accepted = await EventDispatcher.instance.sendRequestForResult(details);
|
||||
|
||||
if (accepted) {
|
||||
info.resolve();
|
||||
} else {
|
||||
info.reject();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "webextension-update-permissions":
|
||||
// To be implemented in bug 1391579, just auto-approve until then
|
||||
subject.wrappedJSObject.resolve();
|
||||
break;
|
||||
|
||||
case "webextension-optional-permission-prompt":
|
||||
// To be implemented in bug 1392176, just auto-approve until then
|
||||
subject.wrappedJSObject.resolve(true);
|
||||
break;
|
||||
}
|
||||
},
|
||||
};
|
|
@ -151,10 +151,6 @@ lazilyLoadedBrowserScripts.forEach(function (aScript) {
|
|||
var lazilyLoadedObserverScripts = [
|
||||
["MemoryObserver", ["memory-pressure", "Memory:Dump"], "chrome://browser/content/MemoryObserver.js"],
|
||||
["ConsoleAPI", ["console-api-log-event"], "chrome://browser/content/ConsoleAPI.js"],
|
||||
["ExtensionPermissions", ["webextension-permission-prompt",
|
||||
"webextension-update-permissions",
|
||||
"webextension-optional-permission-prompt"],
|
||||
"chrome://browser/content/ExtensionPermissions.js"],
|
||||
];
|
||||
|
||||
lazilyLoadedObserverScripts.forEach(function (aScript) {
|
||||
|
|
|
@ -60,7 +60,6 @@ chrome.jar:
|
|||
#ifndef RELEASE_OR_BETA
|
||||
content/WebcompatReporter.js (content/WebcompatReporter.js)
|
||||
#endif
|
||||
content/ExtensionPermissions.js (content/ExtensionPermissions.js)
|
||||
|
||||
% content branding %content/branding/
|
||||
|
||||
|
|
|
@ -109,69 +109,6 @@ xpinstallDisabledMessageLocked=Software installation has been disabled by your s
|
|||
xpinstallDisabledMessage2=Software installation is currently disabled. Press Enable and try again.
|
||||
xpinstallDisabledButton=Enable
|
||||
|
||||
# LOCALIZATION NOTE (webextPerms.header)
|
||||
# This string is used as a header in the webextension permissions dialog,
|
||||
# %S is replaced with the localized name of the extension being installed.
|
||||
# See https://bug1308309.bmoattachments.org/attachment.cgi?id=8814612
|
||||
# for an example of the full dialog.
|
||||
# Note, this string will be used as raw markup. Avoid characters like <, >, &
|
||||
webextPerms.header=Add %S?
|
||||
|
||||
# LOCALIZATION NOTE (webextPerms.listIntro)
|
||||
# This string will be followed by a list of permissions requested
|
||||
# by the webextension.
|
||||
webextPerms.listIntro=It requires your permission to:
|
||||
webextPerms.add.label=Add
|
||||
webextPerms.add.accessKey=A
|
||||
webextPerms.cancel.label=Cancel
|
||||
webextPerms.cancel.accessKey=C
|
||||
|
||||
webextPerms.description.bookmarks=Read and modify bookmarks
|
||||
webextPerms.description.browserSettings=Read and modify browser settings
|
||||
webextPerms.description.clipboardRead=Get data from the clipboard
|
||||
webextPerms.description.clipboardWrite=Input data to the clipboard
|
||||
webextPerms.description.downloads=Download files and read and modify the browser’s download history
|
||||
webextPerms.description.geolocation=Access your location
|
||||
webextPerms.description.history=Access browsing history
|
||||
webextPerms.description.management=Monitor extension usage and manage themes
|
||||
# LOCALIZATION NOTE (webextPerms.description.nativeMessaging)
|
||||
# %S will be replaced with the name of the application
|
||||
webextPerms.description.nativeMessaging=Exchange messages with programs other than %S
|
||||
webextPerms.description.notifications=Display notifications to you
|
||||
webextPerms.description.privacy=Read and modify privacy settings
|
||||
webextPerms.description.sessions=Access recently closed tabs
|
||||
webextPerms.description.tabs=Access browser tabs
|
||||
webextPerms.description.topSites=Access browsing history
|
||||
webextPerms.description.unlimitedStorage=Store unlimited amount of client-side data
|
||||
webextPerms.description.webNavigation=Access browser activity during navigation
|
||||
|
||||
webextPerms.hostDescription.allUrls=Access your data for all websites
|
||||
|
||||
# LOCALIZATION NOTE (webextPerms.hostDescription.wildcard)
|
||||
# %S will be replaced by the DNS domain for which a webextension
|
||||
# is requesting access (e.g., mozilla.org)
|
||||
webextPerms.hostDescription.wildcard=Access your data for sites in the %S domain
|
||||
|
||||
# LOCALIZATION NOTE (webextPerms.hostDescription.tooManyWildcards):
|
||||
# Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #1 will be replaced by an integer indicating the number of additional
|
||||
# domains for which this webextension is requesting permission.
|
||||
webextPerms.hostDescription.tooManyWildcards=Access your data in #1 other domain;Access your data in #1 other domains
|
||||
|
||||
# LOCALIZATION NOTE (webextPerms.hostDescription.oneSite)
|
||||
# %S will be replaced by the DNS host name for which a webextension
|
||||
# is requesting access (e.g., www.mozilla.org)
|
||||
webextPerms.hostDescription.oneSite=Access your data for %S
|
||||
|
||||
# LOCALIZATION NOTE (webextPerms.hostDescription.tooManySites)
|
||||
# Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #1 will be replaced by an integer indicating the number of additional
|
||||
# hosts for which this webextension is requesting permission.
|
||||
webextPerms.hostDescription.tooManySites=Access your data on #1 other site;Access your data on #1 other sites
|
||||
|
||||
|
||||
# Site Identity
|
||||
identity.identified.verifier=Verified by: %S
|
||||
identity.identified.verified_by_you=You have added a security exception for this site
|
||||
|
|
|
@ -57,7 +57,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
MessageChannel: "resource://gre/modules/MessageChannel.jsm",
|
||||
NetUtil: "resource://gre/modules/NetUtil.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
PluralForm: "resource://gre/modules/PluralForm.jsm",
|
||||
Schemas: "resource://gre/modules/Schemas.jsm",
|
||||
setTimeout: "resource://gre/modules/Timer.jsm",
|
||||
TelemetryStopwatch: "resource://gre/modules/TelemetryStopwatch.jsm",
|
||||
|
@ -791,149 +790,6 @@ this.ExtensionData = class {
|
|||
this.localeData.selectedLocale = locale;
|
||||
return results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats all the strings for a permissions dialog/notification.
|
||||
*
|
||||
* @param {object} info Information about the permissions being requested.
|
||||
*
|
||||
* @param {array<string>} info.permissions.origins
|
||||
* Origin permissions requested.
|
||||
* @param {array<string>} info.permissions.permissions
|
||||
* Regular (non-origin) permissions requested.
|
||||
* @param {AddonWrapper} info.addonName
|
||||
* The name of the addon for which permissions are
|
||||
* being requested.
|
||||
* @param {boolean} info.unsigned
|
||||
* True if the prompt is for installing an unsigned addon.
|
||||
* @param {string} info.type
|
||||
* The type of prompt being shown. May be one of "update",
|
||||
* "sideload", "optional", or omitted for a regular
|
||||
* install prompt.
|
||||
* @param {string} info.appName
|
||||
* The localized name of the application, to be substituted
|
||||
* in computed strings as needed.
|
||||
* @param {nsIStringBundle} bundle
|
||||
* The string bundle to use for l10n.
|
||||
*
|
||||
* @returns {object} An object with properties containing localized strings
|
||||
* for various elements of a permission dialog.
|
||||
*/
|
||||
static formatPermissionStrings(info, bundle) {
|
||||
let result = {};
|
||||
|
||||
let perms = info.permissions || {origins: [], permissions: []};
|
||||
|
||||
// First classify our host permissions
|
||||
let allUrls = false, wildcards = [], sites = [];
|
||||
for (let permission of perms.origins) {
|
||||
if (permission == "<all_urls>") {
|
||||
allUrls = true;
|
||||
break;
|
||||
}
|
||||
let match = /^[htps*]+:\/\/([^/]+)\//.exec(permission);
|
||||
if (!match) {
|
||||
Cu.reportError(`Unparseable host permission ${permission}`);
|
||||
continue;
|
||||
}
|
||||
if (match[1] == "*") {
|
||||
allUrls = true;
|
||||
} else if (match[1].startsWith("*.")) {
|
||||
wildcards.push(match[1].slice(2));
|
||||
} else {
|
||||
sites.push(match[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Format the host permissions. If we have a wildcard for all urls,
|
||||
// a single string will suffice. Otherwise, show domain wildcards
|
||||
// first, then individual host permissions.
|
||||
result.msgs = [];
|
||||
if (allUrls) {
|
||||
result.msgs.push(bundle.GetStringFromName("webextPerms.hostDescription.allUrls"));
|
||||
} else {
|
||||
// Formats a list of host permissions. If we have 4 or fewer, display
|
||||
// them all, otherwise display the first 3 followed by an item that
|
||||
// says "...plus N others"
|
||||
let format = (list, itemKey, moreKey) => {
|
||||
function formatItems(items) {
|
||||
result.msgs.push(...items.map(item => bundle.formatStringFromName(itemKey, [item], 1)));
|
||||
}
|
||||
if (list.length < 5) {
|
||||
formatItems(list);
|
||||
} else {
|
||||
formatItems(list.slice(0, 3));
|
||||
|
||||
let remaining = list.length - 3;
|
||||
result.msgs.push(PluralForm.get(remaining, bundle.GetStringFromName(moreKey))
|
||||
.replace("#1", remaining));
|
||||
}
|
||||
};
|
||||
|
||||
format(wildcards, "webextPerms.hostDescription.wildcard",
|
||||
"webextPerms.hostDescription.tooManyWildcards");
|
||||
format(sites, "webextPerms.hostDescription.oneSite",
|
||||
"webextPerms.hostDescription.tooManySites");
|
||||
}
|
||||
|
||||
let permissionKey = perm => `webextPerms.description.${perm}`;
|
||||
|
||||
// Next, show the native messaging permission if it is present.
|
||||
const NATIVE_MSG_PERM = "nativeMessaging";
|
||||
if (perms.permissions.includes(NATIVE_MSG_PERM)) {
|
||||
result.msgs.push(bundle.formatStringFromName(permissionKey(NATIVE_MSG_PERM), [info.appName], 1));
|
||||
}
|
||||
|
||||
// Finally, show remaining permissions, in any order.
|
||||
for (let permission of perms.permissions) {
|
||||
// Handled above
|
||||
if (permission == "nativeMessaging") {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
result.msgs.push(bundle.GetStringFromName(permissionKey(permission)));
|
||||
} catch (err) {
|
||||
// We deliberately do not include all permissions in the prompt.
|
||||
// So if we don't find one then just skip it.
|
||||
}
|
||||
}
|
||||
|
||||
result.header = bundle.formatStringFromName("webextPerms.header", [info.addonName], 1);
|
||||
result.text = info.unsigned ?
|
||||
bundle.GetStringFromName("webextPerms.unsignedWarning") : "";
|
||||
result.listIntro = bundle.GetStringFromName("webextPerms.listIntro");
|
||||
|
||||
result.acceptText = bundle.GetStringFromName("webextPerms.add.label");
|
||||
result.acceptKey = bundle.GetStringFromName("webextPerms.add.accessKey");
|
||||
result.cancelText = bundle.GetStringFromName("webextPerms.cancel.label");
|
||||
result.cancelKey = bundle.GetStringFromName("webextPerms.cancel.accessKey");
|
||||
|
||||
if (info.type == "sideload") {
|
||||
result.header = bundle.formatStringFromName("webextPerms.sideloadHeader", [info.addonName], 1);
|
||||
let key = result.msgs.length == 0 ?
|
||||
"webextPerms.sideloadTextNoPerms" : "webextPerms.sideloadText2";
|
||||
result.text = bundle.GetStringFromName(key);
|
||||
result.acceptText = bundle.GetStringFromName("webextPerms.sideloadEnable.label");
|
||||
result.acceptKey = bundle.GetStringFromName("webextPerms.sideloadEnable.accessKey");
|
||||
result.cancelText = bundle.GetStringFromName("webextPerms.sideloadCancel.label");
|
||||
result.cancelKey = bundle.GetStringFromName("webextPerms.sideloadCancel.accessKey");
|
||||
} else if (info.type == "update") {
|
||||
result.header = "";
|
||||
result.text = bundle.formatStringFromName("webextPerms.updateText", [info.addonName], 1);
|
||||
result.acceptText = bundle.GetStringFromName("webextPerms.updateAccept.label");
|
||||
result.acceptKey = bundle.GetStringFromName("webextPerms.updateAccept.accessKey");
|
||||
} else if (info.type == "optional") {
|
||||
result.header = bundle.formatStringFromName("webextPerms.optionalPermsHeader", [info.addonName], 1);
|
||||
result.text = "";
|
||||
result.listIntro = bundle.GetStringFromName("webextPerms.optionalPermsListIntro");
|
||||
result.acceptText = bundle.GetStringFromName("webextPerms.optionalPermsAllow.label");
|
||||
result.acceptKey = bundle.GetStringFromName("webextPerms.optionalPermsAllow.accessKey");
|
||||
result.cancelText = bundle.GetStringFromName("webextPerms.optionalPermsDeny.label");
|
||||
result.cancelKey = bundle.GetStringFromName("webextPerms.optionalPermsDeny.accessKey");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
const PROXIED_EVENTS = new Set(["test-harness-message", "add-permissions", "remove-permissions"]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче