Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fixes #3228 Send only http/https tabs (#3230)
Browse files Browse the repository at this point in the history
* Limit tabs sending to http/https

* Limit tab sending to http/https in the TabWidget

Co-authored-by: Randall E. Barker <[email protected]>
  • Loading branch information
keianhzo and bluemarvin authored Apr 24, 2020
1 parent 5bf1506 commit 2f33ded
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class TabView extends RelativeLayout implements GeckoSession.ContentDeleg
protected boolean mPressed;
protected CompletableFuture<Bitmap> mBitmapFuture;
protected boolean mUsingPlaceholder;
private boolean mIsPrivateMode;
private boolean mSendTabEnabled;
private static final int ICON_ANIMATION_DURATION = 100;

public interface Delegate {
Expand Down Expand Up @@ -216,8 +216,8 @@ public void setActive(boolean aActive) {
}
}

public void setPrivate(boolean privateMode) {
mIsPrivateMode = privateMode;
public void setSendTabEnabled(boolean enabled) {
mSendTabEnabled = enabled;
}

public void reset() {
Expand Down Expand Up @@ -261,7 +261,7 @@ private void updateState() {
boolean selected = isSelected();

mCloseButton.setVisibility(interacted && !selected && !mSelecting ? View.VISIBLE : View.GONE);
mSendTabButton.setVisibility(interacted && !selected && !mSelecting && !mIsPrivateMode ? View.VISIBLE : View.GONE);
mSendTabButton.setVisibility(mSendTabEnabled && interacted && !selected && !mSelecting ? View.VISIBLE : View.GONE);
mTitle.setVisibility(interacted && !selected ? View.VISIBLE : View.GONE);
mTabOverlay.setPressed(mPressed);
if (mSelecting) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.URLUtil;
import android.widget.EditText;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -1155,7 +1156,12 @@ public void onSwitchMode() {
hideMenu();
}
});
mHamburgerMenu.setSendTabEnabled(!UrlUtils.isPrivateAboutPage(getContext(), mAttachedWindow.getSession().getCurrentUri()));
boolean isSendTabEnabled = false;
if (URLUtil.isHttpUrl(mAttachedWindow.getSession().getCurrentUri()) ||
URLUtil.isHttpsUrl(mAttachedWindow.getSession().getCurrentUri())) {
isSendTabEnabled = true;
}
mHamburgerMenu.setSendTabEnabled(isSendTabEnabled);
mHamburgerMenu.setUAMode(mAttachedWindow.getSession().getUaMode());
mHamburgerMenu.show(UIWidget.KEEP_FOCUS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.URLUtil;
import android.widget.LinearLayout;
import android.widget.TextView;

Expand Down Expand Up @@ -240,13 +241,17 @@ public void onBindViewHolder(MyViewHolder holder, int position) {
holder.tabView.setSelected(mSelectedTabs.contains(holder.tabView.getSession()));
holder.tabView.setActive(SessionStore.get().getActiveSession() == holder.tabView.getSession());
if (holder.tabView.getSession() != null) {
holder.tabView.setPrivate(UrlUtils.isPrivateAboutPage(getContext(), holder.tabView.getSession().getCurrentUri()));
String uri = holder.tabView.getSession().getCurrentUri();
holder.tabView.setSendTabEnabled(URLUtil.isHttpUrl(uri) || URLUtil.isHttpsUrl(uri));
} else {
holder.tabView.setSendTabEnabled(false);
}
holder.tabView.setDelegate(new TabView.Delegate() {
@Override
public void onClose(TabView aSender) {
if (aSender.getSession() != null) {
holder.tabView.setPrivate(aSender.getSession().isPrivateMode());
String uri = aSender.getSession().getCurrentUri();
aSender.setSendTabEnabled(URLUtil.isHttpUrl(uri) || URLUtil.isHttpsUrl(uri));
}
if (mTabDelegate != null) {
ArrayList<Session> closed = new ArrayList<>();
Expand Down

0 comments on commit 2f33ded

Please sign in to comment.