[MDM] Fix for incognito mode menu item
The incognito restriction was correctly gating incognito tab creation when
attempted from the 'new tab' screen, but I had missed the incognito icon
at the top of the menu.
The fix was to modify the IncognitoRestriction class to manage a new type
of control (the menu icon) and to push the gating logic down into the
Controller class (where it really belongs anyway).
Change-Id: I5395f060502907fcc7d03826568af1802450ad1b
diff --git a/src/com/android/browser/NavScreen.java b/src/com/android/browser/NavScreen.java
index 76d0703..d8bfd56 100644
--- a/src/com/android/browser/NavScreen.java
+++ b/src/com/android/browser/NavScreen.java
@@ -33,7 +33,6 @@
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.RelativeLayout;
-import android.widget.Toast;
import com.android.browser.NavTabScroller.OnRemoveListener;
import com.android.browser.mdm.IncognitoRestriction;
@@ -117,7 +116,7 @@
R.string.accessibility_transition_navscreen));
mToolbarLayout = findViewById(R.id.nav_toolbar_animate);
mNewIncognitoTab = (ImageButton) findViewById(R.id.newincognitotab);
- IncognitoRestriction.getInstance().registerButton(mNewIncognitoTab);
+ IncognitoRestriction.getInstance().registerControl(mNewIncognitoTab);
mNewTab = (ImageButton) findViewById(R.id.newtab);
mMore = (ImageButton) findViewById(R.id.more);
mNewIncognitoTab.setOnClickListener(this);
@@ -149,11 +148,7 @@
if (mNewTab == v) {
openNewTab();
} else if (mNewIncognitoTab == v) {
- if (IncognitoRestriction.getInstance().isEnabled()) {
- Toast.makeText(getContext(), R.string.mdm_managed_alert, Toast.LENGTH_SHORT).show();
- } else {
- openNewIncognitoTab();
- }
+ openNewIncognitoTab();
} else if (mMore == v) {
showPopupMenu();
}