- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / automation / automation_util.h
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.
4
5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_
6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11
12 class AutomationProvider;
13 class Browser;
14 class GURL;
15 class Profile;
16
17 namespace content {
18 class RenderViewHost;
19 class WebContents;
20 }
21
22 namespace base {
23 class DictionaryValue;
24 }
25
26 namespace extensions {
27 class Extension;
28 }
29
30 namespace IPC {
31 class Message;
32 }
33
34 // This file contains automation utility functions.
35
36 namespace automation_util {
37
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);
41
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);
45
46 #if defined(OS_CHROMEOS)
47 // Returns the appropriate profile depending on signed in state of user.
48 Profile* GetCurrentProfileOnChromeOS(std::string* error_message);
49 #endif
50
51 // Returns the browser that contains the given tab, or NULL if none exists.
52 Browser* GetBrowserForTab(content::WebContents* tab);
53
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,
58                 int* value_size,
59                 std::string* value);
60
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,
65                int* response_value);
66
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,
71                   bool* success);
72
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);
78
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);
84
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);
90
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);
95
96 }  // namespace automation_util
97
98 #endif  // CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_