OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_ | 5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_ |
6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_ | 6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 | 12 |
| 13 class AutomationId; |
13 class AutomationProvider; | 14 class AutomationProvider; |
14 class Browser; | 15 class Browser; |
| 16 class Extension; |
| 17 class ExtensionHost; |
15 class GURL; | 18 class GURL; |
| 19 class Profile; |
| 20 class RenderViewHost; |
16 class TabContents; | 21 class TabContents; |
| 22 class TabContentsWrapper; |
17 | 23 |
18 namespace base { | 24 namespace base { |
19 class DictionaryValue; | 25 class DictionaryValue; |
20 } | 26 } |
21 | 27 |
22 namespace IPC { | 28 namespace IPC { |
23 class Message; | 29 class Message; |
24 } | 30 } |
25 | 31 |
26 // This file contains automation utility functions. | 32 // This file contains automation utility functions. |
27 | 33 |
28 namespace automation_util { | 34 namespace automation_util { |
29 | 35 |
30 // Returns the browser at the given index of the |BrowserList| or NULL if the | 36 // Returns the browser at the given index of the |BrowserList| or NULL if the |
31 // index is out of range. | 37 // index is out of range. |
32 Browser* GetBrowserAt(int index); | 38 Browser* GetBrowserAt(int index); |
33 | 39 |
34 // Returns the tab at |tab_index| within the browser at |browser_index| in the | 40 // Returns the tab at |tab_index| within the browser at |browser_index| in the |
35 // |BrowserList|. If any of these indices are invalid, NULL will be returned. | 41 // |BrowserList|. If any of these indices are invalid, NULL will be returned. |
36 TabContents* GetTabContentsAt(int browser_index, int tab_index); | 42 TabContents* GetTabContentsAt(int browser_index, int tab_index); |
37 | 43 |
| 44 // Returns the browser that contains the given tab, or NULL if none exists. |
| 45 Browser* GetBrowserForTab(TabContents* tab); |
| 46 |
38 // Gets the size and value of the cookie string for |url| in the given tab. | 47 // Gets the size and value of the cookie string for |url| in the given tab. |
39 // Can be called from any thread. | 48 // Can be called from any thread. |
40 void GetCookies(const GURL& url, | 49 void GetCookies(const GURL& url, |
41 TabContents* contents, | 50 TabContents* contents, |
42 int* value_size, | 51 int* value_size, |
43 std::string* value); | 52 std::string* value); |
44 | 53 |
45 // Sets a cookie for |url| in the given tab. Can be called from any thread. | 54 // Sets a cookie for |url| in the given tab. Can be called from any thread. |
46 void SetCookie(const GURL& url, | 55 void SetCookie(const GURL& url, |
47 const std::string& value, | 56 const std::string& value, |
(...skipping 22 matching lines...) Expand all Loading... |
70 // See |TestingAutomationProvider| for example input. | 79 // See |TestingAutomationProvider| for example input. |
71 void SetCookieJSON(AutomationProvider* provider, | 80 void SetCookieJSON(AutomationProvider* provider, |
72 base::DictionaryValue* args, | 81 base::DictionaryValue* args, |
73 IPC::Message* reply_message); | 82 IPC::Message* reply_message); |
74 | 83 |
75 // Sends a JSON error reply if an app modal dialog is active. Returns whether | 84 // Sends a JSON error reply if an app modal dialog is active. Returns whether |
76 // an error reply was sent. | 85 // an error reply was sent. |
77 bool SendErrorIfModalDialogActive(AutomationProvider* provider, | 86 bool SendErrorIfModalDialogActive(AutomationProvider* provider, |
78 IPC::Message* message); | 87 IPC::Message* message); |
79 | 88 |
| 89 // Returns a valid automation ID for the given tab. |
| 90 AutomationId GetIdForTab(const TabContentsWrapper* tab); |
| 91 |
| 92 // Returns a valid automation ID for the extension host. |
| 93 AutomationId GetIdForExtensionView(const ExtensionHost* ext_host); |
| 94 |
| 95 // Returns a valid automation ID for the extension. |
| 96 AutomationId GetIdForExtension(const Extension* extension); |
| 97 |
| 98 // Gets the tab for the given ID. Returns true on success. |
| 99 bool GetTabForId(const AutomationId& id, TabContents** tab); |
| 100 |
| 101 // Gets the render view for the given ID. Returns true on success. |
| 102 bool GetRenderViewForId(const AutomationId& id, |
| 103 Profile* profile, |
| 104 RenderViewHost** rvh); |
| 105 |
| 106 // Gets the extension for the given ID. Returns true on success. |
| 107 bool GetExtensionForId(const AutomationId& id, |
| 108 Profile* profile, |
| 109 const Extension** extension); |
| 110 |
| 111 // Returns whether the given ID refers to an actual automation entity. |
| 112 bool DoesObjectWithIdExist(const AutomationId& id, Profile* profile); |
| 113 |
80 } // namespace automation_util | 114 } // namespace automation_util |
81 | 115 |
82 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_ | 116 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_UTIL_H_ |
OLD | NEW |