зеркало из https://github.com/mozilla/gecko-dev.git
Bug 932208 - Part 2: Do not allow non-shareable links to be shared. r=mfinkle
This commit is contained in:
Родитель
ad6d0c7ed7
Коммит
8944acbd6f
|
@ -2315,10 +2315,9 @@ abstract public class BrowserApp extends GeckoApp
|
|||
}
|
||||
|
||||
// Disable share menuitem for about:, chrome:, file:, and resource: URIs
|
||||
String scheme = Uri.parse(url).getScheme();
|
||||
share.setVisible(!GeckoProfile.get(this).inGuestMode());
|
||||
share.setEnabled(!(scheme.equals("about") || scheme.equals("chrome") ||
|
||||
scheme.equals("file") || scheme.equals("resource")));
|
||||
final boolean inGuestMode = GeckoProfile.get(this).inGuestMode();
|
||||
share.setVisible(!inGuestMode);
|
||||
share.setEnabled(StringUtils.isShareableUrl(url) && !inGuestMode);
|
||||
|
||||
// NOTE: Use MenuUtils.safeSetEnabled because some actions might
|
||||
// be on the BrowserToolbar context menu
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.mozilla.gecko.db.BrowserDB;
|
|||
import org.mozilla.gecko.favicons.Favicons;
|
||||
import org.mozilla.gecko.home.TopSitesGridView.TopSitesGridContextMenuInfo;
|
||||
import org.mozilla.gecko.util.Clipboard;
|
||||
import org.mozilla.gecko.util.StringUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
import org.mozilla.gecko.util.UiAsyncTask;
|
||||
import org.mozilla.gecko.widget.ButtonToast;
|
||||
|
@ -110,7 +111,9 @@ abstract class HomeFragment extends Fragment {
|
|||
menu.findItem(R.id.home_remove).setVisible(false);
|
||||
}
|
||||
|
||||
menu.findItem(R.id.home_share).setVisible(!GeckoProfile.get(getActivity()).inGuestMode());
|
||||
if (!StringUtils.isShareableUrl(info.url) || GeckoProfile.get(getActivity()).inGuestMode()) {
|
||||
menu.findItem(R.id.home_share).setVisible(false);
|
||||
}
|
||||
|
||||
final boolean canOpenInReader = (info.display == Combined.DISPLAY_READER);
|
||||
menu.findItem(R.id.home_open_in_reader).setVisible(canOpenInReader);
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.EnumSet;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mozilla.gecko.GeckoProfile;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
|
@ -23,6 +24,7 @@ import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
|
|||
import org.mozilla.gecko.home.PinSiteDialog.OnSiteSelectedListener;
|
||||
import org.mozilla.gecko.home.TopSitesGridView.OnEditPinnedSiteListener;
|
||||
import org.mozilla.gecko.home.TopSitesGridView.TopSitesGridContextMenuInfo;
|
||||
import org.mozilla.gecko.util.StringUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -296,6 +298,10 @@ public class TopSitesPanel extends HomeFragment {
|
|||
menu.findItem(R.id.top_sites_pin).setVisible(false);
|
||||
menu.findItem(R.id.top_sites_unpin).setVisible(false);
|
||||
}
|
||||
|
||||
if (!StringUtils.isShareableUrl(info.url) || GeckoProfile.get(getActivity()).inGuestMode()) {
|
||||
menu.findItem(R.id.home_share).setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -154,4 +154,10 @@ public class StringUtils {
|
|||
|
||||
return url.substring(FILTER_URL_PREFIX.length());
|
||||
}
|
||||
|
||||
public static boolean isShareableUrl(final String url) {
|
||||
final String scheme = Uri.parse(url).getScheme();
|
||||
return !(scheme.equals("about") || scheme.equals("chrome") ||
|
||||
scheme.equals("file") || scheme.equals("resource"));
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче