From 3aded7fb5db539bd2e39a4c9c5f22b2fa8251f60 Mon Sep 17 00:00:00 2001 From: "kkania@chromium.org" Date: Sat, 26 Mar 2011 18:12:52 +0000 Subject: Part2 of Convert ChromeDriver to use only the JSON automation interface. Move common functions to automation_util. BUG=none TEST=none Review URL: http://codereview.chromium.org/6614023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79496 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/automation/automation_util.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'chrome/browser/automation/automation_util.cc') diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc index 99b025c..9d4c39e 100644 --- a/chrome/browser/automation/automation_util.cc +++ b/chrome/browser/automation/automation_util.cc @@ -9,13 +9,17 @@ #include "base/scoped_ptr.h" #include "base/time.h" #include "base/values.h" +#include "chrome/browser/automation/automation_provider.h" #include "chrome/browser/automation/automation_provider_json.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_host/browser_render_process_host.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_list.h" #include "chrome/common/net/url_request_context_getter.h" #include "chrome/browser/ui/browser.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/render_view_host.h" +#include "content/browser/tab_contents/tab_contents.h" #include "net/base/cookie_monster.h" #include "net/base/cookie_store.h" #include "net/url_request/url_request_context.h" @@ -80,6 +84,21 @@ void DeleteCookieOnIOThread( namespace automation_util { +Browser* GetBrowserAt(int index) { + if (index < 0 || index >= static_cast(BrowserList::size())) + return NULL; + return *(BrowserList::begin() + index); +} + +TabContents* GetTabContentsAt(int browser_index, int tab_index) { + if (tab_index < 0) + return NULL; + Browser* browser = GetBrowserAt(browser_index); + if (!browser || tab_index >= browser->tab_count()) + return NULL; + return browser->GetTabContentsAt(tab_index); +} + void GetCookies(const GURL& url, TabContents* contents, int* value_size, -- cgit v1.1