OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.customtabs; | 5 package org.chromium.chrome.browser.customtabs; |
6 | 6 |
7 import android.content.Intent; | 7 import android.content.Intent; |
8 import android.content.pm.PackageManager; | 8 import android.content.pm.PackageManager; |
9 import android.content.pm.ResolveInfo; | 9 import android.content.pm.ResolveInfo; |
10 import android.net.Uri; | 10 import android.net.Uri; |
11 import android.os.AsyncTask; | 11 import android.os.AsyncTask; |
12 import android.view.Menu; | 12 import android.view.Menu; |
13 import android.view.MenuItem; | 13 import android.view.MenuItem; |
14 | 14 |
15 import org.chromium.base.BuildInfo; | 15 import org.chromium.base.BuildInfo; |
16 import org.chromium.base.VisibleForTesting; | 16 import org.chromium.base.VisibleForTesting; |
17 import org.chromium.chrome.R; | 17 import org.chromium.chrome.R; |
18 import org.chromium.chrome.browser.ChromeActivity; | 18 import org.chromium.chrome.browser.ChromeActivity; |
19 import org.chromium.chrome.browser.ChromeFeatureList; | |
19 import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate; | 20 import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate; |
20 import org.chromium.chrome.browser.share.ShareHelper; | 21 import org.chromium.chrome.browser.share.ShareHelper; |
21 import org.chromium.chrome.browser.tab.Tab; | 22 import org.chromium.chrome.browser.tab.Tab; |
22 | 23 |
23 import java.util.HashMap; | 24 import java.util.HashMap; |
24 import java.util.List; | 25 import java.util.List; |
25 import java.util.Map; | 26 import java.util.Map; |
26 import java.util.concurrent.ExecutionException; | 27 import java.util.concurrent.ExecutionException; |
27 | 28 |
28 /** | 29 /** |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 MenuItem bookmarkItem = menu.findItem(R.id.bookmark_this_page_id ); | 98 MenuItem bookmarkItem = menu.findItem(R.id.bookmark_this_page_id ); |
98 updateBookmarkMenuItem(bookmarkItem, currentTab); | 99 updateBookmarkMenuItem(bookmarkItem, currentTab); |
99 } else { | 100 } else { |
100 // Because we have custom logic for laying out the icon row, the bookmark icon must | 101 // Because we have custom logic for laying out the icon row, the bookmark icon must |
101 // be explicitly removed instead of just made invisible. | 102 // be explicitly removed instead of just made invisible. |
102 menu.findItem(R.id.icon_row_menu_id).getSubMenu().removeItem( | 103 menu.findItem(R.id.icon_row_menu_id).getSubMenu().removeItem( |
103 R.id.bookmark_this_page_id); | 104 R.id.bookmark_this_page_id); |
104 } | 105 } |
105 | 106 |
106 MenuItem openInChromeItem = menu.findItem(R.id.open_in_browser_id); | 107 MenuItem openInChromeItem = menu.findItem(R.id.open_in_browser_id); |
107 try { | 108 MenuItem readItLaterItem = menu.findItem(R.id.read_it_later_id); |
108 openInChromeItem.setTitle(mDefaultBrowserFetcher.get()); | 109 if (ChromeFeatureList.isEnabled("ReadItLaterInMenu")) { |
109 } catch (InterruptedException | ExecutionException e) { | 110 openInChromeItem.setTitle(R.string.menu_open_in_chrome); |
gone
2016/06/16 18:07:58
Any reason why this string is different in this ca
Ian Wen
2016/06/16 21:09:00
Done.
| |
110 openInChromeItem.setTitle( | 111 } else { |
111 mActivity.getString(R.string.menu_open_in_product_defaul t)); | 112 readItLaterItem.setVisible(false); |
113 try { | |
114 openInChromeItem.setTitle(mDefaultBrowserFetcher.get()); | |
115 } catch (InterruptedException | ExecutionException e) { | |
116 openInChromeItem.setTitle( | |
117 mActivity.getString(R.string.menu_open_in_product_de fault)); | |
118 } | |
112 } | 119 } |
113 | 120 |
114 // Add custom menu items. Make sure they are only added once. | 121 // Add custom menu items. Make sure they are only added once. |
115 if (!mIsCustomEntryAdded) { | 122 if (!mIsCustomEntryAdded) { |
116 mIsCustomEntryAdded = true; | 123 mIsCustomEntryAdded = true; |
117 for (int i = 0; i < mMenuEntries.size(); i++) { | 124 for (int i = 0; i < mMenuEntries.size(); i++) { |
118 MenuItem item = menu.add(0, 0, 1, mMenuEntries.get(i)); | 125 MenuItem item = menu.add(0, 0, 1, mMenuEntries.get(i)); |
119 mItemToIndexMap.put(item, i); | 126 mItemToIndexMap.put(item, i); |
120 } | 127 } |
121 } | 128 } |
(...skipping 21 matching lines...) Expand all Loading... | |
143 * the same title, a random one will be returned. This method is for testing purpose _only_. | 150 * the same title, a random one will be returned. This method is for testing purpose _only_. |
144 */ | 151 */ |
145 @VisibleForTesting | 152 @VisibleForTesting |
146 MenuItem getMenuItemForTitle(String title) { | 153 MenuItem getMenuItemForTitle(String title) { |
147 for (MenuItem item : mItemToIndexMap.keySet()) { | 154 for (MenuItem item : mItemToIndexMap.keySet()) { |
148 if (item.getTitle().equals(title)) return item; | 155 if (item.getTitle().equals(title)) return item; |
149 } | 156 } |
150 return null; | 157 return null; |
151 } | 158 } |
152 } | 159 } |
OLD | NEW |