Commit 5c972fcf authored by John Abd-El-Malek's avatar John Abd-El-Malek Committed by Commit Bot

Convert ui_test_utils::GetCookies to work with network service.

Bug: 769401
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: Ic00aa9c4eada086ec810ae6167e614ed72e5a046
Reviewed-on: https://chromium-review.googlesource.com/953086
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541551}
parent 7a87490b
......@@ -70,6 +70,7 @@
#include "net/url_request/url_request_context_getter.h"
#include "services/device/public/mojom/geoposition.mojom.h"
#include "services/network/public/cpp/resource_request_body.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
#include "ui/gfx/geometry/rect.h"
#if defined(OS_WIN)
......@@ -401,23 +402,11 @@ Browser* GetBrowserNotInSet(const std::set<Browser*>& excluded_browsers) {
namespace {
void GetCookieListCallback(base::WaitableEvent* event,
net::CookieList* cookies,
const net::CookieList& cookie_list) {
void GetCookieCallback(base::RepeatingClosure callback,
net::CookieList* cookies,
const net::CookieList& cookie_list) {
*cookies = cookie_list;
event->Signal();
}
void GetCookiesOnIOThread(
const GURL& url,
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
base::WaitableEvent* event,
net::CookieList* cookie_list) {
context_getter->GetURLRequestContext()
->cookie_store()
->GetCookieListWithOptionsAsync(
url, net::CookieOptions(),
base::BindOnce(&GetCookieListCallback, event, cookie_list));
callback.Run();
}
} // namespace
......@@ -428,19 +417,15 @@ void GetCookies(const GURL& url,
std::string* value) {
*value_size = -1;
if (url.is_valid() && contents) {
scoped_refptr<net::URLRequestContextGetter> context_getter =
contents->GetMainFrame()
->GetProcess()
->GetStoragePartition()
->GetURLRequestContext();
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
base::RunLoop loop;
auto* storage_partition =
contents->GetMainFrame()->GetProcess()->GetStoragePartition();
net::CookieOptions options;
net::CookieList cookie_list;
CHECK(content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&GetCookiesOnIOThread, url, context_getter, &event,
&cookie_list)));
event.Wait();
storage_partition->GetCookieManagerForBrowserProcess()->GetCookieList(
url, options,
base::BindOnce(GetCookieCallback, loop.QuitClosure(), &cookie_list));
loop.Run();
*value = net::CanonicalCookie::BuildCookieLine(cookie_list);
*value_size = static_cast<int>(value->size());
......
......@@ -37,7 +37,6 @@
-PKPModelClientTest.PKPEnforced
-PlatformAppBrowserTest.AppWindowAdjustBoundsToBeVisibleOnScreen
-PlatformAppBrowserTest.CreateAndCloseAppWindow
-PlatformAppBrowserTest.Isolation
-PlatformAppDevToolsBrowserTest.ReOpenedWithID
-PlatformAppDevToolsBrowserTest.ReOpenedWithURL
-PolicyTest.DefaultCookiesSetting
......
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