diff options
author | Danesh M <daneshm90@gmail.com> | 2012-01-18 15:23:24 -0500 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-07 13:57:35 -0800 |
commit | fdabe56ae7bb73cff98baf3f5440bf6e0563a9b9 (patch) | |
tree | 16877033e42aa400623167ff2591d05abe4901b1 | |
parent | 1fd4bec1891e40dfe2e04c1ffe0bbd9f4e649cee (diff) | |
download | packages_apps_Browser-fdabe56ae7bb73cff98baf3f5440bf6e0563a9b9.tar.gz packages_apps_Browser-fdabe56ae7bb73cff98baf3f5440bf6e0563a9b9.tar.bz2 packages_apps_Browser-fdabe56ae7bb73cff98baf3f5440bf6e0563a9b9.zip |
Browser : Open in incognito tab
Long click on a link now allows you to choose
between opening in incognito/regular tab.
Credits: Danesh M
Signed-off-by: Arham Jamal <arhamjamal@gmail.com>
Change-Id: Iba8e7446e69ae66e0bd957910e6309fdb0e0b947
-rw-r--r-- | res/menu/browsercontext.xml | 2 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 7 | ||||
-rw-r--r-- | src/com/android/browser/Controller.java | 41 |
3 files changed, 48 insertions, 2 deletions
diff --git a/res/menu/browsercontext.xml b/res/menu/browsercontext.xml index 8137a6749..8c2582108 100644 --- a/res/menu/browsercontext.xml +++ b/res/menu/browsercontext.xml @@ -40,6 +40,8 @@ android:title="@string/contextmenu_openlink"/> <item android:id="@+id/open_newtab_context_menu_id" android:title="@string/contextmenu_openlink_newwindow"/> + <item android:id="@+id/open_newtab_incognito_context_menu_id" + android:title="@string/contextmenu_openlink_incognito_newwindow"/> <item android:id="@+id/save_link_context_menu_id" android:title="@string/contextmenu_savelink"/> <item android:id="@+id/copy_link_context_menu_id" diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 63b04e93f..b948091a7 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -17,4 +17,11 @@ <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <!-- Content description for home screen button [CHAR LIMIT=NONE] --> <string name="accessibility_button_homescreen">Home screen</string> + + <!-- Context Menu item to open the currently selected link in a new + incognito window. --> + <string name="contextmenu_openlink_incognito_newwindow">Open in new incognito tab</string> + <!-- Context Menu item to open the currently selected link in a new + background window. [CHAR LIMIT=50] --> + <string name="contextmenu_openlink_incognito_newwindow_background">Open in new incognito background tab</string> </resources> diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 934f70f71..3a68f4bf3 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -507,8 +507,9 @@ public class Controller break; case R.id.open_newtab_context_menu_id: final Tab parent = mTabControl.getCurrentTab(); - openTab(url, parent, - !mSettings.openInBackground(), true); + boolean privateBrowsing = msg.arg2 == 1; + openTab(url, parent != null && privateBrowsing, + !mSettings.openInBackground(), true, parent); break; case R.id.copy_link_context_menu_id: copy(url); @@ -1392,6 +1393,42 @@ public class Controller }); } } + newTabItem = menu.findItem(R.id.open_newtab_incognito_context_menu_id); + newTabItem.setTitle(getSettings().openInBackground() + ? R.string.contextmenu_openlink_incognito_newwindow_background + : R.string.contextmenu_openlink_incognito_newwindow); + newTabItem.setVisible(showNewTab); + newTabItem.setVisible(!mTabControl.getCurrentTab().isPrivateBrowsingEnabled()); + if (showNewTab) { + if (WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE == type) { + newTabItem.setOnMenuItemClickListener( + new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + final HashMap<String, WebView> hrefMap = + new HashMap<String, WebView>(); + hrefMap.put("webview", webview); + final Message msg = mHandler.obtainMessage( + FOCUS_NODE_HREF, + R.id.open_newtab_context_menu_id, + 1, hrefMap); + webview.requestFocusNodeHref(msg); + return true; + } + }); + } else { + newTabItem.setOnMenuItemClickListener( + new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + final Tab parent = mTabControl.getCurrentTab(); + openTab(extra, parent != null, + !mSettings.openInBackground(), true, parent); + return true; + } + }); + } + } if (type == WebView.HitTestResult.SRC_ANCHOR_TYPE) { break; } |