1 // Copyright 2020 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.query_tiles; 6 7 import org.chromium.base.annotations.NativeMethods; 8 import org.chromium.chrome.browser.profiles.Profile; 9 import org.chromium.components.query_tiles.TileProvider; 10 11 /** 12 * Basic factory that creates and returns an {@link TileProvider} that is attached 13 * natively to the given {@link Profile}. 14 */ 15 public class TileProviderFactory { 16 private static TileProvider sTileProviderForTesting; 17 18 /** 19 * Used to get access to the tile provider backend. 20 * @return An {@link TileProvider} instance. 21 */ getForProfile(Profile profile)22 public static TileProvider getForProfile(Profile profile) { 23 if (sTileProviderForTesting != null) return sTileProviderForTesting; 24 return TileProviderFactoryJni.get().getForProfile(profile); 25 } 26 27 /** For testing only. */ setTileProviderForTesting(TileProvider provider)28 public static void setTileProviderForTesting(TileProvider provider) { 29 sTileProviderForTesting = provider; 30 } 31 32 @NativeMethods 33 interface Natives { getForProfile(Profile profile)34 TileProvider getForProfile(Profile profile); 35 } 36 }