1// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_ 6#define CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_ 7#pragma once 8 9#include <string> 10 11#include "base/basictypes.h" 12 13class AutomationProvider; 14class Browser; 15class DictionaryValue; 16class GURL; 17class TabContents; 18 19namespace IPC { 20class Message; 21} 22 23// This file contains automation utility functions. 24 25namespace automation_util { 26 27// Returns the browser at the given index of the |BrowserList| or NULL if the 28// index is out of range. 29Browser* GetBrowserAt(int index); 30 31// Returns the tab at |tab_index| within the browser at |browser_index| in the 32// |BrowserList|. If any of these indices are invalid, NULL will be returned. 33TabContents* GetTabContentsAt(int browser_index, int tab_index); 34 35// Gets the size and value of the cookie string for |url| in the given tab. 36// Can be called from any thread. 37void GetCookies(const GURL& url, 38 TabContents* contents, 39 int* value_size, 40 std::string* value); 41 42// Sets a cookie for |url| in the given tab. Can be called from any thread. 43void SetCookie(const GURL& url, 44 const std::string& value, 45 TabContents* contents, 46 int* response_value); 47 48// Deletes a cookie for |url| in the given tab. Can be called from any thread. 49void DeleteCookie(const GURL& url, 50 const std::string& cookie_name, 51 TabContents* contents, 52 bool* success); 53 54// Gets the cookies for the given URL. Uses the JSON interface. 55// See |TestingAutomationProvider| for example input. 56void GetCookiesJSON(AutomationProvider* provider, 57 DictionaryValue* args, 58 IPC::Message* reply_message); 59 60// Deletes the cookie with the given name for the URL. Uses the JSON interface. 61// See |TestingAutomationProvider| for example input. 62void DeleteCookieJSON(AutomationProvider* provider, 63 DictionaryValue* args, 64 IPC::Message* reply_message); 65 66// Sets a cookie for the given URL. Uses the JSON interface. 67// See |TestingAutomationProvider| for example input. 68void SetCookieJSON(AutomationProvider* provider, 69 DictionaryValue* args, 70 IPC::Message* reply_message); 71 72} // namespace automation_util 73 74#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_ 75