diff options
-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 8137a67..8c25821 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 63b04e9..b948091 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 934f70f..3a68f4b 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; } |