Commit 7c8d964d authored by yusufo's avatar yusufo Committed by Commit bot

Use bounds instead of size for prerender requests

This changes the pipeline that initializes prerender contents
with a size to use bounds instead. Note that not all addPrerenderX
calls are switched to use Rect since for everywhere except Android
this won't be needed. Android needs bounds instead of size to get
info about the Physical Backing Size, also the top container height
(to be used for toolbar hide on scroll). With a Rect, all these can
be initialized and we can avoid extra Resizes that happen when the
native View is properly tied to the Android View hierarcy on swap.

This change only updates the params and shouldn't be making any
functional changes. A follow up Android only patch will start setting
the value to the origin.

BUG=628302

Review-Url: https://codereview.chromium.org/2259533003
Cr-Commit-Position: refs/heads/master@{#413469}
parent c09c6c48
......@@ -11,6 +11,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.AsyncTask;
......@@ -751,7 +752,8 @@ public class CustomTabsConnection {
}
if (referrer == null) referrer = "";
WebContents webContents = mExternalPrerenderHandler.addPrerender(
Profile.getLastUsedProfile(), url, referrer, contentSize.x, contentSize.y,
Profile.getLastUsedProfile(), url, referrer,
new Rect(0, 0, contentSize.x, contentSize.y),
shouldPrerenderOnCellularForSession(session));
if (webContents == null) return false;
if (throttle) mClientManager.registerPrerenderRequest(uid, url);
......
......@@ -8,6 +8,7 @@ import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.WindowManager;
import org.chromium.base.VisibleForTesting;
......@@ -38,17 +39,16 @@ public class ExternalPrerenderHandler {
* @param profile The profile to use for the prerender.
* @param url The url to prerender.
* @param referrer The referrer for the prerender request.
* @param width The width for the content view (render widget host view) for the prerender.
* @param height The height for the content view (render widget host view) for the prerender.
* @param bounds The bounds for the content view (render widget host view) for the prerender.
* @param prerenderOnCellular Whether the prerender should happen if the device has a cellular
* connection.
* @return The {@link WebContents} that is linked to this prerender. {@code null} if
* unsuccessful.
*/
public WebContents addPrerender(Profile profile, String url, String referrer, int width,
int height, boolean prerenderOnCellular) {
public WebContents addPrerender(Profile profile, String url, String referrer,
Rect bounds, boolean prerenderOnCellular) {
WebContents webContents = WebContentsFactory.createWebContents(false, false);
if (addPrerender(profile, webContents, url, referrer, width, height, prerenderOnCellular)) {
if (addPrerender(profile, webContents, url, referrer, bounds, prerenderOnCellular)) {
return webContents;
}
if (webContents != null) webContents.destroy();
......@@ -63,16 +63,16 @@ public class ExternalPrerenderHandler {
* @param webContents The WebContents to add the prerender to.
* @param url The url to prerender.
* @param referrer The referrer for the prerender request.
* @param width The width for the content view (render widget host view) for the prerender.
* @param height The height for the content view (render widget host view) for the prerender.
* @param bounds The bounds for the content view (render widget host view) for the prerender.
* @param prerenderOnCellular Whether the prerender should happen if the device has a cellular
* connection.
* @return Whether the prerender was successful.
*/
public boolean addPrerender(Profile profile, WebContents webContents, String url,
String referrer, int width, int height, boolean prerenderOnCellular) {
return nativeAddPrerender(mNativeExternalPrerenderHandler, profile, webContents,
url, referrer, width, height, prerenderOnCellular);
String referrer, Rect bounds, boolean prerenderOnCellular) {
return nativeAddPrerender(mNativeExternalPrerenderHandler, profile, webContents, url,
referrer, bounds.top, bounds.left, bounds.bottom, bounds.right,
prerenderOnCellular);
}
/**
......@@ -148,7 +148,7 @@ public class ExternalPrerenderHandler {
private static native boolean nativeAddPrerender(
long nativeExternalPrerenderHandlerAndroid, Profile profile,
WebContents webContents, String url, String referrer,
int width, int height, boolean prerenderOnCellular);
int top, int left, int bottom, int right, boolean prerenderOnCellular);
private static native boolean nativeHasPrerenderedUrl(
Profile profile, String url, WebContents webContents);
private static native boolean nativeHasPrerenderedAndFinishedLoadingUrl(
......
......@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.prerender;
import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_END_DEVICE;
import android.graphics.Rect;
import android.os.Environment;
import android.test.suitebuilder.annotation.SmallTest;
......@@ -114,7 +115,8 @@ public class ExternalPrerenderHandlerTest extends NativeLibraryTestBase {
@Override
public WebContents call() {
WebContents webContents =
mExternalPrerenderHandler.addPrerender(mProfile, url, "", 0, 0, false);
mExternalPrerenderHandler.addPrerender(
mProfile, url, "", new Rect(), false);
assertNotNull(webContents);
assertTrue(mExternalPrerenderHandler.hasPrerenderedUrl(
mProfile, url, webContents));
......
......@@ -31,7 +31,7 @@ class StubPrerenderContents : public PrerenderContents {
~StubPrerenderContents() override;
void StartPrerendering(
const gfx::Size& size,
const gfx::Rect& bounds,
content::SessionStorageNamespace* session_storage_namespace) override;
void ReportStartEvent() { NotifyPrerenderStart(); }
......@@ -53,7 +53,7 @@ StubPrerenderContents::StubPrerenderContents(
StubPrerenderContents::~StubPrerenderContents() {}
void StubPrerenderContents::StartPrerendering(
const gfx::Size& size,
const gfx::Rect& bounds,
content::SessionStorageNamespace* session_storage_namespace) {
prerendering_has_started_ = true;
}
......
......@@ -98,7 +98,8 @@ void OffscreenTab::Start(const GURL& start_url,
// Set initial size, if specified.
if (!initial_size.IsEmpty())
ResizeWebContents(offscreen_tab_web_contents_.get(), initial_size);
ResizeWebContents(offscreen_tab_web_contents_.get(),
gfx::Rect(initial_size));
// Mute audio output. When tab capture starts, the audio will be
// automatically unmuted, but will be captured into the MediaStream.
......@@ -227,7 +228,7 @@ void OffscreenTab::EnterFullscreenModeForTab(WebContents* contents,
contents->GetRenderWidgetHostView()->GetViewBounds().size();
if (contents->GetCapturerCount() >= 0 &&
!contents->GetPreferredSize().IsEmpty()) {
ResizeWebContents(contents, contents->GetPreferredSize());
ResizeWebContents(contents, gfx::Rect(contents->GetPreferredSize()));
}
}
......@@ -237,7 +238,7 @@ void OffscreenTab::ExitFullscreenModeForTab(WebContents* contents) {
if (!in_fullscreen_mode())
return;
ResizeWebContents(contents, non_fullscreen_size_);
ResizeWebContents(contents, gfx::Rect(non_fullscreen_size_));
non_fullscreen_size_ = gfx::Size();
}
......
......@@ -57,8 +57,10 @@ bool ExternalPrerenderHandlerAndroid::AddPrerender(
const JavaParamRef<jobject>& jweb_contents,
const JavaParamRef<jstring>& jurl,
const JavaParamRef<jstring>& jreferrer,
jint width,
jint height,
jint top,
jint left,
jint bottom,
jint right,
jboolean prerender_on_cellular) {
Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
......@@ -91,12 +93,12 @@ bool ExternalPrerenderHandlerAndroid::AddPrerender(
prerender_manager->AddPrerenderOnCellularFromExternalRequest(
url, referrer,
web_contents->GetController().GetDefaultSessionStorageNamespace(),
gfx::Size(width, height));
gfx::Rect(top, left, bottom, right));
} else {
prerender_handle_ = prerender_manager->AddPrerenderFromExternalRequest(
url, referrer,
web_contents->GetController().GetDefaultSessionStorageNamespace(),
gfx::Size(width, height));
gfx::Rect(top, left, bottom, right));
}
return !!prerender_handle_;
......
......@@ -35,8 +35,10 @@ class ExternalPrerenderHandlerAndroid {
const base::android::JavaParamRef<jobject>& jweb_contents,
const base::android::JavaParamRef<jstring>& url,
const base::android::JavaParamRef<jstring>& referrer,
jint width,
jint height,
jint top,
jint left,
jint bottom,
jint right,
jboolean prerender_on_cellular);
// Cancel the prerender associated with the prerender_handle_
......
......@@ -43,7 +43,7 @@
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/frame_navigate_params.h"
#include "ui/base/page_transition_types.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
using content::BrowserThread;
using content::DownloadItem;
......@@ -169,7 +169,7 @@ class PrerenderContents::WebContentsDelegateImpl
gfx::Size GetSizeForNewRenderView(WebContents* web_contents) const override {
// Have to set the size of the RenderView on initialization to be sure it is
// set before the RenderView is hidden on all platforms (esp. Android).
return prerender_contents_->size_;
return prerender_contents_->bounds_.size();
}
private:
......@@ -235,17 +235,16 @@ PrerenderContents* PrerenderContents::FromWebContents(
}
void PrerenderContents::StartPrerendering(
const gfx::Size& size,
const gfx::Rect& bounds,
SessionStorageNamespace* session_storage_namespace) {
DCHECK(profile_);
DCHECK(!size.IsEmpty());
DCHECK(!bounds.IsEmpty());
DCHECK(!prerendering_has_started_);
DCHECK(!prerender_contents_);
DCHECK(size_.IsEmpty());
DCHECK_EQ(1U, alias_urls_.size());
session_storage_namespace_id_ = session_storage_namespace->id();
size_ = size;
bounds_ = bounds;
DCHECK(load_start_time_.is_null());
load_start_time_ = base::TimeTicks::Now();
......@@ -270,7 +269,7 @@ void PrerenderContents::StartPrerendering(
web_contents_delegate_.reset(new WebContentsDelegateImpl(this));
prerender_contents_.get()->SetDelegate(web_contents_delegate_.get());
// Set the size of the prerender WebContents.
ResizeWebContents(prerender_contents_.get(), size_);
ResizeWebContents(prerender_contents_.get(), bounds_);
// TODO(davidben): This logic assumes each prerender has at most one
// route. https://crbug.com/440544
......
......@@ -23,7 +23,7 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/referrer.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/rect.h"
class Profile;
......@@ -110,12 +110,12 @@ class PrerenderContents : public content::NotificationObserver,
// Start rendering the contents in the prerendered state. If
// |is_control_group| is true, this will go through some of the mechanics of
// starting a prerender, without actually creating the RenderView. |size|
// indicates the rectangular dimensions that the prerendered page should be.
// starting a prerender, without actually creating the RenderView. |bounds|
// indicates the rectangle that the prerendered page should be in.
// |session_storage_namespace| indicates the namespace that the prerendered
// page should be part of.
virtual void StartPrerendering(
const gfx::Size& size,
const gfx::Rect& bounds,
content::SessionStorageNamespace* session_storage_namespace);
// Verifies that the prerendering is not using too many resources, and kills
......@@ -343,8 +343,8 @@ class PrerenderContents : public content::NotificationObserver,
// Origin for this prerender.
Origin origin_;
// The size of the WebView from the launching page.
gfx::Size size_;
// The bounds of the WebView from the launching page.
gfx::Rect bounds_;
typedef std::vector<history::HistoryAddPageArgs> AddPageVector;
......
......@@ -59,6 +59,7 @@
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "ui/gfx/geometry/rect.h"
using content::BrowserThread;
using content::RenderViewHost;
......@@ -235,8 +236,8 @@ PrerenderManager::AddPrerenderFromLinkRelPrerender(
source_web_contents->GetController()
.GetDefaultSessionStorageNamespace();
}
return AddPrerender(origin, url, referrer, size, session_storage_namespace);
return AddPrerender(
origin, url, referrer, gfx::Rect(size), session_storage_namespace);
}
std::unique_ptr<PrerenderHandle> PrerenderManager::AddPrerenderFromOmnibox(
......@@ -245,7 +246,7 @@ std::unique_ptr<PrerenderHandle> PrerenderManager::AddPrerenderFromOmnibox(
const gfx::Size& size) {
if (!IsOmniboxEnabled(profile_))
return nullptr;
return AddPrerender(ORIGIN_OMNIBOX, url, content::Referrer(), size,
return AddPrerender(ORIGIN_OMNIBOX, url, content::Referrer(), gfx::Rect(size),
session_storage_namespace);
}
......@@ -254,9 +255,9 @@ PrerenderManager::AddPrerenderFromExternalRequest(
const GURL& url,
const content::Referrer& referrer,
SessionStorageNamespace* session_storage_namespace,
const gfx::Size& size) {
return AddPrerender(
ORIGIN_EXTERNAL_REQUEST, url, referrer, size, session_storage_namespace);
const gfx::Rect& bounds) {
return AddPrerender(ORIGIN_EXTERNAL_REQUEST, url, referrer,
bounds, session_storage_namespace);
}
std::unique_ptr<PrerenderHandle>
......@@ -264,11 +265,11 @@ PrerenderManager::AddPrerenderOnCellularFromExternalRequest(
const GURL& url,
const content::Referrer& referrer,
SessionStorageNamespace* session_storage_namespace,
const gfx::Size& size) {
const gfx::Rect& bounds) {
return AddPrerender(ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR,
url,
referrer,
size,
bounds,
session_storage_namespace);
}
......@@ -276,7 +277,7 @@ std::unique_ptr<PrerenderHandle> PrerenderManager::AddPrerenderForInstant(
const GURL& url,
content::SessionStorageNamespace* session_storage_namespace,
const gfx::Size& size) {
return AddPrerender(ORIGIN_INSTANT, url, content::Referrer(), size,
return AddPrerender(ORIGIN_INSTANT, url, content::Referrer(), gfx::Rect(size),
session_storage_namespace);
}
......@@ -284,7 +285,7 @@ std::unique_ptr<PrerenderHandle> PrerenderManager::AddPrerenderForOffline(
const GURL& url,
content::SessionStorageNamespace* session_storage_namespace,
const gfx::Size& size) {
return AddPrerender(ORIGIN_OFFLINE, url, content::Referrer(), size,
return AddPrerender(ORIGIN_OFFLINE, url, content::Referrer(), gfx::Rect(size),
session_storage_namespace);
}
......@@ -853,7 +854,7 @@ std::unique_ptr<PrerenderHandle> PrerenderManager::AddPrerender(
Origin origin,
const GURL& url_arg,
const content::Referrer& referrer,
const gfx::Size& size,
const gfx::Rect& bounds,
SessionStorageNamespace* session_storage_namespace) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......@@ -954,10 +955,10 @@ std::unique_ptr<PrerenderHandle> PrerenderManager::AddPrerender(
last_prerender_start_time_ = GetCurrentTimeTicks();
gfx::Size contents_size =
size.IsEmpty() ? config_.default_tab_bounds.size() : size;
gfx::Rect contents_bounds =
bounds.IsEmpty() ? config_.default_tab_bounds : bounds;
prerender_contents_ptr->StartPrerendering(contents_size,
prerender_contents_ptr->StartPrerendering(contents_bounds,
session_storage_namespace);
DCHECK(IsControlGroup() ||
......
......@@ -50,6 +50,7 @@ class WebContents;
}
namespace gfx {
class Rect;
class Size;
}
......@@ -131,7 +132,7 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
const GURL& url,
const content::Referrer& referrer,
content::SessionStorageNamespace* session_storage_namespace,
const gfx::Size& size);
const gfx::Rect& bounds);
// Adds a prerender from an external request that will prerender even on
// cellular networks as long as the user setting for prerendering is ON.
......@@ -139,7 +140,7 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
const GURL& url,
const content::Referrer& referrer,
content::SessionStorageNamespace* session_storage_namespace,
const gfx::Size& size);
const gfx::Rect& bounds);
// Adds a prerender for Instant Search |url| if valid. The
// |session_storage_namespace| matches the namespace of the active tab at the
......@@ -413,14 +414,14 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
Origin origin) const;
// Adds a prerender for |url| from |referrer|. The |origin| specifies how the
// prerender was added. If |size| is empty, then
// prerender was added. If |bounds| is empty, then
// PrerenderContents::StartPrerendering will instead use a default from
// PrerenderConfig. Returns a PrerenderHandle or NULL.
std::unique_ptr<PrerenderHandle> AddPrerender(
Origin origin,
const GURL& url,
const content::Referrer& referrer,
const gfx::Size& size,
const gfx::Rect& bounds,
content::SessionStorageNamespace* session_storage_namespace);
void StartSchedulingPeriodicCleanups();
......
......@@ -34,6 +34,7 @@
#include "content/public/test/test_browser_thread.h"
#include "net/base/network_change_notifier.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
......@@ -59,7 +60,7 @@ class DummyPrerenderContents : public PrerenderContents {
~DummyPrerenderContents() override;
void StartPrerendering(
const gfx::Size& size,
const gfx::Rect& bounds,
content::SessionStorageNamespace* session_storage_namespace) override;
bool GetChildId(int* child_id) const override {
......@@ -291,7 +292,7 @@ DummyPrerenderContents::~DummyPrerenderContents() {
}
void DummyPrerenderContents::StartPrerendering(
const gfx::Size& size,
const gfx::Rect& bounds,
content::SessionStorageNamespace* session_storage_namespace) {
// In the base PrerenderContents implementation, StartPrerendering will
// be called even when the PrerenderManager is part of the control group,
......@@ -1098,7 +1099,7 @@ TEST_F(PrerenderTest, PrerenderNotAllowedOnCellularWithExternalOrigin) {
FINAL_STATUS_MANAGER_SHUTDOWN);
std::unique_ptr<PrerenderHandle> prerender_handle(
prerender_manager()->AddPrerenderFromExternalRequest(
url, content::Referrer(), nullptr, kSize));
url, content::Referrer(), nullptr, gfx::Rect(kSize)));
EXPECT_FALSE(prerender_handle);
EXPECT_FALSE(prerender_contents->prerendering_has_started());
}
......@@ -1128,7 +1129,7 @@ TEST_F(PrerenderTest, PrerenderAllowedForOfflineAndForcedCellular) {
url, origin, FINAL_STATUS_USED);
prerender_handle =
prerender_manager()->AddPrerenderOnCellularFromExternalRequest(
url, content::Referrer(), nullptr, kSize);
url, content::Referrer(), nullptr, gfx::Rect(kSize));
}
EXPECT_TRUE(prerender_handle);
EXPECT_TRUE(prerender_handle->IsPrerendering());
......
......@@ -216,7 +216,7 @@ void ChromeAppDelegate::RenderViewCreated(
void ChromeAppDelegate::ResizeWebContents(content::WebContents* web_contents,
const gfx::Size& size) {
::ResizeWebContents(web_contents, size);
::ResizeWebContents(web_contents, gfx::Rect(size));
}
content::WebContents* ChromeAppDelegate::OpenURLFromTab(
......
......@@ -128,7 +128,7 @@ content::WebContents* AddRestoredTab(
// yet and the bounds may not be available on all platforms.
if (size.IsEmpty())
size = browser->window()->GetRestoredBounds().size();
ResizeWebContents(web_contents, size);
ResizeWebContents(web_contents, gfx::Rect(size));
web_contents->WasHidden();
}
SessionService* session_service =
......
......@@ -232,7 +232,7 @@ void FullscreenController::OnTabDetachedFromView(WebContents* old_contents) {
old_contents->GetFullscreenRenderWidgetHostView();
if (current_fs_view)
current_fs_view->SetSize(old_contents->GetPreferredSize());
ResizeWebContents(old_contents, old_contents->GetPreferredSize());
ResizeWebContents(old_contents, gfx::Rect(old_contents->GetPreferredSize()));
}
void FullscreenController::OnTabClosing(WebContents* web_contents) {
......
......@@ -64,7 +64,7 @@ class DummyPrerenderContents : public PrerenderContents {
bool call_did_finish_load);
void StartPrerendering(
const gfx::Size& size,
const gfx::Rect& bounds,
content::SessionStorageNamespace* session_storage_namespace) override;
bool GetChildId(int* child_id) const override;
bool GetRouteId(int* route_id) const override;
......@@ -110,7 +110,7 @@ DummyPrerenderContents::DummyPrerenderContents(
}
void DummyPrerenderContents::StartPrerendering(
const gfx::Size& size,
const gfx::Rect& bounds,
content::SessionStorageNamespace* session_storage_namespace) {
content::SessionStorageNamespaceMap session_storage_namespace_map;
session_storage_namespace_map[std::string()] = session_storage_namespace;
......
......@@ -793,7 +793,8 @@ void TabStripModel::AddWebContents(WebContents* contents,
// new background tab.
if (WebContents* old_contents = GetActiveWebContents()) {
if ((add_types & ADD_ACTIVE) == 0) {
ResizeWebContents(contents, old_contents->GetContainerBounds().size());
ResizeWebContents(
contents, gfx::Rect(old_contents->GetContainerBounds().size()));
}
}
}
......
......@@ -14,13 +14,13 @@
#endif
void ResizeWebContents(content::WebContents* web_contents,
const gfx::Size& new_size) {
const gfx::Rect& new_bounds) {
#if defined(USE_AURA)
aura::Window* window = web_contents->GetNativeView();
window->SetBounds(gfx::Rect(window->bounds().origin(), new_size));
window->SetBounds(gfx::Rect(window->bounds().origin(), new_bounds.size()));
#elif defined(OS_ANDROID)
content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView();
if (view)
view->SetSize(new_size);
view->SetSize(new_bounds.size());
#endif
}
......@@ -10,12 +10,11 @@ class WebContents;
}
namespace gfx {
class Size;
class Rect;
}
// A platform-agnostic function to resize a WebContents. The top-left corner of
// the WebContents does not move during the resizing.
// A platform-agnostic function to resize a WebContents.
void ResizeWebContents(content::WebContents* web_contents,
const gfx::Size& size);
const gfx::Rect& bounds);
#endif // CHROME_BROWSER_UI_WEB_CONTENTS_SIZER_H_
......@@ -9,13 +9,16 @@
#include "content/public/browser/web_contents.h"
void ResizeWebContents(content::WebContents* web_contents,
const gfx::Size& new_size) {
const gfx::Rect& new_bounds) {
NSView* view = web_contents->GetNativeView();
NSRect old_wcv_frame = [view frame];
CGFloat new_x = old_wcv_frame.origin.x;
CGFloat new_y =
old_wcv_frame.origin.y + (old_wcv_frame.size.height - new_size.height());
old_wcv_frame.origin.y
+ (old_wcv_frame.size.height - new_bounds.size().height());
NSRect new_wcv_frame =
NSMakeRect(new_x, new_y, new_size.width(), new_size.height());
NSMakeRect(new_x, new_y,
new_bounds.size().width(),
new_bounds.size().height());
[view setFrame:new_wcv_frame];
}
......@@ -114,7 +114,7 @@ void ExtensionSettingsUIBrowserTest::ShrinkWebContentsView() {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
CHECK(web_contents);
ResizeWebContents(web_contents, gfx::Size(400, 400));
ResizeWebContents(web_contents, gfx::Rect(0, 0, 400, 400));
}
const Extension* ExtensionSettingsUIBrowserTest::InstallUnpackedExtension(
......
......@@ -4,6 +4,8 @@
package org.chromium.chrome.test.util;
import android.graphics.Rect;
import junit.framework.Assert;
import org.chromium.base.ThreadUtils;
......@@ -92,13 +94,14 @@ public class PrerenderTestHelper {
@Override
public ExternalPrerenderHandler call() throws Exception {
ExternalPrerenderHandler prerenderHandler = new ExternalPrerenderHandler();
boolean didPrerender = prerenderHandler.addPrerender(
currentTab.getProfile(), currentTab.getWebContents(), testUrl, null,
currentTab.getContentViewCore().getRenderCoordinates()
Rect bounds = new Rect(
0, 0, currentTab.getContentViewCore().getRenderCoordinates()
.getContentWidthPixInt(),
currentTab.getContentViewCore().getRenderCoordinates()
.getContentHeightPixInt(),
false);
.getContentHeightPixInt());
boolean didPrerender = prerenderHandler.addPrerender(
currentTab.getProfile(), currentTab.getWebContents(), testUrl, null,
bounds, false);
Assert.assertTrue("Failed to prerender test url: " + testUrl, didPrerender);
return prerenderHandler;
}
......
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