diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/automation_resource_message_filter.cc | 33 | ||||
-rw-r--r-- | chrome/browser/automation/automation_resource_message_filter.h | 7 |
2 files changed, 31 insertions, 9 deletions
diff --git a/chrome/browser/automation/automation_resource_message_filter.cc b/chrome/browser/automation/automation_resource_message_filter.cc index 2777f75..1529751 100644 --- a/chrome/browser/automation/automation_resource_message_filter.cc +++ b/chrome/browser/automation/automation_resource_message_filter.cc @@ -345,6 +345,11 @@ void AutomationResourceMessageFilter::GetCookiesForUrl( filtered_render_views_.Get().find(RendererId( get_cookies_callback->render_process_id(), get_cookies_callback->render_view_id()))); + if (automation_details_iter == filtered_render_views_.Get().end()) { + OnGetCookiesHostResponseInternal(tab_handle, false, url, "", callback, + cookie_store); + return; + } DCHECK(automation_details_iter->second.filter != NULL); @@ -379,21 +384,31 @@ void AutomationResourceMessageFilter::OnGetCookiesHostResponse( completion_callback_map_.Get().erase(index); - // Set the cookie in the cookie store so that the callback can read it. - cookie_store->SetCookieWithOptions(url, cookies, net::CookieOptions()); - - Tuple1<int> params; - params.a = success ? net::OK : net::ERR_ACCESS_DENIED; - callback->RunWithParams(params); - - // The cookie for this URL is only valid until it is read by the callback. - cookie_store->SetCookieWithOptions(url, "", net::CookieOptions()); + OnGetCookiesHostResponseInternal(tab_handle, success, url, cookies, + callback, cookie_store.get()); } else { NOTREACHED() << "Received invalid completion callback id:" << cookie_id; } } +void AutomationResourceMessageFilter::OnGetCookiesHostResponseInternal( + int tab_handle, bool success, const GURL& url, const std::string& cookies, + net::CompletionCallback* callback, net::CookieStore* cookie_store) { + DCHECK(callback); + DCHECK(cookie_store); + + // Set the cookie in the cookie store so that the callback can read it. + cookie_store->SetCookieWithOptions(url, cookies, net::CookieOptions()); + + Tuple1<int> params; + params.a = success ? net::OK : net::ERR_ACCESS_DENIED; + callback->RunWithParams(params); + + // The cookie for this URL is only valid until it is read by the callback. + cookie_store->SetCookieWithOptions(url, "", net::CookieOptions()); +} + void AutomationResourceMessageFilter::SetCookiesForUrl( int tab_handle, const GURL&url, const std::string& cookie_line, net::CompletionCallback* callback) { diff --git a/chrome/browser/automation/automation_resource_message_filter.h b/chrome/browser/automation/automation_resource_message_filter.h index a2acba8..5ed2a81 100644 --- a/chrome/browser/automation/automation_resource_message_filter.h +++ b/chrome/browser/automation/automation_resource_message_filter.h @@ -132,6 +132,13 @@ class AutomationResourceMessageFilter int renderer_pid, int renderer_id, int tab_handle, AutomationResourceMessageFilter* filter); + // Helper function to execute the GetCookies completion callback with the + // response for the GetCookies request from the renderer. + static void OnGetCookiesHostResponseInternal( + int tab_handle, bool success, const GURL& url, + const std::string& cookies, net::CompletionCallback* callback, + net::CookieStore* cookie_store); + private: void OnSetFilteredInet(bool enable); void OnGetFilteredInetHitCount(int* hit_count); |