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