Bug 697726: Stop button in URL bar [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 16 Nov 2011 16:23:22 -0800
changeset 83516 14e6f9bd949d9c2ae9b3ddb689cdfdf1a6f34dd1
parent 83515 a87cd9791a02f477ba6ba54f0e9d0d097f055e88
child 83517 a0b5bd8b07a75551abdfc6687a14e94336fa504f
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs697726
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 697726: Stop button in URL bar [r=mfinkle]
embedding/android/BrowserToolbar.java
embedding/android/GeckoApp.java
embedding/android/Makefile.in
embedding/android/Tab.java
embedding/android/resources/drawable-hdpi-v8/urlbar_stop.png
embedding/android/resources/drawable-mdpi-v8/urlbar_stop.png
embedding/android/resources/layout/browser_toolbar.xml
mobile/android/chrome/content/browser.js
--- a/embedding/android/BrowserToolbar.java
+++ b/embedding/android/BrowserToolbar.java
@@ -63,16 +63,17 @@ import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.TextSwitcher;
 import android.widget.ViewSwitcher.ViewFactory;
 
 public class BrowserToolbar extends LinearLayout {
     final private Button mAwesomeBar;
     final private ImageButton mTabs;
     final public ImageButton mFavicon;
+    final public ImageButton mStop;
     final private AnimationDrawable mProgressSpinner;
     final private TextSwitcher mTabsCount;
 
     final private Context mContext;
     final private Handler mHandler;
     final private int mColor;
     final private int mCounterColor;
 
@@ -145,16 +146,23 @@ public class BrowserToolbar extends Line
                 return text;
             } 
         });
         mCount = 0;
         mTabsCount.setText("0");
 
         mFavicon = (ImageButton) findViewById(R.id.favicon);
         mProgressSpinner = (AnimationDrawable) resources.getDrawable(R.drawable.progress_spinner);
+        
+        mStop = (ImageButton) findViewById(R.id.stop);
+        mStop.setOnClickListener(new Button.OnClickListener() {
+            public void onClick(View v) {
+                doStop();
+            }
+        });
 
         mHandler = new Handler();
         mSlideUpIn = new TranslateAnimation(0, 0, 30, 0);
         mSlideUpOut = new TranslateAnimation(0, 0, 0, -30);
         mSlideDownIn = new TranslateAnimation(0, 0, -30, 0);
         mSlideDownOut = new TranslateAnimation(0, 0, 0, 30);
 
         mDuration = 750;
@@ -192,16 +200,20 @@ public class BrowserToolbar extends Line
     private void addTab() {
         GeckoApp.mAppContext.addTab();
     }
 
     private void showTabs() {
         GeckoApp.mAppContext.showTabs();
     }
 
+    private void doStop() {
+        GeckoApp.mAppContext.doStop();
+    }
+
     public int getHighlightColor() {
         return mColor;
     }
     
     public void updateTabs(int count) {
         if (mCount > count) {
             mTabsCount.setInAnimation(mSlideDownIn);
             mTabsCount.setOutAnimation(mSlideDownOut);
@@ -237,18 +249,20 @@ public class BrowserToolbar extends Line
             }
         }, 2 * mDuration);
     }
 
     public void setProgressVisibility(boolean visible) {
         if (visible) {
             mFavicon.setImageDrawable(mProgressSpinner);
             mProgressSpinner.start();
+            mStop.setVisibility(View.VISIBLE);
         } else {
             mProgressSpinner.stop();
+            mStop.setVisibility(View.GONE);
             setFavicon(Tabs.getInstance().getSelectedTab().getFavicon());
         }
     }
 
     public void setTitle(CharSequence title) {
         mAwesomeBar.setText(title);
     }
 
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -1585,16 +1585,25 @@ abstract public class GeckoApp
         Log.i(LOG_NAME, "Forward requested");
         Tab tab = Tabs.getInstance().getSelectedTab();
         if (tab == null)
             return false;
 
         return tab.doForward();
     }
 
