diff options
author | jmikhail@google.com <jmikhail@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-21 23:07:22 +0000 |
---|---|---|
committer | jmikhail@google.com <jmikhail@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-21 23:07:22 +0000 |
commit | 5fa579426b97728de9c6e21253535ae1a4bb82cf (patch) | |
tree | a87cc6da49bef3b9500005708afbbea86a55e285 | |
parent | 5aa74cb012c23ee3590016ea9bfe724cdb4b1be1 (diff) | |
download | chromium_src-5fa579426b97728de9c6e21253535ae1a4bb82cf.zip chromium_src-5fa579426b97728de9c6e21253535ae1a4bb82cf.tar.gz chromium_src-5fa579426b97728de9c6e21253535ae1a4bb82cf.tar.bz2 |
Add delete cookie option to Automation Proxy
BUG=none
TEST=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45256 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 14 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 2 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 7 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 9 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 7 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 2 |
6 files changed, 41 insertions, 0 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 5f51cad..04bb3d3 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -323,6 +323,7 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseTab, CloseTab) IPC_MESSAGE_HANDLER(AutomationMsg_GetCookies, GetCookies) IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) + IPC_MESSAGE_HANDLER(AutomationMsg_DeleteCookie, DeleteCookie) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_NavigateToURL, NavigateToURL) IPC_MESSAGE_HANDLER_DELAY_REPLY( AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, @@ -1174,6 +1175,19 @@ void AutomationProvider::SetCookie(const GURL& url, } } +void AutomationProvider::DeleteCookie(const GURL& url, + const std::string& cookie_name, + int handle, bool* success) { + *success = false; + if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { + NavigationController* tab = tab_tracker_->GetResource(handle); + net::CookieStore* cookie_store = + tab->profile()->GetRequestContext()->GetCookieStore(); + cookie_store->DeleteCookie(url, cookie_name); + *success = true; + } +} + void AutomationProvider::GetTabURL(int handle, bool* success, GURL* url) { *success = false; if (tab_tracker_->ContainsHandle(handle)) { diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index e4256c0..d21456d 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -162,6 +162,8 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, const std::string value, int handle, int* response_value); + void DeleteCookie(const GURL& url, const std::string& cookie_name, + int handle, bool* success); void GetBrowserWindowCount(int* window_count); void GetBrowserLocale(string16* locale); void GetNormalBrowserWindowCount(int* window_count); diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 9512969..77f9d56 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -1389,4 +1389,11 @@ IPC_BEGIN_MESSAGES(Automation) WindowOpenDisposition, bool /* result */) + + // This message requests the cookie be delete for given url in the + // profile of the tab identified by the first parameter. The second + // parameter is the cookie name. + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_DeleteCookie, GURL, std::string, + int, bool) + IPC_END_MESSAGES(Automation) diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index 9850d1f..2631f84 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -414,6 +414,15 @@ TEST_F(AutomationProxyTest, Cookies) { ASSERT_FALSE(value_result.empty()); EXPECT_TRUE(value_result.find("foo1=baz1") != std::string::npos); EXPECT_TRUE(value_result.find("foo2=baz2") != std::string::npos); + + // test deleting cookie + ASSERT_TRUE(tab->SetCookie(url, "foo3=deleteme")); + + ASSERT_TRUE(tab->GetCookieByName(url, "foo3", &value_result)); + ASSERT_FALSE(value_result.empty()); + ASSERT_STREQ("deleteme", value_result.c_str()); + + ASSERT_TRUE(tab->DeleteCookie(url, "foo3")); } TEST_F(AutomationProxyTest, NavigateToURLAsync) { diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index a662f60..0c2c27f 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -474,6 +474,13 @@ bool TabProxy::SetCookie(const GURL& url, const std::string& value) { &response_value)); } +bool TabProxy::DeleteCookie(const GURL& url, const std::string& name) { + bool succeeded; + sender_->Send(new AutomationMsg_DeleteCookie(0, url, name, handle_, + &succeeded)); + return succeeded; +} + int TabProxy::InspectElement(int x, int y) { if (!is_valid()) return -1; diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index 7fabc50..3929213 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -251,6 +251,8 @@ class TabProxy : public AutomationResourceProxy, const std::string& name, std::string* cookies) WARN_UNUSED_RESULT; bool SetCookie(const GURL& url, const std::string& value) WARN_UNUSED_RESULT; + bool DeleteCookie(const GURL& url, + const std::string& name) WARN_UNUSED_RESULT; // Sends a InspectElement message for the current tab. |x| and |y| are the // coordinates that we want to simulate that the user is trying to inspect. |