Commit e17c0386 authored by Christian O. Andersson's avatar Christian O. Andersson Committed by Commit Bot

Replaced 'Should' with 'Will' per Android API council guidance

See https://crrev.com/c/1185001 for details

Design doc: https://docs.google.com/document/d/188BbgvTdhKf8bXikCL-JMduEclJOd9GxhKu79hmSVdo/edit

Test: run_webview_instrumentation_test_apk -f AwSettingsTest#testWillSuppressErrorPage
Change-Id: I71603bf906b58c9c42cb06ecf1abcee10360d5cb
Reviewed-on: https://chromium-review.googlesource.com/c/1482900
Auto-Submit: Christian O. Andersson <cricke@chromium.org>
Reviewed-by: default avatarTobias Sargeant <tobiasjs@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634775}
parent 0b3114da
......@@ -142,7 +142,7 @@ void AwSettings::UpdateEverythingLocked(JNIEnv* env,
UpdateFormDataPreferencesLocked(env, obj);
UpdateRendererPreferencesLocked(env, obj);
UpdateOffscreenPreRasterLocked(env, obj);
UpdateShouldSuppressErrorStateLocked(env, obj);
UpdateWillSuppressErrorStateLocked(env, obj);
}
void AwSettings::UpdateUserAgentLocked(JNIEnv* env,
......@@ -198,15 +198,15 @@ void AwSettings::UpdateInitialPageScaleLocked(
}
}
void AwSettings::UpdateShouldSuppressErrorStateLocked(
void AwSettings::UpdateWillSuppressErrorStateLocked(
JNIEnv* env,
const JavaParamRef<jobject>& obj) {
AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt();
if (!rvhe)
return;
bool suppress = Java_AwSettings_getShouldSuppressErrorPageLocked(env, obj);
rvhe->SetShouldSuppressErrorPage(suppress);
bool suppress = Java_AwSettings_getWillSuppressErrorPageLocked(env, obj);
rvhe->SetWillSuppressErrorPage(suppress);
}
void AwSettings::UpdateFormDataPreferencesLocked(
......
......@@ -51,7 +51,7 @@ class AwSettings : public content::WebContentsObserver {
void UpdateInitialPageScaleLocked(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
void UpdateShouldSuppressErrorStateLocked(
void UpdateWillSuppressErrorStateLocked(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
void UpdateUserAgentLocked(JNIEnv* env,
......
......@@ -117,15 +117,15 @@ void AwRenderViewHostExt::SetBackgroundColor(SkColor c) {
}
}
void AwRenderViewHostExt::SetShouldSuppressErrorPage(bool suppress) {
void AwRenderViewHostExt::SetWillSuppressErrorPage(bool suppress) {
// We need to store state on the browser-side, as state might need to be
// synchronized again later (see AwRenderViewHostExt::RenderFrameCreated)
if (should_suppress_error_page_ == suppress)
if (will_suppress_error_page_ == suppress)
return;
should_suppress_error_page_ = suppress;
will_suppress_error_page_ = suppress;
web_contents()->SendToAllFrames(new AwViewMsg_ShouldSuppressErrorPage(
MSG_ROUTING_NONE, should_suppress_error_page_));
web_contents()->SendToAllFrames(new AwViewMsg_WillSuppressErrorPage(
MSG_ROUTING_NONE, will_suppress_error_page_));
}
void AwRenderViewHostExt::SetJsOnlineProperty(bool network_up) {
......@@ -170,8 +170,8 @@ void AwRenderViewHostExt::RenderFrameCreated(
// it) because for cross-origin navigations in multi-process mode, the
// navigation will already have started then. Also, newly created subframes
// need to inherit the state.
frame_host->Send(new AwViewMsg_ShouldSuppressErrorPage(
frame_host->GetRoutingID(), should_suppress_error_page_));
frame_host->Send(new AwViewMsg_WillSuppressErrorPage(
frame_host->GetRoutingID(), will_suppress_error_page_));
}
void AwRenderViewHostExt::DidFinishNavigation(
......
......@@ -75,7 +75,7 @@ class AwRenderViewHostExt : public content::WebContentsObserver {
// the meta viewport tag.
void SetInitialPageScale(double page_scale_factor);
void SetBackgroundColor(SkColor c);
void SetShouldSuppressErrorPage(bool suppress);
void SetWillSuppressErrorPage(bool suppress);
void SetJsOnlineProperty(bool network_up);
void SmoothScroll(int target_x, int target_y, long duration_ms);
......@@ -124,7 +124,7 @@ class AwRenderViewHostExt : public content::WebContentsObserver {
service_manager::BinderRegistry registry_;
// Some WebView users might want to show their own error pages / logic.
bool should_suppress_error_page_ = false;
bool will_suppress_error_page_ = false;
SEQUENCE_CHECKER(sequence_checker_);
......
......@@ -89,8 +89,8 @@ IPC_MESSAGE_ROUTED3(AwViewMsg_SmoothScroll,
// Sent to inform renderers whether the internal error page should be shown or
// not.
IPC_MESSAGE_ROUTED1(AwViewMsg_ShouldSuppressErrorPage,
bool /* should_suppress_error_page */)
IPC_MESSAGE_ROUTED1(AwViewMsg_WillSuppressErrorPage,
bool /* will_suppress_error_page */)
//-----------------------------------------------------------------------------
// RenderView messages
......
......@@ -112,7 +112,7 @@ public class AwSettings {
private int mMixedContentMode = WebSettings.MIXED_CONTENT_NEVER_ALLOW;
private boolean mCSSHexAlphaColorEnabled;
private boolean mScrollTopLeftInteropEnabled;
private boolean mShouldSuppressErrorPage;
private boolean mWillSuppressErrorPage;
private boolean mOffscreenPreRaster;
private int mDisabledMenuItems = WebSettings.MENU_ITEM_NONE;
......@@ -1257,31 +1257,31 @@ public class AwSettings {
}
@CalledByNative
private boolean getShouldSuppressErrorPageLocked() {
private boolean getWillSuppressErrorPageLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mShouldSuppressErrorPage;
return mWillSuppressErrorPage;
}
public boolean getShouldSuppressErrorPage() {
public boolean getWillSuppressErrorPage() {
synchronized (mAwSettingsLock) {
return getShouldSuppressErrorPageLocked();
return getWillSuppressErrorPageLocked();
}
}
public void setShouldSuppressErrorPage(boolean suppressed) {
public void setWillSuppressErrorPage(boolean suppressed) {
synchronized (mAwSettingsLock) {
if (mShouldSuppressErrorPage == suppressed) return;
if (mWillSuppressErrorPage == suppressed) return;
mShouldSuppressErrorPage = suppressed;
updateShouldSuppressErrorStateLocked();
mWillSuppressErrorPage = suppressed;
updateWillSuppressErrorStateLocked();
}
}
private void updateShouldSuppressErrorStateLocked() {
private void updateWillSuppressErrorStateLocked() {
mEventHandler.runOnUiThreadBlockingAndLocked(() -> {
assert Thread.holdsLock(mAwSettingsLock);
assert mNativeAwSettings != 0;
nativeUpdateShouldSuppressErrorStateLocked(mNativeAwSettings);
nativeUpdateWillSuppressErrorStateLocked(mNativeAwSettings);
});
}
......@@ -1851,5 +1851,5 @@ public class AwSettings {
private native void nativeUpdateOffscreenPreRasterLocked(long nativeAwSettings);
private native void nativeUpdateShouldSuppressErrorStateLocked(long nativeAwSettings);
private native void nativeUpdateWillSuppressErrorStateLocked(long nativeAwSettings);
}
......@@ -1464,13 +1464,13 @@ public class AwSettingsTest {
}
}
class AwSettingsShouldSuppressErrorPageTestHelper extends AwSettingsTestHelper<Boolean> {
class AwSettingsWillSuppressErrorPageTestHelper extends AwSettingsTestHelper<Boolean> {
private static final String BAD_SCHEME_URL = "htt://nonsense";
private static final String PREV_TITLE = "cuencpobgjhfdmdovhmfdkjf";
private static final int MAX_TIME_LOADING_ERROR_PAGE = 1000;
private final AwContents mAwContents;
AwSettingsShouldSuppressErrorPageTestHelper(AwTestContainerView containerView,
AwSettingsWillSuppressErrorPageTestHelper(AwTestContainerView containerView,
TestAwContentsClient contentViewClient) throws Throwable {
super(containerView, contentViewClient, true);
mAwContents = containerView.getAwContents();
......@@ -1488,12 +1488,12 @@ public class AwSettingsTest {
@Override
protected Boolean getCurrentValue() {
return mAwSettings.getShouldSuppressErrorPage();
return mAwSettings.getWillSuppressErrorPage();
}
@Override
protected void setCurrentValue(Boolean value) {
mAwSettings.setShouldSuppressErrorPage(value);
mAwSettings.setWillSuppressErrorPage(value);
}
@Override
......@@ -1516,7 +1516,7 @@ public class AwSettingsTest {
// Verify the state in settings reflect what we expect
AwSettings settings = mActivityTestRule.getAwSettingsOnUiThread(mAwContents);
Assert.assertEquals(value, settings.getShouldSuppressErrorPage());
Assert.assertEquals(value, settings.getWillSuppressErrorPage());
// Verify the error page is shown / suppressed
if (value == DISABLED) {
......@@ -1725,11 +1725,11 @@ public class AwSettingsTest {
@Test
@MediumTest
@Feature({"AndroidWebView", "Preferences"})
public void testShouldSuppressErrorPage() throws Throwable {
public void testWillSuppressErrorPage() throws Throwable {
ViewPair views = createViews();
runPerViewSettingsTest(new AwSettingsShouldSuppressErrorPageTestHelper(
runPerViewSettingsTest(new AwSettingsWillSuppressErrorPageTestHelper(
views.getContainer0(), views.getClient0()),
new AwSettingsShouldSuppressErrorPageTestHelper(
new AwSettingsWillSuppressErrorPageTestHelper(
views.getContainer1(), views.getClient1()));
}
......
......@@ -201,7 +201,7 @@ bool AwContentRendererClient::ShouldSuppressErrorPage(
if (render_frame_ext == nullptr)
return false;
return render_frame_ext->GetShouldSuppressErrorPage();
return render_frame_ext->GetWillSuppressErrorPage();
}
void AwContentRendererClient::PrepareErrorPage(
......
......@@ -230,8 +230,8 @@ bool AwRenderFrameExt::OnMessageReceived(const IPC::Message& message) {
OnResetScrollAndScaleState)
IPC_MESSAGE_HANDLER(AwViewMsg_SetInitialPageScale, OnSetInitialPageScale)
IPC_MESSAGE_HANDLER(AwViewMsg_SetBackgroundColor, OnSetBackgroundColor)
IPC_MESSAGE_HANDLER(AwViewMsg_ShouldSuppressErrorPage,
OnSetShouldSuppressErrorPage)
IPC_MESSAGE_HANDLER(AwViewMsg_WillSuppressErrorPage,
OnSetWillSuppressErrorPage)
IPC_MESSAGE_HANDLER(AwViewMsg_SmoothScroll, OnSmoothScroll)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
......@@ -347,12 +347,12 @@ void AwRenderFrameExt::OnSmoothScroll(int target_x,
webview->SmoothScroll(target_x, target_y, static_cast<long>(duration_ms));
}
void AwRenderFrameExt::OnSetShouldSuppressErrorPage(bool suppress) {
this->should_suppress_error_page_ = suppress;
void AwRenderFrameExt::OnSetWillSuppressErrorPage(bool suppress) {
this->will_suppress_error_page_ = suppress;
}
bool AwRenderFrameExt::GetShouldSuppressErrorPage() {
return this->should_suppress_error_page_;
bool AwRenderFrameExt::GetWillSuppressErrorPage() {
return this->will_suppress_error_page_;
}
blink::WebView* AwRenderFrameExt::GetWebView() {
......
......@@ -31,7 +31,7 @@ class AwRenderFrameExt : public content::RenderFrameObserver {
static AwRenderFrameExt* FromRenderFrame(content::RenderFrame* render_frame);
bool GetShouldSuppressErrorPage();
bool GetWillSuppressErrorPage();
private:
~AwRenderFrameExt() override;
......@@ -61,7 +61,7 @@ class AwRenderFrameExt : public content::RenderFrameObserver {
void OnSmoothScroll(int target_x, int target_y, int duration_ms);
void OnSetShouldSuppressErrorPage(bool suppress);
void OnSetWillSuppressErrorPage(bool suppress);
blink::WebView* GetWebView();
blink::WebFrameWidget* GetWebFrameWidget();
......@@ -71,7 +71,7 @@ class AwRenderFrameExt : public content::RenderFrameObserver {
blink::AssociatedInterfaceRegistry registry_;
// Some WebView users might want to show their own error pages / logic
bool should_suppress_error_page_ = false;
bool will_suppress_error_page_ = false;
DISALLOW_COPY_AND_ASSIGN(AwRenderFrameExt);
};
......
......@@ -21,6 +21,6 @@ public interface WebSettingsBoundaryInterface {
void setDisabledActionModeMenuItems(int menuItems);
int getDisabledActionModeMenuItems();
void setShouldSuppressErrorPage(boolean suppressed);
boolean getShouldSuppressErrorPage();
void setWillSuppressErrorPage(boolean suppressed);
boolean getWillSuppressErrorPage();
}
......@@ -132,8 +132,8 @@ public class Features {
// ProxyController.clearProxyOverride
public static final String PROXY_OVERRIDE = "PROXY_OVERRIDE:3";
// WebSettingsCompat.setShouldSuppressErrorPage
// WebSettingsCompat.getShouldSuppressErrorPage
// WebSettingsCompat.setWillSuppressErrorPage
// WebSettingsCompat.getWillSuppressErrorPage
public static final String SUPPRESS_ERROR_PAGE = "SUPPRESS_ERROR_PAGE";
// WebViewCompat.getWebViewRenderer
......
......@@ -48,12 +48,12 @@ class SupportLibWebSettingsAdapter implements WebSettingsBoundaryInterface {
}
@Override
public boolean getShouldSuppressErrorPage() {
return mAwSettings.getShouldSuppressErrorPage();
public boolean getWillSuppressErrorPage() {
return mAwSettings.getWillSuppressErrorPage();
}
@Override
public void setShouldSuppressErrorPage(boolean suppressed) {
mAwSettings.setShouldSuppressErrorPage(suppressed);
public void setWillSuppressErrorPage(boolean suppressed) {
mAwSettings.setWillSuppressErrorPage(suppressed);
}
}
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