Invite the user to set up AutoFill

If the user has not set up an AutoFill profile but has the
feature enabled and they start to fill out a form that we
have determined as "autofillable" then offer to take them
to the profile editor to set up their profile.

Change-Id: Ia44c7036ef616d4ea826e541471dd916262488f2
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index b12b317..0f8ce6b 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -54,6 +54,7 @@
 import android.widget.FrameLayout;
 import android.widget.LinearLayout;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -1061,6 +1062,35 @@
         public void getVisitedHistory(final ValueCallback<String[]> callback) {
             mWebViewController.getVisitedHistory(callback);
         }
+
+        @Override
+        public void setupAutoFill(Message message) {
+            // Prompt the user to set up their profile.
+            final Message msg = message;
+            AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
+            builder.setMessage(R.string.autofill_setup_dialog_message)
+                   .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+                       @Override
+                       public void onClick(DialogInterface dialog, int id) {
+                           // Take user to the AutoFill profile editor. When they return,
+                           // we will send the message that we pass here which will trigger
+                           // the form to get filled out with their new profile.
+                           mWebViewController.setupAutoFill(msg);
+                       }
+                   })
+                   .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
+                       @Override
+                       public void onClick(DialogInterface dialog, int id) {
+                           // Disable autofill and show a toast with how to turn it on again.
+                           BrowserSettings s = BrowserSettings.getInstance();
+                           s.addObserver(mMainView.getSettings());
+                           s.disableAutoFill(mActivity);
+                           s.update();
+                           Toast.makeText(mActivity, R.string.autofill_setup_dialog_negative_toast,
+                                   Toast.LENGTH_LONG).show();
+                       }
+                   }).show();
+        }
     };
 
     // -------------------------------------------------------------------------