Commit a6b91467 authored by tyoshino's avatar tyoshino Committed by Commit bot

Rename setAlwaysAcceptCookies to setBlockThirdPartyCookies

Giving more descriptive name.

BUG=624711
R=mkwst,rdsmith,clamy

Review-Url: https://codereview.chromium.org/2125523003
Cr-Commit-Position: refs/heads/master@{#404620}
parent 235b8cbc
......@@ -197,7 +197,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
void SetAllowRunningOfInsecureContent(bool allowed);
void SetAutoplayAllowed(bool allowed);
void SetAllowUniversalAccessFromFileURLs(bool allow);
void SetAlwaysAcceptCookies(bool accept);
void SetBlockThirdPartyCookies(bool block);
void SetAudioData(const gin::ArrayBufferView& view);
void SetBackingScaleFactor(double value, v8::Local<v8::Function> callback);
void SetBluetoothFakeAdapter(const std::string& adapter_name,
......@@ -492,8 +492,8 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
.SetMethod("setAutoplayAllowed", &TestRunnerBindings::SetAutoplayAllowed)
.SetMethod("setAllowUniversalAccessFromFileURLs",
&TestRunnerBindings::SetAllowUniversalAccessFromFileURLs)
.SetMethod("setAlwaysAcceptCookies",
&TestRunnerBindings::SetAlwaysAcceptCookies)
.SetMethod("setBlockThirdPartyCookies",
&TestRunnerBindings::SetBlockThirdPartyCookies)
.SetMethod("setAudioData", &TestRunnerBindings::SetAudioData)
.SetMethod("setBackingScaleFactor",
&TestRunnerBindings::SetBackingScaleFactor)
......@@ -1264,9 +1264,9 @@ void TestRunnerBindings::SetDatabaseQuota(int quota) {
runner_->SetDatabaseQuota(quota);
}
void TestRunnerBindings::SetAlwaysAcceptCookies(bool accept) {
void TestRunnerBindings::SetBlockThirdPartyCookies(bool block) {
if (runner_)
runner_->SetAlwaysAcceptCookies(accept);
runner_->SetBlockThirdPartyCookies(block);
}
void TestRunnerBindings::SetWindowIsKey(bool value) {
......@@ -1602,7 +1602,7 @@ void TestRunner::Reset() {
delegate_->SetDatabaseQuota(5 * 1024 * 1024);
delegate_->SetDeviceColorProfile("reset");
delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor());
delegate_->SetAcceptAllCookies(false);
delegate_->SetBlockThirdPartyCookies(true);
delegate_->SetLocale("");
delegate_->UseUnfortunateSynchronousResizeMode(false);
delegate_->DisableAutoResizeMode(WebSize());
......@@ -2606,8 +2606,8 @@ void TestRunner::SetDatabaseQuota(int quota) {
delegate_->SetDatabaseQuota(quota);
}
void TestRunner::SetAlwaysAcceptCookies(bool accept) {
delegate_->SetAcceptAllCookies(accept);
void TestRunner::SetBlockThirdPartyCookies(bool block) {
delegate_->SetBlockThirdPartyCookies(block);
}
void TestRunner::SetFocus(blink::WebView* web_view, bool focus) {
......
......@@ -493,8 +493,10 @@ class TestRunner : public WebTestRunner {
// Sets the default quota for all origins
void SetDatabaseQuota(int quota);
// Changes the cookie policy from the default to allow all cookies.
void SetAlwaysAcceptCookies(bool accept);
// Sets the cookie policy to:
// - allow all cookies when |block| is false
// - block only third-party cookies when |block| is true
void SetBlockThirdPartyCookies(bool block);
// Converts a URL starting with file:///tmp/ to the local mapping.
std::string PathToLocalResource(const std::string& path);
......
......@@ -200,7 +200,7 @@ class WebTestDelegate {
// Controls whether all cookies should be accepted or writing cookies in a
// third-party context is blocked.
virtual void SetAcceptAllCookies(bool accept) = 0;
virtual void SetBlockThirdPartyCookies(bool block) = 0;
// The same as RewriteLayoutTestsURL unless the resource is a path starting
// with /tmp/, then return a file URL to a temporary file.
......
......@@ -2238,7 +2238,7 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) {
ASSERT_TRUE(origin_two.Start());
// Block third-party cookies.
ShellNetworkDelegate::SetAcceptAllCookies(false);
ShellNetworkDelegate::SetBlockThirdPartyCookies(true);
// |url| redirects to a different origin |download| which tries to set a
// cookie.
......
......@@ -489,7 +489,7 @@ IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, CookiePolicy) {
GURL url(embedded_test_server()->GetURL("/redirect?" + set_cookie_url));
ShellContentBrowserClient::SetSwapProcessesForRedirect(true);
ShellNetworkDelegate::SetAcceptAllCookies(false);
ShellNetworkDelegate::SetBlockThirdPartyCookies(true);
CheckTitleTest(url, "cookie set");
}
......
......@@ -75,7 +75,8 @@ bool LayoutTestMessageFilter::OnMessageReceived(const IPC::Message& message) {
OnSimulateWebNotificationClick)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_SimulateWebNotificationClose,
OnSimulateWebNotificationClose)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_AcceptAllCookies, OnAcceptAllCookies)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_BlockThirdPartyCookies,
OnBlockThirdPartyCookies)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_DeleteAllCookies, OnDeleteAllCookies)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_SetPermission, OnSetPermission)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_ResetPermissions, OnResetPermissions)
......@@ -139,8 +140,8 @@ void LayoutTestMessageFilter::OnSimulateWebNotificationClose(
manager->SimulateClose(title, by_user);
}
void LayoutTestMessageFilter::OnAcceptAllCookies(bool accept) {
ShellNetworkDelegate::SetAcceptAllCookies(accept);
void LayoutTestMessageFilter::OnBlockThirdPartyCookies(bool block) {
ShellNetworkDelegate::SetBlockThirdPartyCookies(block);
}
void LayoutTestMessageFilter::OnDeleteAllCookies() {
......
......@@ -63,7 +63,7 @@ class LayoutTestMessageFilter : public BrowserMessageFilter {
void OnSimulateWebNotificationClose(const std::string& title, bool by_user);
void OnSetPushMessagingPermission(const GURL& origin, bool allowed);
void OnClearPushMessagingPermissions();
void OnAcceptAllCookies(bool accept);
void OnBlockThirdPartyCookies(bool block);
void OnDeleteAllCookies();
void OnSetPermission(const std::string& name,
blink::mojom::PermissionStatus status,
......
......@@ -39,7 +39,7 @@ LayoutTestURLRequestContextGetter::~LayoutTestURLRequestContextGetter() {
std::unique_ptr<net::NetworkDelegate>
LayoutTestURLRequestContextGetter::CreateNetworkDelegate() {
ShellNetworkDelegate::SetAcceptAllCookies(false);
ShellNetworkDelegate::SetBlockThirdPartyCookies(true);
return base::WrapUnique(new ShellNetworkDelegate);
}
......
......@@ -14,7 +14,7 @@
namespace content {
namespace {
bool g_accept_all_cookies = true;
bool g_block_third_party_cookies = false;
}
ShellNetworkDelegate::ShellNetworkDelegate() {
......@@ -23,8 +23,8 @@ ShellNetworkDelegate::ShellNetworkDelegate() {
ShellNetworkDelegate::~ShellNetworkDelegate() {
}
void ShellNetworkDelegate::SetAcceptAllCookies(bool accept) {
g_accept_all_cookies = accept;
void ShellNetworkDelegate::SetBlockThirdPartyCookies(bool block) {
g_block_third_party_cookies = block;
}
int ShellNetworkDelegate::OnBeforeURLRequest(
......@@ -81,9 +81,9 @@ ShellNetworkDelegate::AuthRequiredResponse ShellNetworkDelegate::OnAuthRequired(
bool ShellNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
const net::CookieList& cookie_list) {
net::StaticCookiePolicy::Type policy_type = g_accept_all_cookies ?
net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES;
net::StaticCookiePolicy::Type policy_type = g_block_third_party_cookies ?
net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
net::StaticCookiePolicy::ALLOW_ALL_COOKIES;
net::StaticCookiePolicy policy(policy_type);
int rv = policy.CanGetCookies(
request.url(), request.first_party_for_cookies());
......@@ -93,9 +93,9 @@ bool ShellNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
bool ShellNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
const std::string& cookie_line,
net::CookieOptions* options) {
net::StaticCookiePolicy::Type policy_type = g_accept_all_cookies ?
net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES;
net::StaticCookiePolicy::Type policy_type = g_block_third_party_cookies ?
net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
net::StaticCookiePolicy::ALLOW_ALL_COOKIES;
net::StaticCookiePolicy policy(policy_type);
int rv = policy.CanSetCookie(
request.url(), request.first_party_for_cookies());
......
......@@ -16,7 +16,7 @@ class ShellNetworkDelegate : public net::NetworkDelegateImpl {
ShellNetworkDelegate();
~ShellNetworkDelegate() override;
static void SetAcceptAllCookies(bool accept);
static void SetBlockThirdPartyCookies(bool block);
private:
// net::NetworkDelegate implementation.
......
per-file *_messages*.h=set noparent
per-file *_messages*.h=file://ipc/SECURITY_OWNERS
......@@ -30,8 +30,8 @@ IPC_MESSAGE_ROUTED2(LayoutTestHostMsg_SimulateWebNotificationClick,
IPC_MESSAGE_ROUTED2(LayoutTestHostMsg_SimulateWebNotificationClose,
std::string /* title */,
bool /* by_user */)
IPC_MESSAGE_ROUTED1(LayoutTestHostMsg_AcceptAllCookies,
bool /* accept */)
IPC_MESSAGE_ROUTED1(LayoutTestHostMsg_BlockThirdPartyCookies,
bool /* block */)
IPC_MESSAGE_ROUTED0(LayoutTestHostMsg_DeleteAllCookies)
IPC_MESSAGE_ROUTED4(LayoutTestHostMsg_SetPermission,
std::string /* name */,
......
......@@ -537,8 +537,8 @@ void BlinkTestRunner::SetFocus(blink::WebView* web_view, bool focus) {
SetFocusAndActivate(render_view, focus);
}
void BlinkTestRunner::SetAcceptAllCookies(bool accept) {
Send(new LayoutTestHostMsg_AcceptAllCookies(routing_id(), accept));
void BlinkTestRunner::SetBlockThirdPartyCookies(bool block) {
Send(new LayoutTestHostMsg_BlockThirdPartyCookies(routing_id(), block));
}
std::string BlinkTestRunner::PathToLocalResource(const std::string& resource) {
......
......@@ -116,7 +116,7 @@ class BlinkTestRunner : public RenderViewObserver,
void SendBluetoothManualChooserEvent(const std::string& event,
const std::string& argument) override;
void SetFocus(blink::WebView* web_view, bool focus) override;
void SetAcceptAllCookies(bool accept) override;
void SetBlockThirdPartyCookies(bool block) override;
std::string PathToLocalResource(const std::string& resource) override;
void SetLocale(const std::string& locale) override;
void OnLayoutTestRuntimeFlagsChanged(
......
function resetCookies()
{
if (window.testRunner)
testRunner.setAlwaysAcceptCookies(true);
testRunner.setBlockThirdPartyCookies(false);
// Due to cross-origin restrictions, we can only (simply) reset cookies for our current origin.
var url = "http://" + window.location.hostname +":8000/cookies/resources/cookie-utility.php?queryfunction=deleteCookies";
......@@ -14,5 +14,5 @@ function resetCookies()
}
if (window.testRunner)
testRunner.setAlwaysAcceptCookies(false);
testRunner.setBlockThirdPartyCookies(true);
}
if (window.testRunner) {
testRunner.setAlwaysAcceptCookies(true);
testRunner.setBlockThirdPartyCookies(false);
}
var ORIGINAL_HOST = "example.test";
......
......@@ -32,7 +32,7 @@ function sendXHR(queryCommand)
{
if (window.testRunner) {
// setAlwaysAcceptCookies() takes effect asynchronously (IPC is involved).
testRunner.setAlwaysAcceptCookies(true);
testRunner.setBlockThirdPartyCookies(false);
}
var baseurl = "http://localhost:8000/cookies/resources/cookie-utility.php";
......@@ -48,7 +48,7 @@ function sendXHR(queryCommand)
alert("xhr error");
if (window.testRunner) {
testRunner.setAlwaysAcceptCookies(false);
testRunner.setBlockThirdPartyCookies(true);
}
parent.window.postMessage("done", "*");
......
......@@ -13,7 +13,7 @@ if (window.testRunner) {
//testRunner.overridePreference('WebKitAllowDisplayingInsecureContent', true);
// Accept all cookies.
testRunner.setAlwaysAcceptCookies(true);
testRunner.setBlockThirdPartyCookies(false);
}
// How tests starts:
......
......@@ -10,7 +10,7 @@
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setAlwaysAcceptCookies(true);
testRunner.setBlockThirdPartyCookies(false);
testRunner.waitUntilDone();
}
......
......@@ -14,7 +14,7 @@ if (window.testRunner) {
if (testRunner.setPrivateBrowsingEnabled)
testRunner.setPrivateBrowsingEnabled(true);
testRunner.setAlwaysAcceptCookies(false);
testRunner.setBlockThirdPartyCookies(true);
}
</script>
<body>
......
......@@ -14,7 +14,7 @@ if (window.testRunner) {
if (testRunner.setPrivateBrowsingEnabled)
testRunner.setPrivateBrowsingEnabled(true);
testRunner.setAlwaysAcceptCookies(false);
testRunner.setBlockThirdPartyCookies(true);
}
</script>
<body>
......
......@@ -12,7 +12,7 @@ if (window.testRunner) {
if (testRunner.setPrivateBrowsingEnabled)
testRunner.setPrivateBrowsingEnabled(true);
testRunner.setAlwaysAcceptCookies(false);
testRunner.setBlockThirdPartyCookies(true);
}
function runTest()
......
......@@ -12,7 +12,7 @@ if (window.testRunner) {
if (testRunner.setPrivateBrowsingEnabled)
testRunner.setPrivateBrowsingEnabled(true);
testRunner.setAlwaysAcceptCookies(false);
testRunner.setBlockThirdPartyCookies(true);
}
function runTest()
......
......@@ -12,7 +12,7 @@ if (window.testRunner) {
if (testRunner.setPrivateBrowsingEnabled)
testRunner.setPrivateBrowsingEnabled(true);
testRunner.setAlwaysAcceptCookies(false);
testRunner.setBlockThirdPartyCookies(true);
}
function runTest()
......
......@@ -5,7 +5,7 @@
<script src="../resources/get-host-info.js?pipe=sub"></script>
<script>
if (window.testRunner)
testRunner.setAlwaysAcceptCookies(true);
testRunner.setBlockThirdPartyCookies(false);
function load_image(url, cross_origin) {
......
......@@ -5,7 +5,7 @@ if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.setCanOpenWindows();
testRunner.setAlwaysAcceptCookies(1);
testRunner.setBlockThirdPartyCookies(false);
}
function log(message)
......@@ -108,4 +108,3 @@ function testSyncCookiesWithCredentials()
if (window.testRunner)
testSyncCookiesNoCredentials();
</script>
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