Skip to content

Commit

Permalink
Limit tab sending to http/https in the TabWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin committed Apr 24, 2020
1 parent abe026e commit 17a2181
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 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 @@ -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 17a2181

Please sign in to comment.