diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-31 18:08:40 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-31 18:08:40 +0000 |
commit | 4f999134a2e270792abc8b5ac6ad70aa500dcef4 (patch) | |
tree | e90d972ee2f29d10d6e22220d54cd142925bb2bb /chrome/test | |
parent | b5cd43eb964e452d7a0245b9e14bd9a9d1e89b4a (diff) | |
download | chromium_src-4f999134a2e270792abc8b5ac6ad70aa500dcef4.zip chromium_src-4f999134a2e270792abc8b5ac6ad70aa500dcef4.tar.gz chromium_src-4f999134a2e270792abc8b5ac6ad70aa500dcef4.tar.bz2 |
Use WebScriptSource and WebFindInPageRequest from the WebKit API.
This change introduces some helper functions in glue_util.cc for efficient
conversion between WebString and WebCore::String when inside the implementation
of webkit/glue. This is a temporary change since eventually all code in glue
that uses WebCore will be moved into the WebKit API implementation.
Instead of making the Chrome automation use WebFindInPageRequest, I decided to
introduce AutomationMsg_Find_Params as a copy of the old FindInPageRequest
structure. That preserves the IPC protocol and avoids making the automation
library depend on WebKit.
R=dglazkov
Review URL: http://codereview.chromium.org/57060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12881 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/automation/automation_messages.h | 40 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 13 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 15 |
3 files changed, 53 insertions, 15 deletions
diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h index 52a9945..5968f78 100644 --- a/chrome/test/automation/automation_messages.h +++ b/chrome/test/automation/automation_messages.h @@ -13,9 +13,49 @@ #include "chrome/common/ipc_message_utils.h" #include "chrome/test/automation/automation_constants.h" +struct AutomationMsg_Find_Params { + // Unused value, which exists only for backwards compat. + int unused; + + // The word(s) to find on the page. + string16 search_string; + + // Whether to search forward or backward within the page. + bool forward; + + // Whether search should be Case sensitive. + bool match_case; + + // Whether this operation is first request (Find) or a follow-up (FindNext). + bool find_next; +}; + namespace IPC { template <> +struct ParamTraits<AutomationMsg_Find_Params> { + typedef AutomationMsg_Find_Params param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.unused); + WriteParam(m, p.search_string); + WriteParam(m, p.forward); + WriteParam(m, p.match_case); + WriteParam(m, p.find_next); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->unused) && + ReadParam(m, iter, &p->search_string) && + ReadParam(m, iter, &p->forward) && + ReadParam(m, iter, &p->match_case) && + ReadParam(m, iter, &p->find_next); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<AutomationMsg_Find_Params>"); + } +}; + +template <> struct ParamTraits<AutomationMsg_NavigationResponseValues> { typedef AutomationMsg_NavigationResponseValues param_type; static void Write(Message* m, const param_type& p) { diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 89e401b..59599b1 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -13,11 +13,11 @@ #include "base/basictypes.h" #include "base/gfx/rect.h" +#include "base/string16.h" #include "chrome/common/ipc_message_macros.h" #include "chrome/common/navigation_types.h" #include "chrome/test/automation/autocomplete_edit_proxy.h" #include "googleurl/src/gurl.h" -#include "webkit/glue/find_in_page_request.h" // NOTE: All IPC messages have either a routing_id of 0 (for asynchronous // messages), or one that's been assigned by the proxy (for calls @@ -299,8 +299,8 @@ IPC_BEGIN_MESSAGES(Automation) // (1=case sensitive, 0=case insensitive). If an error occurs, matches_found // will be -1. // - // NOTE: These two messages have been deprecated, please use the new messages - // AutomationMsg_FindRequest and AutomationMsg_FindInPageResponse2 below. + // NOTE: This message has been deprecated, please use the new message + // AutomationMsg_Find below. // IPC_SYNC_MESSAGE_ROUTED4_2(AutomationMsg_FindInPage, // DEPRECATED. int, /* tab_handle */ @@ -746,12 +746,11 @@ IPC_BEGIN_MESSAGES(Automation) // This message starts a find within a tab corresponding to the supplied // tab handle. The parameter |request| specifies what to search for. - // If an error occurs, |matches_found| will be -1 (see response message - // AutomationMsg_FindInPageResponse2). + // If an error occurs, |matches_found| will be -1. // IPC_SYNC_MESSAGE_ROUTED2_2(AutomationMsg_Find, - int, /* tab_handle */ - FindInPageRequest /* request */, + int /* tab_handle */, + AutomationMsg_Find_Params /* params */, int /* active_ordinal */, int /* matches_found */) diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 550dc5d..bf69a78 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -51,17 +51,17 @@ int TabProxy::FindInPage(const std::wstring& search_string, if (!is_valid()) return -1; - FindInPageRequest request = {0}; - request.search_string = WideToUTF16(search_string); - request.find_next = find_next; - // The explicit comparison to TRUE avoids a warning (C4800). - request.match_case = match_case == TRUE; - request.forward = forward == TRUE; + AutomationMsg_Find_Params params; + params.unused = 0; + params.search_string = WideToUTF16Hack(search_string); + params.find_next = find_next; + params.match_case = (match_case == CASE_SENSITIVE); + params.forward = (forward == FWD); int matches = 0; int ordinal2 = 0; bool succeeded = sender_->Send(new AutomationMsg_Find(0, handle_, - request, + params, &ordinal2, &matches)); if (!succeeded) @@ -622,4 +622,3 @@ void TabProxy::Reposition(HWND window, HWND window_insert_after, int left, sender_->Send(new AutomationMsg_TabReposition(0, handle_, params)); } #endif // defined(OS_WIN) - |