Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/AnswersImage.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/AnswersImage.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/AnswersImage.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..504f050199dcfc4fd59a69d932714343720fa578 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/AnswersImage.java |
| @@ -0,0 +1,83 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.omnibox; |
| + |
| +import android.graphics.Bitmap; |
| + |
| +import org.chromium.base.CalledByNative; |
| +import org.chromium.chrome.browser.profiles.Profile; |
| + |
| +/** |
| + * Provides access to images used by Answers in Suggest. |
| + */ |
| +public class AnswersImage { |
| + /** |
| + * Observer for updating an image when it is available. |
| + */ |
| + public interface AnswersImageObserver { |
| + /** |
| + * Called when the image is updated. |
| + * |
| + * @param answersImage the image |
| + */ |
| + @CalledByNative("AnswersImageObserver") |
| + public void onAnswersImageChanged(Bitmap bitmap); |
|
Ted C
2014/06/17 20:38:15
-4 indent
groby-ooo-7-16
2014/06/17 23:46:20
Done.
|
| + } |
| + |
| + /** |
| + * Encapsulates requests to the AnswerImagesService. |
| + */ |
| + public static class AnswersImageRequest { |
| + public final AnswersImageObserver observer; |
| + public final int requestId; |
| + |
| + public AnswersImageRequest(AnswersImageObserver observer, int requestId) { |
| + this.observer = observer; |
| + this.requestId = requestId; |
| + } |
| + } |
| + |
| + /** |
| + * Request image, observer is notified when image is loaded. |
| + * @param profile Profile that the request is for. |
| + * @param imageUrl URL for image data. |
| + * @param observer Observer to be notified when image is updated. |
| + * @return An AnswersImageRequest. |
| + */ |
| + public static AnswersImageRequest requestAnswersImage( |
| + Profile profile, String imageUrl, AnswersImageObserver observer) { |
| + return nativeRequestAnswersImage(profile, imageUrl, observer); |
| + } |
| + |
| + /** |
| + * Cancel a pending image request. |
| + * @param profile Profile the request was issued for. |
| + * @param requestId The ID of the request to be cancelled. |
| + */ |
| + public static void cancelAnswersImageRequest(Profile profile, int requestId) { |
| + nativeCancelAnswersImageRequest(profile, requestId); |
| + } |
| + |
| + /** |
| + * Allows the native side to generate AnswersImageRequest objects. |
| + */ |
| + @CalledByNative |
| + private static AnswersImageRequest createAnswersImageRequest( |
|
Ted C
2014/06/17 20:38:15
This function needs to be -4 indented
groby-ooo-7-16
2014/06/17 23:46:20
Function deleted, since the request class is unnec
|
| + AnswersImageObserver observer, int requestId) { |
| + return new AnswersImageRequest(observer, requestId); |
| + } |
| + |
| + /** |
| + * Requests an image at |imageUrl| for the given |profile| with |observer| being notified. |
| + * @returns an AnswersImageRequest |
| + */ |
| + private static native AnswersImageRequest nativeRequestAnswersImage( |
| + Profile profile, String imageUrl, AnswersImageObserver observer); |
| + |
| + /** |
| + * Cancels a pending request. |
| + */ |
| + private static native void nativeCancelAnswersImageRequest(Profile profile, int requestId); |
| +} |