Fix AutoFill

Ensure that we sync the new profile data to WebSettings so that
it will get sent to native land.

Change-Id: I825557d9c73e218f0056f6bfd1d3b726ca9f6eef
diff --git a/src/com/android/browser/AutofillHandler.java b/src/com/android/browser/AutofillHandler.java
index d91c7ff..b6b237d 100644
--- a/src/com/android/browser/AutofillHandler.java
+++ b/src/com/android/browser/AutofillHandler.java
@@ -119,18 +119,22 @@
     }
 
     public void setAutoFillProfile(AutoFillProfile profile, Message msg) {
+        int profileId = NO_AUTOFILL_PROFILE_SET;
         if (profile != null) {
-            setActiveAutoFillProfileId(profile.getUniqueId());
+            profileId = profile.getUniqueId();
             // Update the AutoFill DB with the new profile.
             new SaveProfileToDbTask(msg).execute(profile);
         } else {
             // Delete the current profile.
             if (mAutoFillProfile != null) {
                 new DeleteProfileFromDbTask(msg).execute(mAutoFillProfile.getUniqueId());
-                setActiveAutoFillProfileId(NO_AUTOFILL_PROFILE_SET);
             }
         }
+        // Make sure we set mAutoFillProfile before calling setActiveAutoFillProfileId
+        // Calling setActiveAutoFillProfileId will trigger an update of WebViews
+        // which will expect a new profile to be set
         mAutoFillProfile = profile;
+        setActiveAutoFillProfileId(profileId);
     }
 
     public AutoFillProfile getAutoFillProfile() {