1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_
6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_
10 #include "base/basictypes.h"
12 class AutomationProvider;
23 class DictionaryValue;
26 namespace extensions {
34 // This file contains automation utility functions.
36 namespace automation_util {
38 // Returns the browser at the given index of the |BrowserList| or NULL if the
39 // index is out of range.
40 Browser* GetBrowserAt(int index);
42 // Returns the tab at |tab_index| within the browser at |browser_index| in the
43 // |BrowserList|. If any of these indices are invalid, NULL will be returned.
44 content::WebContents* GetWebContentsAt(int browser_index, int tab_index);
46 #if defined(OS_CHROMEOS)
47 // Returns the appropriate profile depending on signed in state of user.
48 Profile* GetCurrentProfileOnChromeOS(std::string* error_message);
51 // Returns the browser that contains the given tab, or NULL if none exists.
52 Browser* GetBrowserForTab(content::WebContents* tab);
54 // Gets the size and value of the cookie string for |url| in the given tab.
55 // Can be called from any thread.
56 void GetCookies(const GURL& url,
57 content::WebContents* contents,
61 // Sets a cookie for |url| in the given tab. Can be called from any thread.
62 void SetCookie(const GURL& url,
63 const std::string& value,
64 content::WebContents* contents,
67 // Deletes a cookie for |url| in the given tab. Can be called from any thread.
68 void DeleteCookie(const GURL& url,
69 const std::string& cookie_name,
70 content::WebContents* contents,
73 // Gets the cookies for the given URL. Uses the JSON interface.
74 // See |TestingAutomationProvider| for example input.
75 void GetCookiesJSON(AutomationProvider* provider,
76 base::DictionaryValue* args,
77 IPC::Message* reply_message);
79 // Deletes the cookie with the given name for the URL. Uses the JSON interface.
80 // See |TestingAutomationProvider| for example input.
81 void DeleteCookieJSON(AutomationProvider* provider,
82 base::DictionaryValue* args,
83 IPC::Message* reply_message);
85 // Sets a cookie for the given URL. Uses the JSON interface.
86 // See |TestingAutomationProvider| for example input.
87 void SetCookieJSON(AutomationProvider* provider,
88 base::DictionaryValue* args,
89 IPC::Message* reply_message);
91 // Sends a JSON error reply if an app modal dialog is active. Returns whether
92 // an error reply was sent.
93 bool SendErrorIfModalDialogActive(AutomationProvider* provider,
94 IPC::Message* message);
96 } // namespace automation_util
98 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_