Commit 7e87c78e authored by newt@chromium.org's avatar newt@chromium.org

Remove PageInfo interface.

BUG=367231
NOTRY=true

Review URL: https://codereview.chromium.org/250923008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267033 0039d316-1c4b-4281-b951-d872f2087c98
parent 5704325b
......@@ -5,13 +5,22 @@
package org.chromium.chrome.browser;
import android.graphics.Bitmap;
import org.chromium.content.browser.PageInfo;
import android.view.View;
/**
* An interface for pages that will be shown in a tab using Android views instead of html.
*/
public interface NativePage extends PageInfo {
public interface NativePage {
/**
* @return The View to display the page. This is always non-null.
*/
View getView();
/**
* @return The title of the page.
*/
String getTitle();
/**
* @return The URL of the page.
*/
......@@ -23,15 +32,20 @@ public interface NativePage extends PageInfo {
public String getHost();
/**
* Called after a page has been removed from the view hierarchy and will no longer be used.
* @return The background color of the page.
*/
public void destroy();
int getBackgroundColor();
/**
* Updates the native page based on the given url.
*/
public void updateForUrl(String url);
/**
* Called after a page has been removed from the view hierarchy and will no longer be used.
*/
public void destroy();
/**
* @return An unscaled screenshot of the page.
*/
......
......@@ -32,7 +32,6 @@ import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.LoadUrlParams;
import org.chromium.content.browser.NavigationClient;
import org.chromium.content.browser.NavigationHistory;
import org.chromium.content.browser.PageInfo;
import org.chromium.content.browser.WebContentsObserverAndroid;
import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.Clipboard;
......@@ -453,8 +452,7 @@ public class Tab implements NavigationClient {
* be {@code null}, if the tab is frozen or being initialized or destroyed.
*/
public View getView() {
PageInfo pageInfo = getPageInfo();
return pageInfo != null ? pageInfo.getView() : null;
return mNativePage != null ? mNativePage.getView() : mContentView;
}
/**
......@@ -535,7 +533,9 @@ public class Tab implements NavigationClient {
* @return The background color of the tab.
*/
public int getBackgroundColor() {
return getPageInfo() != null ? getPageInfo().getBackgroundColor() : Color.WHITE;
if (mNativePage != null) return mNativePage.getBackgroundColor();
if (mContentViewCore != null) return mContentViewCore.getBackgroundColor();
return Color.WHITE;
}
/**
......@@ -589,14 +589,6 @@ public class Tab implements NavigationClient {
return mNativePage == null ? mContentViewCore : null;
}
/**
* @return A {@link PageInfo} describing the current page. This is always not {@code null}
* except during initialization, destruction, and when the tab is frozen.
*/
public PageInfo getPageInfo() {
return mNativePage != null ? mNativePage : mContentView;
}
/**
* @return The {@link NativePage} associated with the current page, or {@code null} if there is
* no current page or the current page is displayed using something besides
......@@ -768,7 +760,7 @@ public class Tab implements NavigationClient {
/**
* Completes the {@link ContentView} specific initialization around a native WebContents
* pointer. {@link #getPageInfo()} will still return the {@link NativePage} if there is one.
* pointer. {@link #getNativePage()} will still return the {@link NativePage} if there is one.
* All initialization that needs to reoccur after a web contents swap should be added here.
* <p />
* NOTE: If you attempt to pass a native WebContents that does not have the same incognito
......@@ -868,7 +860,9 @@ public class Tab implements NavigationClient {
*/
@CalledByNative
public String getTitle() {
return getPageInfo() != null ? getPageInfo().getTitle() : "";
if (mNativePage != null) return mNativePage.getTitle();
if (mContentViewCore != null) return mContentViewCore.getTitle();
return "";
}
/**
......@@ -929,7 +923,7 @@ public class Tab implements NavigationClient {
private void destroyNativePageInternal(NativePage nativePage) {
if (nativePage == null) return;
assert getPageInfo() != nativePage : "Attempting to destroy active page.";
assert nativePage != mNativePage : "Attempting to destroy active page.";
nativePage.destroy();
}
......
......@@ -206,7 +206,7 @@ public class ContextMenuTest extends ChromeShellTestBase {
assertNotNull("Context menu was not properly created", menu);
assertFalse("Context menu did not have window focus", getActivity().hasWindowFocus());
TestTouchUtils.singleClickView(getInstrumentation(), tab.getPageInfo().getView(), 0, 0);
TestTouchUtils.singleClickView(getInstrumentation(), tab.getView(), 0, 0);
Assert.assertTrue("Activity did not regain focus.",
CriteriaHelper.pollForCriteria(new Criteria() {
......
......@@ -29,7 +29,7 @@ import org.chromium.ui.base.WindowAndroid;
* compatibility.
*/
public class ContentView extends FrameLayout
implements ContentViewCore.InternalAccessDelegate, PageInfo {
implements ContentViewCore.InternalAccessDelegate {
private final ContentViewCore mContentViewCore;
......@@ -67,23 +67,6 @@ public class ContentView extends FrameLayout
mContentViewCore.initialize(this, this, nativeWebContents, windowAndroid);
}
// PageInfo implementation.
@Override
public String getTitle() {
return mContentViewCore.getTitle();
}
@Override
public int getBackgroundColor() {
return mContentViewCore.getBackgroundColor();
}
@Override
public View getView() {
return this;
}
/**
* @return The core component of the ContentView that handles JNI communication. Should only be
* used for passing to native.
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.content.browser;
import android.view.View;
/**
* A minimal interface for a View to implement to be shown in a Tab. The main implementation of
* this is ContentView but other Views can also implement this, enabling them to be shown in a Tab
* as well.
*/
public interface PageInfo {
/**
* @return The title of the page.
*/
String getTitle();
/**
* @return The background color of the page.
*/
int getBackgroundColor();
/**
* @return The View to display the page. This is always non-null.
*/
View getView();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment