Home | History | Annotate | Download | only in autofill
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 package org.chromium.chrome.browser.autofill;
      6 
      7 import org.chromium.base.CalledByNative;
      8 import org.chromium.base.JNINamespace;
      9 
     10 /**
     11 * JNI call glue for AutofillExternalDelagate C++ and Java objects.
     12 */
     13 @JNINamespace("autofill")
     14 public class AutofillLogger {
     15     /**
     16      * An entry to be sent to Logger.
     17      */
     18     public static class LogEntry {
     19         private final String mAutofilledValue;
     20         private final String mProfileFullName;
     21 
     22         private LogEntry(String autofilledValue, String profileFullName) {
     23             mAutofilledValue = autofilledValue;
     24             mProfileFullName = profileFullName;
     25         }
     26 
     27         public String getAutofilledValue() {
     28             return mAutofilledValue;
     29         }
     30 
     31         public String getProfileFullName() {
     32             return mProfileFullName;
     33         }
     34     }
     35 
     36     /**
     37      * A logger interface. Uses LogItem instead of individual fields to allow
     38      * changing the items that are logged without breaking the embedder.
     39      */
     40     public interface Logger {
     41         public void didFillField(LogEntry logItem);
     42     }
     43 
     44     private static Logger sLogger = null;
     45 
     46     public static void setLogger(Logger logger) {
     47         sLogger = logger;
     48     }
     49 
     50     @CalledByNative
     51     private static void didFillField(String autofilledValue, String profileFullName) {
     52         if (sLogger == null) return;
     53         sLogger.didFillField(new LogEntry(autofilledValue, profileFullName));
     54     }
     55 }
     56