| Index: chrome/browser/automation/testing_automation_provider.cc
|
| diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
|
| index e36d655199dae216bf32dda9ae976ba35daef9a8..757eeac625ce5aa6c1f52d9a0b5d4317c3272f44 100644
|
| --- a/chrome/browser/automation/testing_automation_provider.cc
|
| +++ b/chrome/browser/automation/testing_automation_provider.cc
|
| @@ -26,6 +26,7 @@
|
| #include "chrome/browser/autofill/autofill_manager.h"
|
| #include "chrome/browser/automation/automation_autocomplete_edit_tracker.h"
|
| #include "chrome/browser/automation/automation_browser_tracker.h"
|
| +#include "chrome/browser/automation/automation_cookie_util.h"
|
| #include "chrome/browser/automation/automation_provider_json.h"
|
| #include "chrome/browser/automation/automation_provider_list.h"
|
| #include "chrome/browser/automation/automation_provider_observers.h"
|
| @@ -72,7 +73,6 @@
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| -#include "chrome/common/net/url_request_context_getter.h"
|
| #include "chrome/common/notification_service.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| @@ -80,8 +80,6 @@
|
| #include "content/browser/renderer_host/render_view_host.h"
|
| #include "content/browser/tab_contents/interstitial_page.h"
|
| #include "content/common/common_param_traits.h"
|
| -#include "net/base/cookie_store.h"
|
| -#include "net/url_request/url_request_context.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
|
| #include "ui/base/events.h"
|
| #include "ui/base/message_box_flags.h"
|
| @@ -89,34 +87,6 @@
|
|
|
| namespace {
|
|
|
| -void GetCookiesOnIOThread(
|
| - const GURL& url,
|
| - const scoped_refptr<URLRequestContextGetter>& context_getter,
|
| - base::WaitableEvent* event,
|
| - std::string* cookies) {
|
| - *cookies = context_getter->GetCookieStore()->GetCookies(url);
|
| - event->Signal();
|
| -}
|
| -
|
| -void SetCookieOnIOThread(
|
| - const GURL& url,
|
| - const std::string& value,
|
| - const scoped_refptr<URLRequestContextGetter>& context_getter,
|
| - base::WaitableEvent* event,
|
| - bool* success) {
|
| - *success = context_getter->GetCookieStore()->SetCookie(url, value);
|
| - event->Signal();
|
| -}
|
| -
|
| -void DeleteCookieOnIOThread(
|
| - const GURL& url,
|
| - const std::string& name,
|
| - const scoped_refptr<URLRequestContextGetter>& context_getter,
|
| - base::WaitableEvent* event) {
|
| - context_getter->GetCookieStore()->DeleteCookie(url, name);
|
| - event->Signal();
|
| -}
|
| -
|
| void SendMouseClick(int flags) {
|
| ui_controls::MouseButton button = ui_controls::LEFT;
|
| if ((flags & ui::EF_LEFT_BUTTON_DOWN) ==
|
| @@ -508,67 +478,26 @@ void TestingAutomationProvider::CloseTab(int tab_handle,
|
| void TestingAutomationProvider::GetCookies(const GURL& url, int handle,
|
| int* value_size,
|
| std::string* value) {
|
| - *value_size = -1;
|
| - if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) {
|
| - // Since we are running on the UI thread don't call GetURLRequestContext().
|
| - scoped_refptr<URLRequestContextGetter> context_getter =
|
| - tab_tracker_->GetResource(handle)->profile()->GetRequestContext();
|
| -
|
| - base::WaitableEvent event(true /* manual reset */,
|
| - false /* not initially signaled */);
|
| - CHECK(BrowserThread::PostTask(
|
| - BrowserThread::IO, FROM_HERE,
|
| - NewRunnableFunction(&GetCookiesOnIOThread,
|
| - url, context_getter, &event, value)));
|
| - event.Wait();
|
| -
|
| - *value_size = static_cast<int>(value->size());
|
| - }
|
| + TabContents *contents = tab_tracker_->ContainsHandle(handle) ?
|
| + tab_tracker_->GetResource(handle)->tab_contents() : NULL;
|
| + automation_cookie_util::GetCookies(url, contents, value_size, value);
|
| }
|
|
|
| void TestingAutomationProvider::SetCookie(const GURL& url,
|
| const std::string value,
|
| int handle,
|
| int* response_value) {
|
| - *response_value = -1;
|
| -
|
| - if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) {
|
| - // Since we are running on the UI thread don't call GetURLRequestContext().
|
| - scoped_refptr<URLRequestContextGetter> context_getter =
|
| - tab_tracker_->GetResource(handle)->profile()->GetRequestContext();
|
| -
|
| - base::WaitableEvent event(true /* manual reset */,
|
| - false /* not initially signaled */);
|
| - bool success = false;
|
| - CHECK(BrowserThread::PostTask(
|
| - BrowserThread::IO, FROM_HERE,
|
| - NewRunnableFunction(&SetCookieOnIOThread,
|
| - url, value, context_getter, &event,
|
| - &success)));
|
| - event.Wait();
|
| - if (success)
|
| - *response_value = 1;
|
| - }
|
| + TabContents *contents = tab_tracker_->ContainsHandle(handle) ?
|
| + tab_tracker_->GetResource(handle)->tab_contents() : NULL;
|
| + automation_cookie_util::SetCookie(url, value, contents, response_value);
|
| }
|
|
|
| void TestingAutomationProvider::DeleteCookie(const GURL& url,
|
| const std::string& cookie_name,
|
| int handle, bool* success) {
|
| - *success = false;
|
| - if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) {
|
| - // Since we are running on the UI thread don't call GetURLRequestContext().
|
| - scoped_refptr<URLRequestContextGetter> context_getter =
|
| - tab_tracker_->GetResource(handle)->profile()->GetRequestContext();
|
| -
|
| - base::WaitableEvent event(true /* manual reset */,
|
| - false /* not initially signaled */);
|
| - CHECK(BrowserThread::PostTask(
|
| - BrowserThread::IO, FROM_HERE,
|
| - NewRunnableFunction(&DeleteCookieOnIOThread,
|
| - url, cookie_name, context_getter, &event)));
|
| - event.Wait();
|
| - *success = true;
|
| - }
|
| + TabContents *contents = tab_tracker_->ContainsHandle(handle) ?
|
| + tab_tracker_->GetResource(handle)->tab_contents() : NULL;
|
| + automation_cookie_util::DeleteCookie(url, cookie_name, contents, success);
|
| }
|
|
|
| void TestingAutomationProvider::ShowCollectedCookiesDialog(
|
| @@ -5038,7 +4967,7 @@ void TestingAutomationProvider::GetCookiesJSON(
|
| base::WaitableEvent event(true /* manual reset */,
|
| false /* not initially signaled */);
|
| Task* task = NewRunnableFunction(
|
| - &GetCookiesOnIOThread,
|
| + &automation_cookie_util::GetCookiesOnIOThread,
|
| GURL(url), context_getter, &event, &cookies);
|
| if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, task)) {
|
| reply.SendError("Couldn't post task to get the cookies");
|
| @@ -5077,7 +5006,7 @@ void TestingAutomationProvider::DeleteCookieJSON(
|
| base::WaitableEvent event(true /* manual reset */,
|
| false /* not initially signaled */);
|
| Task* task = NewRunnableFunction(
|
| - &DeleteCookieOnIOThread,
|
| + &automation_cookie_util::DeleteCookieOnIOThread,
|
| GURL(url), name, context_getter, &event);
|
| if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, task)) {
|
| reply.SendError("Couldn't post task to delete the cookie");
|
| @@ -5114,7 +5043,7 @@ void TestingAutomationProvider::SetCookieJSON(
|
| false /* not initially signaled */);
|
| bool success = false;
|
| Task* task = NewRunnableFunction(
|
| - &SetCookieOnIOThread,
|
| + &automation_cookie_util::SetCookieOnIOThread,
|
| GURL(url), cookie, context_getter, &event, &success);
|
| if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, task)) {
|
| reply.SendError("Couldn't post task to set the cookie");
|
|
|