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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.graphics.Color; | 10 import android.graphics.Color; |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 if (mNativePage != null) return mNativePage.getTitle(); | 884 if (mNativePage != null) return mNativePage.getTitle(); |
885 if (mContentViewCore != null) return mContentViewCore.getTitle(); | 885 if (mContentViewCore != null) return mContentViewCore.getTitle(); |
886 return ""; | 886 return ""; |
887 } | 887 } |
888 | 888 |
889 /** | 889 /** |
890 * @return The bitmap of the favicon scaled to 16x16dp. null if no favicon | 890 * @return The bitmap of the favicon scaled to 16x16dp. null if no favicon |
891 * is specified or it requires the default favicon. | 891 * is specified or it requires the default favicon. |
892 */ | 892 */ |
893 public Bitmap getFavicon() { | 893 public Bitmap getFavicon() { |
894 if (mContentViewCore != null) { | 894 String url = getUrl(); |
895 if (mFavicon == null || !mContentViewCore.getUrl().equals(mFaviconUr l)) { | 895 // Invalidate our cached values if necessary. |
896 if (mNativeTabAndroid == 0) return null; | 896 if (url == null || !url.equals(mFaviconUrl)) { |
897 mFavicon = nativeGetFavicon(mNativeTabAndroid); | 897 mFavicon = null; |
898 mFaviconUrl = mContentViewCore.getUrl(); | 898 mFaviconUrl = null; |
899 } | |
900 | |
901 if (mFavicon == null) { | |
902 // If we have no content return null. | |
903 if (getNativePage() == null && getContentViewCore() == null) return null; | |
904 | |
905 Bitmap favicon = nativeGetFavicon(mNativeTabAndroid); | |
906 | |
907 // If the favicon is not yet valid (i.e. it's eitehr blank or a plac eholder), then do | |
Yaron
2014/08/22 22:11:12
either
David Trainor- moved to gerrit
2014/08/25 17:49:31
Done.
| |
908 // not cache the results. We still return this though so we have so mething to show. | |
909 if (favicon != null && nativeIsFaviconValid(mNativeTabAndroid)) { | |
Yaron
2014/08/22 22:11:12
Instead of the extra JNI call, move this isfavicon
David Trainor- moved to gerrit
2014/08/25 17:49:31
Need to pull it out :(. We still want to grab the
| |
910 mFavicon = favicon; | |
911 mFaviconUrl = url; | |
899 } | 912 } |
913 | |
914 return favicon; | |
900 } | 915 } |
916 | |
901 return mFavicon; | 917 return mFavicon; |
902 } | 918 } |
903 | 919 |
904 /** | 920 /** |
905 * Loads the tab if it's not loaded (e.g. because it was killed in backgroun d). | 921 * Loads the tab if it's not loaded (e.g. because it was killed in backgroun d). |
906 * @return true iff tab load was triggered | 922 * @return true iff tab load was triggered |
907 */ | 923 */ |
908 @CalledByNative | 924 @CalledByNative |
909 public boolean loadIfNeeded() { | 925 public boolean loadIfNeeded() { |
910 return false; | 926 return false; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1162 private native WebContents nativeGetWebContents(long nativeTabAndroid); | 1178 private native WebContents nativeGetWebContents(long nativeTabAndroid); |
1163 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); | 1179 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); |
1164 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, | 1180 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, |
1165 byte[] postData, int transition, String referrerUrl, int referrerPol icy, | 1181 byte[] postData, int transition, String referrerUrl, int referrerPol icy, |
1166 boolean isRendererInitiated); | 1182 boolean isRendererInitiated); |
1167 private native int nativeGetSecurityLevel(long nativeTabAndroid); | 1183 private native int nativeGetSecurityLevel(long nativeTabAndroid); |
1168 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, | 1184 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, |
1169 String title); | 1185 String title); |
1170 private native boolean nativePrint(long nativeTabAndroid); | 1186 private native boolean nativePrint(long nativeTabAndroid); |
1171 private native Bitmap nativeGetFavicon(long nativeTabAndroid); | 1187 private native Bitmap nativeGetFavicon(long nativeTabAndroid); |
1188 private native boolean nativeIsFaviconValid(long nativeTabAndroid); | |
1172 } | 1189 } |
OLD | NEW |