Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1998)

Unified Diff: content/public/test/browser_test_utils.cc

Issue 10873082: Converted policy.PolicyTest.ClearSiteDataOnExit pyauto test to a browser_test. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/browser_test_utils.cc
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index aedf32ca93430e81ac800d3894a653c726a56571..ed0379d0aa7afcae979eee9f83ddf3ecc9ea80a5 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -166,8 +166,26 @@ void GetCookiesOnIOThread(const GURL& url,
context_getter->GetURLRequestContext()->cookie_store();
cookie_store->GetCookiesWithOptionsAsync(
url, net::CookieOptions(),
- base::Bind(&GetCookiesCallback,
- base::Unretained(cookies), base::Unretained(event)));
+ base::Bind(&GetCookiesCallback, cookies, event));
+}
+
+void SetCookieCallback(bool* result,
+ base::WaitableEvent* event,
+ bool success) {
+ *result = success;
+ event->Signal();
+}
+
+void SetCookieOnIOThread(const GURL& url,
+ const std::string& value,
+ net::URLRequestContextGetter* context_getter,
+ base::WaitableEvent* event,
+ bool* result) {
+ net::CookieStore* cookie_store =
+ context_getter->GetURLRequestContext()->cookie_store();
+ cookie_store->SetCookieWithOptionsAsync(
+ url, value, net::CookieOptions(),
+ base::Bind(&SetCookieCallback, result, event));
}
} // namespace
@@ -319,6 +337,22 @@ std::string GetCookies(BrowserContext* browser_context, const GURL& url) {
return cookies;
}
+bool SetCookie(BrowserContext* browser_context,
+ const GURL& url,
+ const std::string& value) {
+ bool result = false;
+ base::WaitableEvent event(true, false);
+ net::URLRequestContextGetter* context_getter =
+ browser_context->GetRequestContext();
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&SetCookieOnIOThread, url, value,
+ make_scoped_refptr(context_getter), &event, &result));
+ event.Wait();
+ return result;
+}
+
TitleWatcher::TitleWatcher(WebContents* web_contents,
const string16& expected_title)
: web_contents_(web_contents),
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698