| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 */ | 132 */ |
| 133 private int mParentId = INVALID_TAB_ID; | 133 private int mParentId = INVALID_TAB_ID; |
| 134 | 134 |
| 135 /** | 135 /** |
| 136 * Whether the tab should be grouped with its parent tab. | 136 * Whether the tab should be grouped with its parent tab. |
| 137 */ | 137 */ |
| 138 private boolean mGroupedWithParent = true; | 138 private boolean mGroupedWithParent = true; |
| 139 | 139 |
| 140 private boolean mIsClosing = false; | 140 private boolean mIsClosing = false; |
| 141 | 141 |
| 142 private Bitmap mFavicon = null; |
| 143 |
| 144 private String mFaviconUrl = null; |
| 145 |
| 142 /** | 146 /** |
| 143 * A default {@link ChromeContextMenuItemDelegate} that supports some of the
context menu | 147 * A default {@link ChromeContextMenuItemDelegate} that supports some of the
context menu |
| 144 * functionality. | 148 * functionality. |
| 145 */ | 149 */ |
| 146 protected class TabChromeContextMenuItemDelegate | 150 protected class TabChromeContextMenuItemDelegate |
| 147 extends EmptyChromeContextMenuItemDelegate { | 151 extends EmptyChromeContextMenuItemDelegate { |
| 148 private final Clipboard mClipboard; | 152 private final Clipboard mClipboard; |
| 149 | 153 |
| 150 /** | 154 /** |
| 151 * Builds a {@link TabChromeContextMenuItemDelegate} instance. | 155 * Builds a {@link TabChromeContextMenuItemDelegate} instance. |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 @CalledByNative | 882 @CalledByNative |
| 879 public String getTitle() { | 883 public String getTitle() { |
| 880 if (mNativePage != null) return mNativePage.getTitle(); | 884 if (mNativePage != null) return mNativePage.getTitle(); |
| 881 if (mContentViewCore != null) return mContentViewCore.getTitle(); | 885 if (mContentViewCore != null) return mContentViewCore.getTitle(); |
| 882 return ""; | 886 return ""; |
| 883 } | 887 } |
| 884 | 888 |
| 885 /** | 889 /** |
| 886 * @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 |
| 887 * is specified or it requires the default favicon. | 891 * is specified or it requires the default favicon. |
| 888 * TODO(bauerb): Upstream implementation. | |
| 889 */ | 892 */ |
| 890 public Bitmap getFavicon() { | 893 public Bitmap getFavicon() { |
| 891 return null; | 894 if (mContentViewCore != null) { |
| 895 if (mFavicon == null || !mContentViewCore.getUrl().equals(mFaviconUr
l)) { |
| 896 if (mNativeTabAndroid == 0) return null; |
| 897 mFavicon = nativeGetFavicon(mNativeTabAndroid); |
| 898 mFaviconUrl = mContentViewCore.getUrl(); |
| 899 } |
| 900 } |
| 901 return mFavicon; |
| 892 } | 902 } |
| 893 | 903 |
| 894 /** | 904 /** |
| 895 * Loads the tab if it's not loaded (e.g. because it was killed in backgroun
d). | 905 * Loads the tab if it's not loaded (e.g. because it was killed in backgroun
d). |
| 896 * @return true iff tab load was triggered | 906 * @return true iff tab load was triggered |
| 897 */ | 907 */ |
| 898 @CalledByNative | 908 @CalledByNative |
| 899 public boolean loadIfNeeded() { | 909 public boolean loadIfNeeded() { |
| 900 return false; | 910 return false; |
| 901 } | 911 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 */ | 1017 */ |
| 1008 protected TabChromeWebContentsDelegateAndroid getChromeWebContentsDelegateAn
droid() { | 1018 protected TabChromeWebContentsDelegateAndroid getChromeWebContentsDelegateAn
droid() { |
| 1009 return mWebContentsDelegate; | 1019 return mWebContentsDelegate; |
| 1010 } | 1020 } |
| 1011 | 1021 |
| 1012 /** | 1022 /** |
| 1013 * Called when the favicon of the content this tab represents changes. | 1023 * Called when the favicon of the content this tab represents changes. |
| 1014 */ | 1024 */ |
| 1015 @CalledByNative | 1025 @CalledByNative |
| 1016 protected void onFaviconUpdated() { | 1026 protected void onFaviconUpdated() { |
| 1027 mFavicon = null; |
| 1028 mFaviconUrl = null; |
| 1017 for (TabObserver observer : mObservers) observer.onFaviconUpdated(this); | 1029 for (TabObserver observer : mObservers) observer.onFaviconUpdated(this); |
| 1018 } | 1030 } |
| 1019 | 1031 |
| 1020 /** | 1032 /** |
| 1021 * Called when the navigation entry containing the historyitem changed, | 1033 * Called when the navigation entry containing the historyitem changed, |
| 1022 * for example because of a scroll offset or form field change. | 1034 * for example because of a scroll offset or form field change. |
| 1023 */ | 1035 */ |
| 1024 @CalledByNative | 1036 @CalledByNative |
| 1025 protected void onNavEntryChanged() { | 1037 protected void onNavEntryChanged() { |
| 1026 } | 1038 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean
deleteNative); | 1161 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean
deleteNative); |
| 1150 private native WebContents nativeGetWebContents(long nativeTabAndroid); | 1162 private native WebContents nativeGetWebContents(long nativeTabAndroid); |
| 1151 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); | 1163 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); |
| 1152 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e
xtraHeaders, | 1164 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e
xtraHeaders, |
| 1153 byte[] postData, int transition, String referrerUrl, int referrerPol
icy, | 1165 byte[] postData, int transition, String referrerUrl, int referrerPol
icy, |
| 1154 boolean isRendererInitiated); | 1166 boolean isRendererInitiated); |
| 1155 private native int nativeGetSecurityLevel(long nativeTabAndroid); | 1167 private native int nativeGetSecurityLevel(long nativeTabAndroid); |
| 1156 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab
Android, String url, | 1168 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab
Android, String url, |
| 1157 String title); | 1169 String title); |
| 1158 private native boolean nativePrint(long nativeTabAndroid); | 1170 private native boolean nativePrint(long nativeTabAndroid); |
| 1171 private native Bitmap nativeGetFavicon(long nativeTabAndroid); |
| 1159 } | 1172 } |
| OLD | NEW |