Bug 1174366 - Remove "Edit Site Settings" from Page menu. r=liuche
authorJonathan Almeida <jalmeida@mozilla.com>
Tue, 30 Jun 2015 17:37:41 -0700
changeset 268201 b2fb2a45b78002e8ae246e2ea5342a11601a4a0a
parent 268200 43d44f93838809aaa707b088d1b3bc65ad626e03
child 268202 3e0899a46ca4b1228e08862220c0f39fb65838aa
push id15742
push userryanvm@gmail.com
push dateMon, 19 Oct 2015 02:54:16 +0000
treeherderfx-team@b2fb2a45b780 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs1174366
milestone44.0a1
Bug 1174366 - Remove "Edit Site Settings" from Page menu. r=liuche
mobile/android/base/BrowserApp.java
mobile/android/base/resources/layout-large-v11/tab_strip_item_view.xml
mobile/android/base/resources/menu-large-v11/browser_app_menu.xml
mobile/android/base/resources/menu-v11/browser_app_menu.xml
mobile/android/base/resources/menu-xlarge-v11/browser_app_menu.xml
mobile/android/base/resources/menu/titlebar_contextmenu.xml
mobile/android/tests/browser/robocop/StringHelper.java
mobile/android/tests/browser/robocop/components/ToolbarComponent.java
mobile/android/tests/browser/robocop/testClearPrivateData.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1284,25 +1284,16 @@ public class BrowserApp extends GeckoApp
             if (!TextUtils.isEmpty(text)) {
                 loadUrlOrKeywordSearch(text);
                 Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.CONTEXT_MENU);
                 Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.CONTEXT_MENU, "pasteandgo");
             }
             return true;
         }
 
-        if (itemId == R.id.site_settings) {
-            // This can be selected from either the browser menu or the contextmenu, depending on the size and version (v11+) of the phone.
-            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Permissions:Get", null));
-            if (Versions.preHC) {
-                Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.CONTEXT_MENU, "site_settings");
-            }
-            return true;
-        }
-
         if (itemId == R.id.paste) {
             String text = Clipboard.getText();
             if (!TextUtils.isEmpty(text)) {
                 enterEditingMode(text);
                 showBrowserSearch();
                 mBrowserSearch.filter(text, null);
                 Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.CONTEXT_MENU, "paste");
             }
@@ -3169,17 +3160,16 @@ public class BrowserApp extends GeckoApp
             // NOTE: Use MenuUtils.safeSetEnabled because some actions might
             // be on the BrowserToolbar context menu.
             if (Versions.feature11Plus) {
                 // There is no page menu prior to v11 resources.
                 MenuUtils.safeSetEnabled(aMenu, R.id.page, false);
             }
             MenuUtils.safeSetEnabled(aMenu, R.id.subscribe, false);
             MenuUtils.safeSetEnabled(aMenu, R.id.add_search_engine, false);
-            MenuUtils.safeSetEnabled(aMenu, R.id.site_settings, false);
             MenuUtils.safeSetEnabled(aMenu, R.id.add_to_launcher, false);
 
             return true;
         }
 
         final boolean inGuestMode = GeckoProfile.get(this).inGuestMode();
 
         final boolean isAboutReader = AboutPages.isAboutReader(tab.getURL());
@@ -3255,17 +3245,16 @@ public class BrowserApp extends GeckoApp
 
         // NOTE: Use MenuUtils.safeSetEnabled because some actions might
         // be on the BrowserToolbar context menu.
         if (Versions.feature11Plus) {
             MenuUtils.safeSetEnabled(aMenu, R.id.page, !isAboutHome(tab));
         }
         MenuUtils.safeSetEnabled(aMenu, R.id.subscribe, tab.hasFeeds());
         MenuUtils.safeSetEnabled(aMenu, R.id.add_search_engine, tab.hasOpenSearch());
