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..2be96aa3890214f7e9540e128afc4ec27308bdf8 |
| --- /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); |
| + } |
| + |
| + /** |
| + * Encapsulates requests to the AnswerImagesService. |
| + */ |
| + public static class AnswersImageRequest { |
| + public final AnswersImageObserver observer; |
|
Ted C
2014/06/06 01:49:23
the indenting of this needs to be 4 (and many plac
groby-ooo-7-16
2014/06/13 23:52:21
Done.
|
| + 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( |
|
Ted C
2014/06/06 01:49:23
why not just pass back the request ID here? You p
groby-ooo-7-16
2014/06/13 23:52:21
It allows the Java side to hold a pointer to the o
Ted C
2014/06/17 20:38:15
I don't agree with this. I think it is entirely r
groby-ooo-7-16
2014/06/17 23:46:20
So be it. We'll see what shakes out of the ownersh
|
| + 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( |
| + 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); |
| +} |