Index: chrome/test/automation/automation_json_requests.h |
diff --git a/chrome/test/automation/automation_json_requests.h b/chrome/test/automation/automation_json_requests.h |
index 28d607d334d6a466747a8cb020b6b1f32b4359e9..1c27f686d20383feb1931dab51a071b53b551b82 100644 |
--- a/chrome/test/automation/automation_json_requests.h |
+++ b/chrome/test/automation/automation_json_requests.h |
@@ -11,6 +11,7 @@ |
#include "base/compiler_specific.h" |
#include "base/file_path.h" |
+#include "chrome/browser/automation/automation_provider_json.h" |
#include "chrome/common/automation_constants.h" |
#include "ui/base/keycodes/keyboard_codes.h" |
@@ -37,6 +38,87 @@ struct WebKeyEvent { |
int modifiers; |
}; |
+struct WebViewLocator { |
+ enum Type { |
+ kTypeIndexPair = 0, |
+ kTypeViewId, |
+ }; |
+ struct IndexPair { |
+ int browser_index; |
+ int tab_index; |
+ }; |
+ struct Locator { |
+ Locator() { } |
+ ~Locator() { } |
+ |
+ IndexPair index_pair; |
+ AutomationId view_id; |
+ }; |
+ |
+ WebViewLocator(){} |
+ ~WebViewLocator(){} |
+ void UpdateDictionary(base::DictionaryValue* dict) const; |
+ |
+ Type type; |
+ Locator locator; |
+}; |
+ |
+struct WebViewId { |
+ enum Type { |
+ kTypeTabId = 0, |
+ kTypeViewId, |
+ kMaxTypes |
+ }; |
+ struct Id { |
+ Id() { } |
+ ~Id() { } |
+ |
+ int tab_id; |
+ AutomationId view_id; |
+ }; |
+ |
+ static WebViewId ForTab(int tab_id) { |
+ WebViewId id; |
+ id.type = kTypeTabId; |
+ id.id.tab_id = tab_id; |
+ return id; |
+ } |
+ |
+ static WebViewId ForView(const AutomationId& view_id) { |
+ WebViewId id; |
+ id.type = kTypeViewId; |
+ id.id.view_id = view_id; |
+ return id; |
+ } |
+ |
+ WebViewId() { } |
+ ~WebViewId() {} |
+ bool IsValid() const { |
+ if (type == kTypeTabId) { |
+ return id.tab_id != 0; |
+ } |
+ if (type == kTypeViewId) { |
+ return id.view_id.is_valid(); |
+ } |
+ return false; |
+ } |
+ void UpdateDictionary(base::DictionaryValue* dictionary) const; |
+ |
+ Type type; |
+ Id id; |
+}; |
+ |
+struct WebViewInfo { |
+ WebViewInfo(AutomationId::Type type, |
+ const WebViewId& view_id, |
+ const std::string& extension_id); |
+ ~WebViewInfo(); |
+ |
+ AutomationId::Type type; |
+ WebViewId view_id; |
+ std::string extension_id; |
+}; |
+ |
// Sends a JSON request to the chrome automation provider. Returns true |
// if the JSON request was successfully sent and the reply was received. |
// If true, |success| will be set to whether the JSON request was |
@@ -89,8 +171,7 @@ bool SendNavigateToURLJSONRequest( |
// result of the execution and ownership will be given to the caller. |
bool SendExecuteJavascriptJSONRequest( |
AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
+ const WebViewLocator& locator, |
const std::string& frame_xpath, |
const std::string& javascript, |
base::Value** result, |
@@ -130,22 +211,6 @@ bool SendCaptureEntirePageJSONRequest( |
const FilePath& path, |
std::string* error_msg) WARN_UNUSED_RESULT; |
-// Requests the url of the specified tab. Returns true on success. |
-bool SendGetTabURLJSONRequest( |
- AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
- std::string* url, |
- std::string* error_msg) WARN_UNUSED_RESULT; |
- |
-// Requests the title of the specified tab. Returns true on success. |
-bool SendGetTabTitleJSONRequest( |
- AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
- std::string* tab_title, |
- std::string* error_msg) WARN_UNUSED_RESULT; |
- |
// Requests all the cookies for the given URL. On success returns true and |
// caller takes ownership of |cookies|, which is a list of all the cookies in |
// dictionary format. |
@@ -174,16 +239,29 @@ bool SendSetCookieJSONRequest( |
// Requests the IDs for all open tabs. Returns true on success. |
bool SendGetTabIdsJSONRequest( |
AutomationMessageSender* sender, |
- std::vector<int>* tab_ids, |
+ std::vector<WebViewInfo>* views, |
+ std::string* error_msg) WARN_UNUSED_RESULT; |
+ |
+// Requests info for all open views. Returns true on success. |
+bool SendGetWebViewsJSONRequest( |
+ AutomationMessageSender* sender, |
+ std::vector<WebViewInfo>* views, |
std::string* error_msg) WARN_UNUSED_RESULT; |
// Requests whether the given tab ID is valid. Returns true on success. |
bool SendIsTabIdValidJSONRequest( |
AutomationMessageSender* sender, |
- int tab_id, |
+ const WebViewId& view_id, |
bool* is_valid, |
std::string* error_msg) WARN_UNUSED_RESULT; |
+// Requests whether the given view ID is valid. Returns true on success. |
+bool SendDoesViewExistJSONRequest( |
+ AutomationMessageSender* sender, |
+ const WebViewId& view_id, |
+ bool* does_exist, |
+ std::string* error_msg) WARN_UNUSED_RESULT; |
+ |
// Requests to close the given tab. Returns true on success. |
bool SendCloseTabJSONRequest( |
AutomationMessageSender* sender, |
@@ -195,8 +273,7 @@ bool SendCloseTabJSONRequest( |
// coordinate in the specified tab. Returns true on success. |
bool SendMouseMoveJSONRequest( |
AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
+ const WebViewLocator& locator, |
int x, |
int y, |
std::string* error_msg) WARN_UNUSED_RESULT; |
@@ -205,8 +282,7 @@ bool SendMouseMoveJSONRequest( |
// coordinate in the specified tab. Returns true on success. |
bool SendMouseClickJSONRequest( |
AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
+ const WebViewLocator& locator, |
automation::MouseButton button, |
int x, |
int y, |
@@ -216,8 +292,7 @@ bool SendMouseClickJSONRequest( |
// coordinates given in the specified tab. Returns true on success. |
bool SendMouseDragJSONRequest( |
AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
+ const WebViewLocator& locator, |
int start_x, |
int start_y, |
int end_x, |
@@ -228,8 +303,7 @@ bool SendMouseDragJSONRequest( |
// coordinate in the specified tab. Returns true on success. |
bool SendMouseButtonDownJSONRequest( |
AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
+ const WebViewLocator& locator, |
int x, |
int y, |
std::string* error_msg) WARN_UNUSED_RESULT; |
@@ -238,8 +312,7 @@ bool SendMouseButtonDownJSONRequest( |
// coordinate in the specified tab. Returns true on success. |
bool SendMouseButtonUpJSONRequest( |
AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
+ const WebViewLocator& locator, |
int x, |
int y, |
std::string* error_msg) WARN_UNUSED_RESULT; |
@@ -248,8 +321,7 @@ bool SendMouseButtonUpJSONRequest( |
// coordinate in the specified tab. Returns true on success. |
bool SendMouseDoubleClickJSONRequest( |
AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
+ const WebViewLocator& locator, |
int x, |
int y, |
std::string* error_msg) WARN_UNUSED_RESULT; |
@@ -258,8 +330,7 @@ bool SendMouseDoubleClickJSONRequest( |
// specified tab. Returns true on success. |
bool SendWebKeyEventJSONRequest( |
AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
+ const WebViewLocator& locator, |
const WebKeyEvent& key_event, |
std::string* error_msg) WARN_UNUSED_RESULT; |
@@ -277,8 +348,7 @@ bool SendNativeKeyEventJSONRequest( |
// specified tab. Returns true on success. |
bool SendDragAndDropFilePathsJSONRequest( |
AutomationMessageSender* sender, |
- int browser_index, |
- int tab_index, |
+ const WebViewLocator& locator, |
int x, |
int y, |
const std::vector<FilePath::StringType>& paths, |