-        MenuUtils.safeSetEnabled(aMenu, R.id.site_settings, !isAboutHome(tab));
         MenuUtils.safeSetEnabled(aMenu, R.id.add_to_launcher, !isAboutHome(tab));
 
         // Action providers are available only ICS+.
         if (Versions.feature14Plus) {
             final GeckoActionProvider provider = ((GeckoMenuItem) share).getGeckoActionProvider();
             if (provider != null) {
                 Intent shareIntent = provider.getIntent();
 
--- a/mobile/android/base/resources/layout-large-v11/tab_strip_item_view.xml
+++ b/mobile/android/base/resources/layout-large-v11/tab_strip_item_view.xml
@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <merge xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:gecko="http://schemas.android.com/apk/res-auto">
 
-   <ImageView
+   <ImageButton
         android:id="@+id/favicon"
         android:layout_width="@dimen/browser_toolbar_favicon_size"
         android:layout_height="match_parent"
         android:layout_marginRight="8dp"
         android:scaleType="centerInside"
         android:duplicateParentState="true"/>
 
     <org.mozilla.gecko.widget.FadedSingleColorTextView
--- a/mobile/android/base/resources/menu-large-v11/browser_app_menu.xml
+++ b/mobile/android/base/resources/menu-large-v11/browser_app_menu.xml
@@ -69,19 +69,16 @@
                   android:title="@string/save_as_pdf"/>
 
             <item android:id="@+id/print"
                   android:title="@string/print"/>
 
             <item android:id="@+id/add_search_engine"
                   android:title="@string/contextmenu_add_search_engine"/>
 
-            <item android:id="@+id/site_settings"
-                  android:title="@string/contextmenu_site_settings" />
-
             <item android:id="@+id/add_to_launcher"
                   android:title="@string/contextmenu_add_to_launcher"/>
 
         </menu>
 
     </item>
 
     <item android:id="@+id/tools"
--- a/mobile/android/base/resources/menu-v11/browser_app_menu.xml
+++ b/mobile/android/base/resources/menu-v11/browser_app_menu.xml
@@ -69,19 +69,16 @@
                   android:title="@string/save_as_pdf"/>
 
             <item android:id="@+id/print"
                   android:title="@string/print"/>
 
             <item android:id="@+id/add_search_engine"
                   android:title="@string/contextmenu_add_search_engine"/>
 
-            <item android:id="@+id/site_settings"
-                  android:title="@string/contextmenu_site_settings" />
-
             <item android:id="@+id/add_to_launcher"
                   android:title="@string/contextmenu_add_to_launcher"/>
 
         </menu>
 
     </item>
 
     <item android:id="@+id/tools"
--- a/mobile/android/base/resources/menu-xlarge-v11/browser_app_menu.xml
+++ b/mobile/android/base/resources/menu-xlarge-v11/browser_app_menu.xml
@@ -70,19 +70,16 @@
                   android:title="@string/save_as_pdf"/>
 
             <item android:id="@+id/print"
                   android:title="@string/print"/>
 
             <item android:id="@+id/add_search_engine"
                   android:title="@string/contextmenu_add_search_engine"/>
 
-            <item android:id="@+id/site_settings"
-                  android:title="@string/contextmenu_site_settings" />
-
             <item android:id="@+id/add_to_launcher"
                   android:title="@string/contextmenu_add_to_launcher"/>
 
         </menu>
 
     </item>
 
     <item android:id="@+id/tools"
--- a/mobile/android/base/resources/menu/titlebar_contextmenu.xml
+++ b/mobile/android/base/resources/menu/titlebar_contextmenu.xml
@@ -15,15 +15,12 @@
           android:title="@string/contextmenu_subscribe"/>
 
     <item android:id="@+id/add_search_engine"
           android:title="@string/contextmenu_add_search_engine"/>
 
     <item android:id="@+id/copyurl"
           android:title="@string/contextmenu_copyurl"/>
 
-    <item android:id="@+id/site_settings"
-          android:title="@string/contextmenu_site_settings" />
-
     <item android:id="@+id/add_to_launcher"
           android:title="@string/contextmenu_add_to_launcher"/>
 
 </menu>
--- a/mobile/android/tests/browser/robocop/StringHelper.java
+++ b/mobile/android/tests/browser/robocop/StringHelper.java
@@ -11,16 +11,18 @@ import org.mozilla.gecko.R;
 
 public class StringHelper {
     private static StringHelper instance;
 
     // This needs to be accessed statically, before an instance of StringHelper can be created.
     public static String STATIC_ABOUT_HOME_URL = "about:home";
 
     public final String OK;
+    public final String CANCEL;
+    public final String CLEAR;
 
     // Note: DEFAULT_BOOKMARKS_TITLES.length == DEFAULT_BOOKMARKS_URLS.length
     public final String[] DEFAULT_BOOKMARKS_TITLES;
     public final String[] DEFAULT_BOOKMARKS_URLS;
     public final int DEFAULT_BOOKMARKS_COUNT;
 
     // About pages
     public final String ABOUT_BLANK_URL = "about:blank";
@@ -290,16 +292,18 @@ public class StringHelper {
     // Restore Tabs Settings
     public final String DONT_RESTORE_TABS;
     public final String ALWAYS_RESTORE_TABS;
     public final String DONT_RESTORE_QUIT;
 
     private StringHelper(final Resources res) {
 
         OK = res.getString(R.string.button_ok);
+        CANCEL = res.getString(R.string.button_cancel);
+        CLEAR = res.getString(R.string.button_clear);
 
         // Note: DEFAULT_BOOKMARKS_TITLES.length == DEFAULT_BOOKMARKS_URLS.length
         DEFAULT_BOOKMARKS_TITLES = new String[] {
                 res.getString(R.string.bookmarkdefaults_title_aboutfirefox),
                 res.getString(R.string.bookmarkdefaults_title_support),
                 res.getString(R.string.bookmarkdefaults_title_addons)
         };
         DEFAULT_BOOKMARKS_URLS = new String[] {
--- a/mobile/android/tests/browser/robocop/components/ToolbarComponent.java
+++ b/mobile/android/tests/browser/robocop/components/ToolbarComponent.java
@@ -5,17 +5,16 @@
 package org.mozilla.gecko.tests.components;
 
 import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertEquals;
 import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertFalse;
 import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertNotNull;
 import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertTrue;
 
 import org.mozilla.gecko.R;
-import org.mozilla.gecko.tests.StringHelper;
 import org.mozilla.gecko.tests.UITestContext;
 import org.mozilla.gecko.tests.helpers.DeviceHelper;
 import org.mozilla.gecko.tests.helpers.NavigationHelper;
 import org.mozilla.gecko.tests.helpers.WaitHelper;
 import org.mozilla.gecko.toolbar.PageActionLayout;
 
 import android.view.View;
 import android.widget.EditText;
--- a/mobile/android/tests/browser/robocop/testClearPrivateData.java
+++ b/mobile/android/tests/browser/robocop/testClearPrivateData.java
@@ -3,16 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.tests;
 
 import org.mozilla.gecko.R;
 
 import com.jayway.android.robotium.solo.Condition;
 import android.view.View;
+import android.widget.ImageButton;
 
 /**
  * This patch tests the clear private data options:
  * - clear history option by: adding and checking that clear private
  * data option removes the history items but not the users bookmarks
  * - clear site settings and clear saved password by: checking
  * each option present in the doorhanger and clearing the settings from
  * the URL bar context menu and settings menu
@@ -58,34 +59,32 @@ public class testClearPrivateData extend
             public boolean isSatisfied() {
                 return mDatabaseHelper.getBrowserDBUrls(DatabaseHelper.BrowserDataType.HISTORY).size() == expectedCount;
             }
         }, TEST_WAIT_MS);
         mAsserter.ok(match, "Checking that the number of history items is correct", String.valueOf(expectedCount) + " history items present in the database");
     }
 
     public void clearSiteSettings() {
-        String shareStrings[] = {"Share your location with", "Share", "Don't share", "There are no settings to clear"};
         String titleGeolocation = mStringHelper.ROBOCOP_GEOLOCATION_TITLE;
         String url = getAbsoluteUrl(mStringHelper.ROBOCOP_GEOLOCATION_URL);
-        loadCheckDismiss(shareStrings[1], url, shareStrings[0]);
-        checkOption(shareStrings[1], "Clear");
-        checkOption(shareStrings[3], "Cancel");
-        loadCheckDismiss(shareStrings[2], url, shareStrings[0]);
-        checkOption(shareStrings[2], "Cancel");
+        loadCheckDismiss(mStringHelper.GEO_ALLOW, url, mStringHelper.GEO_MESSAGE);
+        checkOption(mStringHelper.GEO_ALLOW, mStringHelper.CLEAR);
+        loadCheckDismiss(mStringHelper.GEO_DENY, url, mStringHelper.GEO_MESSAGE);
+        checkOption(mStringHelper.GEO_DENY, mStringHelper.CANCEL);
         checkDevice(titleGeolocation, url);
     }
 
     public void clearPassword(){
         String passwordStrings[] = { mStringHelper.LOGIN_MESSAGE, mStringHelper.LOGIN_ALLOW, mStringHelper.LOGIN_DENY };
         String title = mStringHelper.ROBOCOP_BLANK_PAGE_01_TITLE;
         String loginUrl = getAbsoluteUrl(mStringHelper.ROBOCOP_LOGIN_01_URL);
 
         loadCheckDismiss(passwordStrings[1], loginUrl, passwordStrings[0]);
-        checkOption(mStringHelper.CONTEXT_MENU_SITE_SETTINGS_SAVE_PASSWORD, "Clear");
+        checkOption(mStringHelper.CONTEXT_MENU_SITE_SETTINGS_SAVE_PASSWORD, mStringHelper.CLEAR);
         loadCheckDismiss(passwordStrings[2], loginUrl, passwordStrings[0]);
         checkDevice(title, getAbsoluteUrl(mStringHelper.ROBOCOP_BLANK_PAGE_01_URL));
     }
 
     // clear private data and verify the device type because for phone there is an extra back action to exit the settings menu
     public void checkDevice(final String title, final String url) {
         clearPrivateData();
         if (mDevice.type.equals("phone")) {
@@ -109,17 +108,28 @@ public class testClearPrivateData extend
     public void checkOption(String option, String button) {
         if (mDevice.version.equals("2.x")) {
             // Use the context menu in pre-11
             final View toolbarView = mSolo.getView(R.id.browser_toolbar);
             mSolo.clickLongOnView(toolbarView);
             mAsserter.ok(waitForText(mStringHelper.CONTEXT_MENU_ITEMS_IN_URL_BAR[2]), "Waiting for the pop-up to open", "Pop up was opened");
         } else {
             // Use the Page menu in 11+
-            selectMenuItem(mStringHelper.PAGE_LABEL);
-            mAsserter.ok(waitForText(mStringHelper.CONTEXT_MENU_ITEMS_IN_URL_BAR[2]), "Waiting for the submenu to open", "Submenu was opened");
+            openSiteSecurityDoorHanger();
+            mAsserter.ok(waitForText(mStringHelper.CONTEXT_MENU_ITEMS_IN_URL_BAR[2]), "Waiting for the submenu to open for " + option + " on " + button, "Submenu was opened");
         }
 
-	mSolo.clickOnText(mStringHelper.CONTEXT_MENU_ITEMS_IN_URL_BAR[2]);
+        mSolo.clickOnText(mStringHelper.CONTEXT_MENU_ITEMS_IN_URL_BAR[2]);
         mAsserter.ok(waitForText(option), "Verify that the option: " + option + " is in the list", "The option is in the list. There are settings to clear");
         mSolo.clickOnButton(button);
     }
+
+    private void openSiteSecurityDoorHanger() {
+        mSolo.waitForCondition(new Condition() {
+            @Override
+            public boolean isSatisfied() {
+                ImageButton btn = (ImageButton) mSolo.getView(R.id.favicon);
+                mSolo.clickOnView(btn);
+                return true;
+            }
+        }, TEST_WAIT_MS);
+    }
 }