Commit 8e9d7625 authored by Peter E Conn's avatar Peter E Conn Committed by Commit Bot

🍱 Hold a singleton instance of ExternalAuthUtils in AppHooks.

For modularization, we don't want ExternalAuthUtils to rely on AppHooks.
Since AppHooks is required for the creation of an ExternalAuthUtils, we
have AppHooks hold the singleton instance instead of having
ExternalAuthUtils do it itself.

Change-Id: I5845333ddf92a6f2fdeb61f7d12b2b632e849f16
Bug: 1104817
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2296088Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Peter Conn <peconn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788519}
parent c089c79a
...@@ -61,6 +61,9 @@ import java.util.List; ...@@ -61,6 +61,9 @@ import java.util.List;
public abstract class AppHooks { public abstract class AppHooks {
private static AppHooksImpl sInstance; private static AppHooksImpl sInstance;
@Nullable
private ExternalAuthUtils mExternalAuthUtils;
/** /**
* Sets a mocked instance for testing. * Sets a mocked instance for testing.
*/ */
...@@ -138,6 +141,19 @@ public abstract class AppHooks { ...@@ -138,6 +141,19 @@ public abstract class AppHooks {
return new ExternalAuthUtils(); return new ExternalAuthUtils();
} }
/**
* @return The singleton instance of ExternalAuthUtils.
*
* TODO(https://crbug.com/1104817): Make createExternalAuthUtils protected.
*/
public ExternalAuthUtils getExternalAuthUtils() {
if (mExternalAuthUtils == null) {
mExternalAuthUtils = createExternalAuthUtils();
}
return mExternalAuthUtils;
}
/** /**
* @return An instance of {@link FeedbackReporter} to report feedback. * @return An instance of {@link FeedbackReporter} to report feedback.
*/ */
......
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