1 // Copyright 2012 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.
5 package org.chromium.chrome.browser;
7 import android.graphics.Rect;
8 import android.graphics.RectF;
10 import org.chromium.base.CalledByNative;
11 import org.chromium.components.web_contents_delegate_android.WebContentsDelegateAndroid;
14 * Chromium Android specific WebContentsDelegate.
15 * This file is the Java version of the native class of the same name.
16 * It should contain empty WebContentsDelegate methods to be implemented by the embedder.
17 * These methods belong to the Chromium Android port but not to WebView.
19 public class ChromeWebContentsDelegateAndroid extends WebContentsDelegateAndroid {
22 public void onFindResultAvailable(FindNotificationDetails result) {
26 public void onFindMatchRectsAvailable(FindMatchRectsDetails result) {
30 public boolean addNewContents(long nativeSourceWebContents, long nativeWebContents,
31 int disposition, Rect initialPosition, boolean userGesture) {
35 // Helper functions used to create types that are part of the public interface
37 private static Rect createRect(int x, int y, int right, int bottom) {
38 return new Rect(x, y, right, bottom);
42 private static RectF createRectF(float x, float y, float right, float bottom) {
43 return new RectF(x, y, right, bottom);
47 private static FindNotificationDetails createFindNotificationDetails(
48 int numberOfMatches, Rect rendererSelectionRect,
49 int activeMatchOrdinal, boolean finalUpdate) {
50 return new FindNotificationDetails(numberOfMatches, rendererSelectionRect,
51 activeMatchOrdinal, finalUpdate);
55 private static FindMatchRectsDetails createFindMatchRectsDetails(
56 int version, int numRects, RectF activeRect) {
57 return new FindMatchRectsDetails(version, new RectF[numRects], activeRect);
61 private static void setMatchRectByIndex(
62 FindMatchRectsDetails findMatchRectsDetails, int index, RectF rect) {
63 findMatchRectsDetails.rects[index] = rect;