Commit aa3b35c6 authored by Pete Williamson's avatar Pete Williamson Committed by Commit Bot

Minor cleanup of convertNameFormat.

For https://chromium-review.googlesource.com/c/chromium/src/+/2276685,
a few comments came in after the change was in the CQ.  These are the
fixes that those comments requested.

Bug: 1099504
Change-Id: Ib457a3f0f5d12679f2a65413afef34dde559d491
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2289924
Commit-Queue: Peter Williamson <petewil@chromium.org>
Reviewed-by: default avatarDan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787858}
parent 2a3cc46b
...@@ -497,8 +497,6 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand ...@@ -497,8 +497,6 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
@Override @Override
public void sendFeedback(Map<String, String> productSpecificDataMap) { public void sendFeedback(Map<String, String> productSpecificDataMap) {
HashMap<String, String> feedContext = new HashMap<String, String>();
Profile profile = Profile.getLastUsedRegularProfile(); Profile profile = Profile.getLastUsedRegularProfile();
if (profile == null) { if (profile == null) {
return; return;
...@@ -509,7 +507,7 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand ...@@ -509,7 +507,7 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
return; return;
} }
convertNameFormat(productSpecificDataMap, feedContext); Map<String, String> feedContext = convertNameFormat(productSpecificDataMap);
// FEEDBACK_CONTEXT: This identifies this feedback as coming from Chrome for Android (as // FEEDBACK_CONTEXT: This identifies this feedback as coming from Chrome for Android (as
// opposed to desktop). // opposed to desktop).
...@@ -524,8 +522,7 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand ...@@ -524,8 +522,7 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
// name from the XSurface format to the format that can be handled by the feedback system. Any // name from the XSurface format to the format that can be handled by the feedback system. Any
// new strings that are added on the XSurface side will need a code change here, and adding the // new strings that are added on the XSurface side will need a code change here, and adding the
// PSD to the allow list. // PSD to the allow list.
private void convertNameFormat( private Map<String, String> convertNameFormat(Map<String, String> xSurfaceMap) {
Map<String, String> xSurfaceMap, Map<String, String> feedbackMap) {
Map<String, String> feedbackNameConversionMap = new HashMap<>(); Map<String, String> feedbackNameConversionMap = new HashMap<>();
feedbackNameConversionMap.put("Card URL", "CardUrl"); feedbackNameConversionMap.put("Card URL", "CardUrl");
feedbackNameConversionMap.put("Card Title", "CardTitle"); feedbackNameConversionMap.put("Card Title", "CardTitle");
...@@ -535,10 +532,21 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand ...@@ -535,10 +532,21 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
// For each <name, value> entry in the input map, convert the name to the new name, and // For each <name, value> entry in the input map, convert the name to the new name, and
// write the new <name, value> pair into the output map. // write the new <name, value> pair into the output map.
Map<String, String> feedbackMap = new HashMap<>();
for (Map.Entry<String, String> entry : xSurfaceMap.entrySet()) { for (Map.Entry<String, String> entry : xSurfaceMap.entrySet()) {
String newName = feedbackNameConversionMap.get(entry.getKey()); String newName = feedbackNameConversionMap.get(entry.getKey());
feedbackMap.put(newName, entry.getValue()); if (newName != null) {
feedbackMap.put(newName, entry.getValue());
} else {
Log.v(TAG, "Found an entry with no conversion available.");
// We will put the entry into the map if untranslatable. It will be discarded
// unless it matches an allow list on the server, though. This way we can choose
// to allow it on the server if desired.
feedbackMap.put(entry.getKey(), entry.getValue());
}
} }
return feedbackMap;
} }
@Override @Override
......
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