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) | |
897 return null; | |
David Trainor- moved to gerrit
2014/07/28 17:50:04
put on line above or add {} (java style)
Jitu( very slow this week)
2014/07/30 11:33:55
Done.
| |
898 mFavicon = nativeGetFavicon(mNativeTabAndroid); | |
899 mFaviconUrl = mContentViewCore.getUrl(); | |
900 } | |
901 } | |
902 return mFavicon; | |
892 } | 903 } |
893 | 904 |
894 /** | 905 /** |
895 * Loads the tab if it's not loaded (e.g. because it was killed in backgroun d). | 906 * 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 | 907 * @return true iff tab load was triggered |
897 */ | 908 */ |
898 @CalledByNative | 909 @CalledByNative |
899 public boolean loadIfNeeded() { | 910 public boolean loadIfNeeded() { |
900 return false; | 911 return false; |
901 } | 912 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1007 */ | 1018 */ |
1008 protected TabChromeWebContentsDelegateAndroid getChromeWebContentsDelegateAn droid() { | 1019 protected TabChromeWebContentsDelegateAndroid getChromeWebContentsDelegateAn droid() { |
1009 return mWebContentsDelegate; | 1020 return mWebContentsDelegate; |
1010 } | 1021 } |
1011 | 1022 |
1012 /** | 1023 /** |
1013 * Called when the favicon of the content this tab represents changes. | 1024 * Called when the favicon of the content this tab represents changes. |
1014 */ | 1025 */ |
1015 @CalledByNative | 1026 @CalledByNative |
1016 protected void onFaviconUpdated() { | 1027 protected void onFaviconUpdated() { |
1028 mFavicon = null; | |
1029 mFaviconUrl = null; | |
1017 for (TabObserver observer : mObservers) observer.onFaviconUpdated(this); | 1030 for (TabObserver observer : mObservers) observer.onFaviconUpdated(this); |
1018 } | 1031 } |
1019 | 1032 |
1020 /** | 1033 /** |
1021 * Called when the navigation entry containing the historyitem changed, | 1034 * Called when the navigation entry containing the historyitem changed, |
1022 * for example because of a scroll offset or form field change. | 1035 * for example because of a scroll offset or form field change. |
1023 */ | 1036 */ |
1024 @CalledByNative | 1037 @CalledByNative |
1025 protected void onNavEntryChanged() { | 1038 protected void onNavEntryChanged() { |
1026 } | 1039 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1149 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); | 1162 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); |
1150 private native WebContents nativeGetWebContents(long nativeTabAndroid); | 1163 private native WebContents nativeGetWebContents(long nativeTabAndroid); |
1151 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); | 1164 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); |
1152 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, | 1165 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, |
1153 byte[] postData, int transition, String referrerUrl, int referrerPol icy, | 1166 byte[] postData, int transition, String referrerUrl, int referrerPol icy, |
1154 boolean isRendererInitiated); | 1167 boolean isRendererInitiated); |
1155 private native int nativeGetSecurityLevel(long nativeTabAndroid); | 1168 private native int nativeGetSecurityLevel(long nativeTabAndroid); |
1156 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, | 1169 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, |
1157 String title); | 1170 String title); |
1158 private native boolean nativePrint(long nativeTabAndroid); | 1171 private native boolean nativePrint(long nativeTabAndroid); |
1172 private native Bitmap nativeGetFavicon(long nativeTabAndroid); | |
1159 } | 1173 } |
OLD | NEW |