Bug 896121 - Disable share in guest mode for the awesomescreen. r=mfinkle, a=akeybl
authorWes Johnston <wjohnston@mozilla.com>
Thu, 05 Sep 2013 09:39:28 -0400
changeset 149262 15344ea24f5b6906dbf06fea6b8f42fefccd9658
parent 149261 0c619a15e9e28a049a37094ee90e9600620bf783
child 149263 e142baa23bb2fe9aa921a9f67fc93e5b2babe90a
push id4214
push userryanvm@gmail.com
push dateThu, 05 Sep 2013 13:39:48 +0000
treeherdermozilla-aurora@d771488dca97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, akeybl
bugs896121
milestone25.0a2
Bug 896121 - Disable share in guest mode for the awesomescreen. r=mfinkle, a=akeybl
mobile/android/base/AwesomeBar.java
mobile/android/base/BrowserApp.java
mobile/android/base/awesomebar/AwesomeBarTab.java
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -59,18 +59,21 @@ public class AwesomeBar extends GeckoAct
     public static final String URL_KEY = "url";
     public static final String TAB_KEY = "tab";
     public static final String CURRENT_URL_KEY = "currenturl";
     public static final String TARGET_KEY = "target";
     public static final String SEARCH_KEY = "search";
     public static final String TITLE_KEY = "title";
     public static final String USER_ENTERED_KEY = "user_entered";
     public static final String READING_LIST_KEY = "reading_list";
+    public static final String GUEST_MODE_KEY = "guest_mode_enabled";
     public static enum Target { NEW_TAB, CURRENT_TAB, PICK_SITE };
 
+    public boolean inGuestMode = false;
+
     private String mTarget;
     private AwesomeBarTabs mAwesomeTabs;
     private CustomEditText mText;
     private ImageButton mGoButton;
     private ContextMenuSubject mContextMenuSubject;
     private boolean mDelayRestartInput;
     // The previous autocomplete result returned to us
     private String mAutoCompleteResult = "";
@@ -155,16 +158,18 @@ public class AwesomeBar extends GeckoAct
                 if (mTabs != null)
                     mTabs.setPrivateMode(true);
 
                 mText.setPrivateMode(true);
             }
         }
         mAwesomeTabs.setTarget(mTarget);
 
+        inGuestMode = intent.getBooleanExtra(GUEST_MODE_KEY, false);
+
         mText.setOnKeyPreImeListener(new CustomEditText.OnKeyPreImeListener() {
             @Override
             public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
                 // We only want to process one event per tap
                 if (event.getAction() != KeyEvent.ACTION_DOWN)
                     return false;
 
                 if (keyCode == KeyEvent.KEYCODE_ENTER) {
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -688,16 +688,17 @@ abstract public class BrowserApp extends
     public boolean showAwesomebar(AwesomeBar.Target aTarget) {
         return showAwesomebar(aTarget, null);
     }
 
     public boolean showAwesomebar(AwesomeBar.Target aTarget, String aUrl) {
         Intent intent = new Intent(getBaseContext(), AwesomeBar.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
         intent.putExtra(AwesomeBar.TARGET_KEY, aTarget.name());
+        intent.putExtra(AwesomeBar.GUEST_MODE_KEY, GeckoProfile.get(this).inGuestMode());
 
         // If we were passed in a URL, show it.
         if (aUrl != null && !TextUtils.isEmpty(aUrl)) {
             intent.putExtra(AwesomeBar.CURRENT_URL_KEY, aUrl);
         } else if (aTarget == AwesomeBar.Target.CURRENT_TAB) {
             // Otherwise, if we're editing the current tab, show its URL.
             Tab tab = Tabs.getInstance().getSelectedTab();
             if (tab != null) {
--- a/mobile/android/base/awesomebar/AwesomeBarTab.java
+++ b/mobile/android/base/awesomebar/AwesomeBarTab.java
@@ -119,16 +119,21 @@ abstract public class AwesomeBarTab {
         }
         menu.findItem(R.id.open_new_tab).setVisible(!isPrivate);
         menu.findItem(R.id.open_private_tab).setVisible(isPrivate);
 
         // Hide "Remove" item if there isn't a valid history ID
         if (subject.id < 0) {
             menu.findItem(R.id.remove_history).setVisible(false);
         }
+
+        if ( ((AwesomeBar)mContext).inGuestMode ) {
+            menu.findItem(R.id.share).setVisible(false);
+        }
+
         menu.setHeaderTitle(subject.title);
     }
 
     protected void updateFavicon(FaviconView faviconView, Bitmap bitmap, String key) {
         faviconView.updateImage(bitmap, key);
     }
 
     protected void updateTitle(TextView titleView, Cursor cursor) {