• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
13 class AutomationProvider;
14 class Browser;
15 class DictionaryValue;
16 class GURL;
17 class TabContents;
18 
19 namespace IPC {
20 class Message;
21 }
22 
23 // This file contains automation utility functions.
24 
25 namespace automation_util {
26 
27 // Returns the browser at the given index of the |BrowserList| or NULL if the
28 // index is out of range.
29 Browser* 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.
33 TabContents* 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.
37 void 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.
43 void 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.
49 void 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.
56 void 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.
62 void 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.
68 void 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