+    public boolean doStop() {
+        Log.i(LOG_NAME, "Stop requested");
+        Tab tab = Tabs.getInstance().getSelectedTab();
+        if (tab == null)
+            return false;
+
+        return tab.doStop();
+    }
+
     @Override
     public void onBackPressed() {
         if (mDoorHangerPopup.isShowing()) {
             mDoorHangerPopup.dismiss();
             return;
         }
 
         if (mFullScreen) {
--- a/embedding/android/Makefile.in
+++ b/embedding/android/Makefile.in
@@ -203,16 +203,17 @@ RES_DRAWABLE_MDPI_V8 = \
   res/drawable-mdpi-v8/tabs_pressed.png \
   res/drawable-mdpi-v8/tabs_more.png \
   res/drawable-mdpi-v8/tabs_plus.png \
   res/drawable-mdpi-v8/address_bar_url_bg.9.png \
   res/drawable-mdpi-v8/doorhanger_arrow.png \
   res/drawable-mdpi-v8/doorhanger_bg.9.png \
   res/drawable-mdpi-v8/doorhanger_shadow_bg.9.png \
   res/drawable-mdpi-v8/doorhanger_popup_bg.9.png \
+  res/drawable-mdpi-v8/urlbar_stop.png \
   $(NULL)
 
 RES_DRAWABLE_HDPI_V8 = \
   res/drawable-hdpi-v8/ic_menu_bookmark_add.png \
   res/drawable-hdpi-v8/ic_menu_bookmark_remove.png \
   res/drawable-hdpi-v8/ic_menu_find_in_page.png \
   res/drawable-hdpi-v8/ic_menu_reload.png \
   res/drawable-hdpi-v8/ic_menu_save_as_pdf.png \
@@ -221,16 +222,17 @@ RES_DRAWABLE_HDPI_V8 = \
   res/drawable-hdpi-v8/tabs_pressed.png \
   res/drawable-hdpi-v8/tabs_more.png \
   res/drawable-hdpi-v8/tabs_plus.png \
   res/drawable-hdpi-v8/address_bar_url_bg.9.png \
   res/drawable-hdpi-v8/doorhanger_arrow.png \
   res/drawable-hdpi-v8/doorhanger_bg.9.png \
   res/drawable-hdpi-v8/doorhanger_shadow_bg.9.png \
   res/drawable-hdpi-v8/doorhanger_popup_bg.9.png \
+  res/drawable-hdpi-v8/urlbar_stop.png \
   $(NULL)
 
 RES_DRAWABLE_MDPI_V9 = \
   res/drawable-mdpi-v9/ic_menu_bookmark_add.png \
   res/drawable-mdpi-v9/ic_menu_bookmark_remove.png \
   res/drawable-mdpi-v9/ic_menu_find_in_page.png \
   res/drawable-mdpi-v9/ic_menu_reload.png \
   res/drawable-mdpi-v9/ic_menu_save_as_pdf.png \
--- a/embedding/android/Tab.java
+++ b/embedding/android/Tab.java
@@ -222,16 +222,22 @@ public class Tab {
         if (mHistoryIndex < 1) {
             return false;
         }
         GeckoEvent e = new GeckoEvent("Session:Back", "");
         GeckoAppShell.sendEventToGecko(e);
         return true;
     }
 
+    public boolean doStop() {
+        GeckoEvent e = new GeckoEvent("Session:Stop", "");
+        GeckoAppShell.sendEventToGecko(e);
+        return true;
+    }
+
     public boolean canDoForward() {
         return (mHistoryIndex + 1 < mHistory.size());
     }
 
     public boolean doForward() {
         if (mHistoryIndex + 1 >= mHistory.size()) {
             return false;
         }
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d845a3af454f09434fb5d11d3164f33eb8a435b2
GIT binary patch
literal 1112
zc$@)P1gHCnP)<h;3K|Lk000e1NJLTq000;O000;W1^@s6;CDUv0000PbVXQnQ*UN;
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#`bk7VRCwByRar|LQ5d~hT%ysq1%h!Q
z8ja=$2!ToiNh1L%2t^UB_*5VK1MO2^`v-iHN}vUO6NJJ@uo5x9AsA4^LNppgG|{-*
zb1s=-vKZS7mzlZCIp24_Wem^H&q5sw3k&b?_=B13?d=scH8tX2#?#Z2I668KH#avn
ze7;{?T>Po-8TH@>gJB&rhELDo;i0&{zyB|A+>IKI#vj1?tnM4=0l`fs(|SWggXQ7j
zLEPTnrg70vPrAFiMQv?uRdAe_;AXRVq^YS%TwY!Z;Cz86-%Qun*Kh0V>wmShv{*bI
zkLc*=5EmC0R#^W5<O<$1R;yLOvZ~-PV#Mq93a8U4&ptjr1~)b~vWDg5WoKh!;|@q%
zSmcJt<#J+ocb89k5&%)6r>94Yi5?ta5`1`gShTjb3Me5b49sJUONkUkan{w<?cCkn
zxv(g;S4pm}uF@b409TUmvK}0yMc|NGz}P$_8V`j+TLv|YHa9n&xUhp@RV2YV=?UG3
z2b4vD<-Vbzp(1dL#gYfycpwni(t@mxXf*1?K}mwxXe7yGQj!$pN`XXz4-O8Bwzf76
z98-b^gTbw`H03xy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?+{|CyDWBKEU6KC)V&eT*>nJv3e@qQ4-@GeP6&L0m5
z>`0h7DN!U6`3MgpC>m2i_Z-N=l!aBTf)`~6&M~v-3F4*6g+!4CVl2(h&dzH=hF){H
z@SWw4Lsh{mkx(wwOAJJA{J54TCnx92{s(JoYjXhGJ3Bkmz$u6ROf{1B_I4*E`ZO^y
e@m1abE5HCE;o<_-Ok2eO0000<MNUMnLSTY~3GX-n
--- a/embedding/android/resources/layout/browser_toolbar.xml
+++ b/embedding/android/resources/layout/browser_toolbar.xml
@@ -11,17 +11,17 @@
                 android:layout_alignParentLeft="true"
                 android:layout_alignParentBottom="true"
                 android:layout_centerVertical="true"
                 android:singleLine="true"
                 android:gravity="center_vertical|left"
                 android:hint="@string/awesomebar_default_text"
                 android:textColor="#222222"
                 android:paddingLeft="42dip"
-                android:paddingRight="8dip"/>
+                android:paddingRight="42dip"/>
 
         <ImageButton android:id="@+id/favicon"
                      style="@style/AddressBar.ImageButton"
                      android:layout_width="21.33dip"
                      android:layout_height="21.33dip"
                      android:layout_marginLeft="15dip"
                      android:layout_centerVertical="true"
                      android:src="@drawable/favicon"
@@ -43,11 +43,21 @@
                      style="@style/AddressBar.ImageButton"
                      android:layout_width="54dip"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="15dip"
                      android:layout_alignRight="@id/tabs"
                      android:gravity="center_horizontal"
                      android:visibility="gone"/>
 
+        <ImageButton android:id="@+id/stop"
+                     style="@style/AddressBar.ImageButton"
+                     android:layout_width="20dip"
+                     android:layout_height="20dip"
+                     android:layout_marginRight="15dip"
+                     android:layout_centerVertical="true"
+                     android:src="@drawable/urlbar_stop"
+                     android:layout_alignRight="@id/awesome_bar"
+                     android:visibility="gone"/>
+
     </RelativeLayout>
 
 </merge>
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -149,16 +149,17 @@ var BrowserApp = {
 
     Services.obs.addObserver(this, "Tab:Add", false);
     Services.obs.addObserver(this, "Tab:Load", false);
     Services.obs.addObserver(this, "Tab:Select", false);
     Services.obs.addObserver(this, "Tab:Close", false);
     Services.obs.addObserver(this, "Session:Back", false);
     Services.obs.addObserver(this, "Session:Forward", false);
     Services.obs.addObserver(this, "Session:Reload", false);
+    Services.obs.addObserver(this, "Session:Stop", false);
     Services.obs.addObserver(this, "SaveAs:PDF", false);
     Services.obs.addObserver(this, "Browser:Quit", false);
     Services.obs.addObserver(this, "Preferences:Get", false);
     Services.obs.addObserver(this, "Preferences:Set", false);
     Services.obs.addObserver(this, "ScrollTo:FocusedInput", false);
     Services.obs.addObserver(this, "Sanitize:ClearAll", false);
     Services.obs.addObserver(this, "PanZoom:PanZoom", false);
     Services.obs.addObserver(this, "FullScreen:Exit", false);
@@ -591,16 +592,18 @@ var BrowserApp = {
       return;
 
     if (aTopic == "Session:Back") {
       browser.goBack();
     } else if (aTopic == "Session:Forward") {
       browser.goForward();
     } else if (aTopic == "Session:Reload") {
       browser.reload();
+    } else if (aTopic == "Session:Stop") {
+      browser.stop();
     } else if (aTopic == "Tab:Add") {
       let uri = URIFixup.createFixupURI(aData, Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP);
       let newTab = this.addTab(uri ? uri.spec : aData);
       newTab.active = true;
     } else if (aTopic == "Tab:Load") {
       let uri = URIFixup.createFixupURI(aData, Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP);
       browser.loadURI(uri ? uri.spec : aData);
     } else if (aTopic == "Tab:Select") {