| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.toolbar; | 5 package org.chromium.chrome.browser.toolbar; |
| 6 | 6 |
| 7 import org.chromium.base.annotations.CalledByNative; | 7 import org.chromium.base.annotations.CalledByNative; |
| 8 import org.chromium.content_public.browser.WebContents; | 8 import org.chromium.content_public.browser.WebContents; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * Provides a way of accessing toolbar data and state. | 11 * Provides a way of accessing toolbar data and state. |
| 12 */ | 12 */ |
| 13 public class ToolbarModel { | 13 public class ToolbarModel { |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Delegate for providing additional information to the model. | 16 * Delegate for providing additional information to the model. |
| 17 */ | 17 */ |
| 18 public interface ToolbarModelDelegate { | 18 public interface ToolbarModelDelegate { |
| 19 /** | 19 /** |
| 20 * @return The currently active WebContents being used by the Toolbar. | 20 * @return The currently active WebContents being used by the Toolbar. |
| 21 */ | 21 */ |
| 22 @CalledByNative("ToolbarModelDelegate") | 22 @CalledByNative("ToolbarModelDelegate") |
| 23 WebContents getActiveWebContents(); | 23 WebContents getActiveWebContents(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 private long mNativeToolbarModelAndroid; | 26 private long mNativeToolbarModelAndroid; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * @param webContents The web contents to query for deprecated SHA-1 presenc
e. | |
| 30 * @return Whether the security level of the page was deprecated due to SHA-
1. | |
| 31 */ | |
| 32 public static boolean isDeprecatedSHA1Present(WebContents webContents) { | |
| 33 if (webContents == null) return false; | |
| 34 return nativeIsDeprecatedSHA1Present(webContents); | |
| 35 } | |
| 36 | |
| 37 /** | |
| 38 * Initialize the native counterpart of this model. | 29 * Initialize the native counterpart of this model. |
| 39 * @param delegate The delegate that will be used by the model. | 30 * @param delegate The delegate that will be used by the model. |
| 40 */ | 31 */ |
| 41 public void initialize(ToolbarModelDelegate delegate) { | 32 public void initialize(ToolbarModelDelegate delegate) { |
| 42 mNativeToolbarModelAndroid = nativeInit(delegate); | 33 mNativeToolbarModelAndroid = nativeInit(delegate); |
| 43 } | 34 } |
| 44 | 35 |
| 45 /** | 36 /** |
| 46 * Destroys the native ToolbarModel. | 37 * Destroys the native ToolbarModel. |
| 47 */ | 38 */ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 62 if (mNativeToolbarModelAndroid == 0) return null; | 53 if (mNativeToolbarModelAndroid == 0) return null; |
| 63 return nativeGetCorpusChipText(mNativeToolbarModelAndroid); | 54 return nativeGetCorpusChipText(mNativeToolbarModelAndroid); |
| 64 } | 55 } |
| 65 | 56 |
| 66 /** @return Whether the URL is replaced by a search query. */ | 57 /** @return Whether the URL is replaced by a search query. */ |
| 67 public boolean wouldReplaceURL() { | 58 public boolean wouldReplaceURL() { |
| 68 if (mNativeToolbarModelAndroid == 0) return false; | 59 if (mNativeToolbarModelAndroid == 0) return false; |
| 69 return nativeWouldReplaceURL(mNativeToolbarModelAndroid); | 60 return nativeWouldReplaceURL(mNativeToolbarModelAndroid); |
| 70 } | 61 } |
| 71 | 62 |
| 72 private static native boolean nativeIsDeprecatedSHA1Present(WebContents webC
ontents); | |
| 73 | |
| 74 private native long nativeInit(ToolbarModelDelegate delegate); | 63 private native long nativeInit(ToolbarModelDelegate delegate); |
| 75 private native void nativeDestroy(long nativeToolbarModelAndroid); | 64 private native void nativeDestroy(long nativeToolbarModelAndroid); |
| 76 private native String nativeGetText(long nativeToolbarModelAndroid); | 65 private native String nativeGetText(long nativeToolbarModelAndroid); |
| 77 private native String nativeGetCorpusChipText(long nativeToolbarModelAndroid
); | 66 private native String nativeGetCorpusChipText(long nativeToolbarModelAndroid
); |
| 78 private native boolean nativeWouldReplaceURL(long nativeToolbarModelAndroid)
; | 67 private native boolean nativeWouldReplaceURL(long nativeToolbarModelAndroid)
; |
| 79 } | 68 } |
| OLD | NEW |