Commit fff09083 authored by Lei Tian's avatar Lei Tian Committed by Commit Bot

Roll out custom tabs change 5f4df5c...c4c043c

Bug: none
Change-Id: I1e50971fd5bf501c46429cea115421af49fcc01b
Reviewed-on: https://chromium-review.googlesource.com/959390
Commit-Queue: Lei Tian <ltian@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544179}
parent 7a90a691
...@@ -336,7 +336,7 @@ deps = { ...@@ -336,7 +336,7 @@ deps = {
}, },
'src/third_party/custom_tabs_client/src': { 'src/third_party/custom_tabs_client/src': {
'url': Var('chromium_git') + '/custom-tabs-client.git' + '@' + '54788baf5bfbe5bb42977dc52c2f608392e60f72', 'url': Var('chromium_git') + '/custom-tabs-client.git' + '@' + '5f4df5ce54f4956212eef396e67be376fc4c043c',
'condition': 'checkout_android', 'condition': 'checkout_android',
}, },
......
...@@ -41,7 +41,7 @@ public class BrowserActionActivity extends AsyncInitializationActivity { ...@@ -41,7 +41,7 @@ public class BrowserActionActivity extends AsyncInitializationActivity {
private int mType; private int mType;
private Uri mUri; private Uri mUri;
@VisibleForTesting @VisibleForTesting
String mCreatorPackageName; String mUntrustedCreatorPackageName;
@VisibleForTesting @VisibleForTesting
List<BrowserActionItem> mActions = new ArrayList<>(); List<BrowserActionItem> mActions = new ArrayList<>();
private PendingIntent mOnBrowserActionSelectedCallback; private PendingIntent mOnBrowserActionSelectedCallback;
...@@ -63,7 +63,7 @@ public class BrowserActionActivity extends AsyncInitializationActivity { ...@@ -63,7 +63,7 @@ public class BrowserActionActivity extends AsyncInitializationActivity {
mUri = Uri.parse(IntentHandler.getUrlFromIntent(intent)); mUri = Uri.parse(IntentHandler.getUrlFromIntent(intent));
mType = IntentUtils.safeGetIntExtra( mType = IntentUtils.safeGetIntExtra(
intent, BrowserActionsIntent.EXTRA_TYPE, BrowserActionsIntent.URL_TYPE_NONE); intent, BrowserActionsIntent.EXTRA_TYPE, BrowserActionsIntent.URL_TYPE_NONE);
mCreatorPackageName = BrowserActionsIntent.getCreatorPackageName(intent); mUntrustedCreatorPackageName = BrowserActionsIntent.getUntrustedCreatorPackageName(intent);
mOnBrowserActionSelectedCallback = IntentUtils.safeGetParcelableExtra( mOnBrowserActionSelectedCallback = IntentUtils.safeGetParcelableExtra(
intent, BrowserActionsIntent.EXTRA_SELECTED_ACTION_PENDING_INTENT); intent, BrowserActionsIntent.EXTRA_SELECTED_ACTION_PENDING_INTENT);
ArrayList<Bundle> bundles = IntentUtils.getParcelableArrayListExtra( ArrayList<Bundle> bundles = IntentUtils.getParcelableArrayListExtra(
...@@ -78,10 +78,10 @@ public class BrowserActionActivity extends AsyncInitializationActivity { ...@@ -78,10 +78,10 @@ public class BrowserActionActivity extends AsyncInitializationActivity {
&& !UrlConstants.HTTPS_SCHEME.equals(mUri.getScheme())) { && !UrlConstants.HTTPS_SCHEME.equals(mUri.getScheme())) {
Log.e(TAG, "Url should only be HTTP or HTTPS scheme"); Log.e(TAG, "Url should only be HTTP or HTTPS scheme");
return false; return false;
} else if (mCreatorPackageName == null) { } else if (mUntrustedCreatorPackageName == null) {
Log.e(TAG, "Missing creator's pacakge name"); Log.e(TAG, "Missing creator's pacakge name");
return false; return false;
} else if (!TextUtils.equals(mCreatorPackageName, getPackageName()) } else if (!TextUtils.equals(mUntrustedCreatorPackageName, getPackageName())
&& (intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { && (intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
Log.e(TAG, "Intent should not be started with FLAG_ACTIVITY_NEW_TASK"); Log.e(TAG, "Intent should not be started with FLAG_ACTIVITY_NEW_TASK");
return false; return false;
...@@ -107,8 +107,8 @@ public class BrowserActionActivity extends AsyncInitializationActivity { ...@@ -107,8 +107,8 @@ public class BrowserActionActivity extends AsyncInitializationActivity {
} }
} }
}; };
mHelper = new BrowserActionsContextMenuHelper(this, params, mActions, mCreatorPackageName, mHelper = new BrowserActionsContextMenuHelper(this, params, mActions,
mOnBrowserActionSelectedCallback, listener); mUntrustedCreatorPackageName, mOnBrowserActionSelectedCallback, listener);
mHelper.displayBrowserActionsMenu(view); mHelper.displayBrowserActionsMenu(view);
return; return;
} }
...@@ -132,7 +132,8 @@ public class BrowserActionActivity extends AsyncInitializationActivity { ...@@ -132,7 +132,8 @@ public class BrowserActionActivity extends AsyncInitializationActivity {
* @return The ContextMenuParams used to construct context menu. * @return The ContextMenuParams used to construct context menu.
*/ */
private ContextMenuParams createContextMenuParams() { private ContextMenuParams createContextMenuParams() {
Referrer referrer = IntentHandler.constructValidReferrerForAuthority(mCreatorPackageName); Referrer referrer =
IntentHandler.constructValidReferrerForAuthority(mUntrustedCreatorPackageName);
Point displaySize = new Point(); Point displaySize = new Point();
getWindowManager().getDefaultDisplay().getSize(displaySize); getWindowManager().getDefaultDisplay().getSize(displaySize);
...@@ -172,15 +173,16 @@ public class BrowserActionActivity extends AsyncInitializationActivity { ...@@ -172,15 +173,16 @@ public class BrowserActionActivity extends AsyncInitializationActivity {
} }
private void recordClientPackageName() { private void recordClientPackageName() {
if (TextUtils.isEmpty(mCreatorPackageName)) return; if (TextUtils.isEmpty(mUntrustedCreatorPackageName)) return;
ThreadUtils.runOnUiThread(new Runnable() { ThreadUtils.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
RapporServiceBridge.sampleString( RapporServiceBridge.sampleString(
"BrowserActions.ServiceClient.PackageName", mCreatorPackageName); "BrowserActions.ServiceClient.PackageName", mUntrustedCreatorPackageName);
if (GSAState.isGsaPackageName(mCreatorPackageName)) return; if (GSAState.isGsaPackageName(mUntrustedCreatorPackageName)) return;
RapporServiceBridge.sampleString( RapporServiceBridge.sampleString(
"BrowserActions.ServiceClient.PackageNameThirdParty", mCreatorPackageName); "BrowserActions.ServiceClient.PackageNameThirdParty",
mUntrustedCreatorPackageName);
} }
}); });
} }
......
...@@ -220,7 +220,7 @@ public class BrowserActionActivityTest { ...@@ -220,7 +220,7 @@ public class BrowserActionActivityTest {
Assert.assertEquals(1, mOnFinishNativeInitializationCallback.getCallCount()); Assert.assertEquals(1, mOnFinishNativeInitializationCallback.getCallCount());
Context context = InstrumentationRegistry.getTargetContext(); Context context = InstrumentationRegistry.getTargetContext();
Assert.assertEquals(context.getPackageName(), activity.mCreatorPackageName); Assert.assertEquals(context.getPackageName(), activity.mUntrustedCreatorPackageName);
// Check menu populated correctly. // Check menu populated correctly.
List<Pair<Integer, List<ContextMenuItem>>> menus = mItems; List<Pair<Integer, List<ContextMenuItem>>> menus = mItems;
...@@ -268,7 +268,7 @@ public class BrowserActionActivityTest { ...@@ -268,7 +268,7 @@ public class BrowserActionActivityTest {
Assert.assertEquals(0, mOnFinishNativeInitializationCallback.getCallCount()); Assert.assertEquals(0, mOnFinishNativeInitializationCallback.getCallCount());
Context context = InstrumentationRegistry.getTargetContext(); Context context = InstrumentationRegistry.getTargetContext();
Assert.assertEquals(context.getPackageName(), activity.mCreatorPackageName); Assert.assertEquals(context.getPackageName(), activity.mUntrustedCreatorPackageName);
// Check menu populated correctly that only copy, share and custom items are shown. // Check menu populated correctly that only copy, share and custom items are shown.
List<Pair<Integer, List<ContextMenuItem>>> menus = mItems; List<Pair<Integer, List<ContextMenuItem>>> menus = mItems;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment