diff options
author | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 21:45:17 +0000 |
---|---|---|
committer | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 21:45:17 +0000 |
commit | 0ef25efb6f417a78cb34f498a4a6088d84a332d7 (patch) | |
tree | e652dd6430d9bfd10c1cf8c618530663e3634ebf /chrome/android | |
parent | b5b56bcd54a0cb31137cf330b924386052655838 (diff) | |
download | chromium_src-0ef25efb6f417a78cb34f498a4a6088d84a332d7.zip chromium_src-0ef25efb6f417a78cb34f498a4a6088d84a332d7.tar.gz chromium_src-0ef25efb6f417a78cb34f498a4a6088d84a332d7.tar.bz2 |
Set NavigationEntry titles based on NativePage titles
BUG=277010
Review URL: https://codereview.chromium.org/25804007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/android')
-rw-r--r-- | chrome/android/java/src/org/chromium/chrome/browser/TabBase.java | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java index cf8057c..a5fe835 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java @@ -80,11 +80,15 @@ public abstract class TabBase implements NavigationClient { */ private ContentViewCore mContentViewCore; - // Observers and Delegates. + /** + * A list of TabBase observers. These are used to broadcast TabBase events to listeners. + */ + private final ObserverList<TabObserver> mObservers = new ObserverList<TabObserver>(); + + // Content layer Observers and Delegates private ContentViewClient mContentViewClient; private WebContentsObserverAndroid mWebContentsObserver; private TabBaseChromeWebContentsDelegateAndroid mWebContentsDelegate; - private final ObserverList<TabObserver> mObservers = new ObserverList<TabObserver>(); /** * A basic {@link ChromeWebContentsDelegateAndroid} that forwards some calls to the registered @@ -112,6 +116,19 @@ public abstract class TabBase implements NavigationClient { } } + private class TabBaseWebContentsObserverAndroid extends WebContentsObserverAndroid { + public TabBaseWebContentsObserverAndroid(ContentViewCore contentViewCore) { + super(contentViewCore); + } + + @Override + public void navigationEntryCommitted() { + if (getNativePage() != null) { + pushNativePageStateToNavigationEntry(); + } + } + } + /** * Creates an instance of a {@link TabBase} with no id. * @param incognito Whether or not this tab is incognito. @@ -415,6 +432,7 @@ public abstract class TabBase implements NavigationClient { if (mNativePage == nativePage) return; destroyNativePageInternal(); mNativePage = nativePage; + pushNativePageStateToNavigationEntry(); for (TabObserver observer : mObservers) observer.onContentChanged(this); } @@ -456,7 +474,7 @@ public abstract class TabBase implements NavigationClient { mContentViewCore = mContentView.getContentViewCore(); mWebContentsDelegate = createWebContentsDelegate(); - mWebContentsObserver = createWebContentsObserverAndroid(mContentViewCore); + mWebContentsObserver = new TabBaseWebContentsObserverAndroid(mContentViewCore); if (mContentViewClient != null) mContentViewCore.setContentViewClient(mContentViewClient); @@ -541,16 +559,6 @@ public abstract class TabBase implements NavigationClient { } /** - * A helper method to allow subclasses to build their own observer. - * @param contentViewCore The {@link ContentViewCore} this observer should be built for. - * @return An instance of a {@link WebContentsObserverAndroid}. - */ - protected WebContentsObserverAndroid createWebContentsObserverAndroid( - ContentViewCore contentViewCore) { - return null; - } - - /** * @return The {@link WindowAndroid} associated with this {@link TabBase}. */ protected WindowAndroid getWindowAndroid() { @@ -643,6 +651,12 @@ public abstract class TabBase implements NavigationClient { return sIdCounter.getAndIncrement(); } + private void pushNativePageStateToNavigationEntry() { + assert mNativeTabAndroid != 0 && getNativePage() != null; + nativeSetActiveNavigationEntryTitleForUrl(mNativeTabAndroid, getNativePage().getUrl(), + getNativePage().getTitle()); + } + /** * Ensures the counter is at least as high as the specified value. The counter should always * point to an unused ID (which will be handed out next time a request comes in). Exposed so @@ -665,4 +679,6 @@ public abstract class TabBase implements NavigationClient { private native Profile nativeGetProfileAndroid(int nativeTabAndroid); private native void nativeLaunchBlockedPopups(int nativeTabAndroid); private native int nativeGetSecurityLevel(int nativeTabAndroid); + private native void nativeSetActiveNavigationEntryTitleForUrl(int nativeTabAndroid, String url, + String title); } |