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 /** |
29 * Initialize the native counterpart of this model. | 38 * Initialize the native counterpart of this model. |
30 * @param delegate The delegate that will be used by the model. | 39 * @param delegate The delegate that will be used by the model. |
31 */ | 40 */ |
32 public void initialize(ToolbarModelDelegate delegate) { | 41 public void initialize(ToolbarModelDelegate delegate) { |
33 mNativeToolbarModelAndroid = nativeInit(delegate); | 42 mNativeToolbarModelAndroid = nativeInit(delegate); |
34 } | 43 } |
35 | 44 |
36 /** | 45 /** |
37 * Destroys the native ToolbarModel. | 46 * Destroys the native ToolbarModel. |
38 */ | 47 */ |
(...skipping 14 matching lines...) Expand all Loading... |
53 if (mNativeToolbarModelAndroid == 0) return null; | 62 if (mNativeToolbarModelAndroid == 0) return null; |
54 return nativeGetCorpusChipText(mNativeToolbarModelAndroid); | 63 return nativeGetCorpusChipText(mNativeToolbarModelAndroid); |
55 } | 64 } |
56 | 65 |
57 /** @return Whether the URL is replaced by a search query. */ | 66 /** @return Whether the URL is replaced by a search query. */ |
58 public boolean wouldReplaceURL() { | 67 public boolean wouldReplaceURL() { |
59 if (mNativeToolbarModelAndroid == 0) return false; | 68 if (mNativeToolbarModelAndroid == 0) return false; |
60 return nativeWouldReplaceURL(mNativeToolbarModelAndroid); | 69 return nativeWouldReplaceURL(mNativeToolbarModelAndroid); |
61 } | 70 } |
62 | 71 |
| 72 private static native boolean nativeIsDeprecatedSHA1Present(WebContents webC
ontents); |
| 73 |
63 private native long nativeInit(ToolbarModelDelegate delegate); | 74 private native long nativeInit(ToolbarModelDelegate delegate); |
64 private native void nativeDestroy(long nativeToolbarModelAndroid); | 75 private native void nativeDestroy(long nativeToolbarModelAndroid); |
65 private native String nativeGetText(long nativeToolbarModelAndroid); | 76 private native String nativeGetText(long nativeToolbarModelAndroid); |
66 private native String nativeGetCorpusChipText(long nativeToolbarModelAndroid
); | 77 private native String nativeGetCorpusChipText(long nativeToolbarModelAndroid
); |
67 private native boolean nativeWouldReplaceURL(long nativeToolbarModelAndroid)
; | 78 private native boolean nativeWouldReplaceURL(long nativeToolbarModelAndroid)
; |
68 } | 79 } |
OLD | NEW |