Commit 36055f4c authored by Side Yilmaz's avatar Side Yilmaz Committed by Commit Bot

Fix wrong usages of profile at PaymentRequestHeader.

This CL fixes wrong usages of profile at PaymentRequestHeader by adding
extra profile parameter to |setTitleAndOrigin| function, while
PaymentRequestUI passes the profile to the function.

Bug: 1041781, 1075562
Change-Id: I9c23f54332c956ac27ea54ae6ef80c836034fcb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2215807Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771805}
parent 214ab94d
...@@ -58,19 +58,17 @@ public class PaymentRequestHeader extends FrameLayout { ...@@ -58,19 +58,17 @@ public class PaymentRequestHeader extends FrameLayout {
* @param title The title to display on the header. * @param title The title to display on the header.
* @param origin The origin to display on the header. * @param origin The origin to display on the header.
* @param securityLevel The security level of the page that invoked PaymentRequest. * @param securityLevel The security level of the page that invoked PaymentRequest.
* @param profile The current profile to initialize ChromeAutocompleteSchemeClassifier.
*/ */
public void setTitleAndOrigin(String title, String origin, int securityLevel) { public void setTitleAndOrigin(String title, String origin, int securityLevel, Profile profile) {
((TextView) findViewById(R.id.page_title)).setText(title); ((TextView) findViewById(R.id.page_title)).setText(title);
TextView hostName = (TextView) findViewById(R.id.hostname); TextView hostName = (TextView) findViewById(R.id.hostname);
Spannable url = new SpannableStringBuilder(origin); Spannable url = new SpannableStringBuilder(origin);
final boolean useDarkColors = final boolean useDarkColors =
!ColorUtils.shouldUseLightForegroundOnBackground(mBackgroundColor); !ColorUtils.shouldUseLightForegroundOnBackground(mBackgroundColor);
// TODO(https://crbug.com/1041781): Use the current profile (i.e., regular profile or
// incognito profile) instead of always using regular profile. It is wrong and need to be
// fixed not to cause data leakage from incognito to regular profile.
ChromeAutocompleteSchemeClassifier chromeAutocompleteSchemeClassifier = ChromeAutocompleteSchemeClassifier chromeAutocompleteSchemeClassifier =
new ChromeAutocompleteSchemeClassifier(Profile.getLastUsedRegularProfile()); new ChromeAutocompleteSchemeClassifier(profile);
OmniboxUrlEmphasizer.emphasizeUrl(url, mContext.getResources(), OmniboxUrlEmphasizer.emphasizeUrl(url, mContext.getResources(),
chromeAutocompleteSchemeClassifier, securityLevel, false /* isInternalPage */, chromeAutocompleteSchemeClassifier, securityLevel, false /* isInternalPage */,
useDarkColors, true /* emphasizeHttpsScheme */); useDarkColors, true /* emphasizeHttpsScheme */);
......
...@@ -405,7 +405,7 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O ...@@ -405,7 +405,7 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O
mRequestView = mRequestView =
(ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.payment_request, null); (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.payment_request, null);
prepareRequestView(mContext, title, origin, securityLevel, canAddCards); prepareRequestView(mContext, title, origin, securityLevel, canAddCards, profile);
mEditorDialog = new EditorDialog(activity, /*deleteRunnable =*/null, profile); mEditorDialog = new EditorDialog(activity, /*deleteRunnable =*/null, profile);
DimmingDialog.setVisibleStatusBarIconColor(mEditorDialog.getWindow()); DimmingDialog.setVisibleStatusBarIconColor(mEditorDialog.getWindow());
...@@ -478,9 +478,10 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O ...@@ -478,9 +478,10 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O
* @param origin The RFC6454 origin of the page. * @param origin The RFC6454 origin of the page.
* @param securityLevel The security level of the page that invoked PaymentRequest. * @param securityLevel The security level of the page that invoked PaymentRequest.
* @param canAddCards Whether new cards can be added. * @param canAddCards Whether new cards can be added.
* @param profile The current profile to pass PaymentRequestHeader.
*/ */
private void prepareRequestView( private void prepareRequestView(Context context, String title, String origin, int securityLevel,
Context context, String title, String origin, int securityLevel, boolean canAddCards) { boolean canAddCards, Profile profile) {
mSpinnyLayout = mRequestView.findViewById(R.id.payment_request_spinny); mSpinnyLayout = mRequestView.findViewById(R.id.payment_request_spinny);
assert mSpinnyLayout.getVisibility() == View.VISIBLE; assert mSpinnyLayout.getVisibility() == View.VISIBLE;
mIsShowingSpinner = true; mIsShowingSpinner = true;
...@@ -490,7 +491,7 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O ...@@ -490,7 +491,7 @@ public class PaymentRequestUI implements DimmingDialog.OnDismissListener, View.O
messageView.setText(R.string.payments_loading_message); messageView.setText(R.string.payments_loading_message);
((PaymentRequestHeader) mRequestView.findViewById(R.id.header)) ((PaymentRequestHeader) mRequestView.findViewById(R.id.header))
.setTitleAndOrigin(title, origin, securityLevel); .setTitleAndOrigin(title, origin, securityLevel, profile);
// Set up the buttons. // Set up the buttons.
mCloseButton = mRequestView.findViewById(R.id.close_button); mCloseButton = mRequestView.findViewById(R.id.close_button);
......
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