diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-23 22:15:34 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-23 22:15:34 +0000 |
commit | f5494d49ab74e3d116540b14db3457558f54c88e (patch) | |
tree | beb367c01c187652d02091a5067a69d5bc0fa064 /chrome/browser/automation | |
parent | a9f39a313b7ecc11d98727d869e15094481f3a65 (diff) | |
download | chromium_src-f5494d49ab74e3d116540b14db3457558f54c88e.zip chromium_src-f5494d49ab74e3d116540b14db3457558f54c88e.tar.gz chromium_src-f5494d49ab74e3d116540b14db3457558f54c88e.tar.bz2 |
Clean up Automation and Chrome Frame IPC code.-only use routed messages when needed-use routing IDs to avoid manually unpacking messages-remove data structures from IPC namespace (that should only be used for IPC code, and param traits)Note that I temporarily commented out part of a test in external_tab_test.cc because I couldn't figure out how to get the updated gmock macros to compile.
Review URL: http://codereview.chromium.org/5998006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70105 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation')
11 files changed, 32 insertions, 101 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 0e3aa72..e4e1909 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -198,7 +198,7 @@ void AutomationProvider::SetExpectedTabCount(size_t expected_tabs) { void AutomationProvider::OnInitialLoadsComplete() { initial_loads_complete_ = true; if (is_connected_) - Send(new AutomationMsg_InitialLoadsComplete(0)); + Send(new AutomationMsg_InitialLoadsComplete()); } NotificationObserver* AutomationProvider::AddNavigationStatusListener( @@ -353,9 +353,9 @@ void AutomationProvider::OnChannelConnected(int pid) { // Send a hello message with our current automation protocol version. chrome::VersionInfo version_info; - channel_->Send(new AutomationMsg_Hello(0, version_info.Version())); + channel_->Send(new AutomationMsg_Hello(version_info.Version())); if (initial_loads_complete_) - Send(new AutomationMsg_InitialLoadsComplete(0)); + Send(new AutomationMsg_InitialLoadsComplete()); } void AutomationProvider::OnMessageReceived(const IPC::Message& message) { diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 797d8b08..40b9bce 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -34,13 +34,13 @@ #include "views/event.h" #endif // defined(OS_WIN) -struct AutomationMsg_Find_Params; class PopupMenuWaiter; class TabContents; - -namespace IPC { +struct AutomationMsg_Find_Params; struct Reposition_Params; struct ExternalTabSettings; + +namespace IPC { class ChannelProxy; } @@ -355,11 +355,11 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, bool restore_focus_to_view); void OnTabReposition(int tab_handle, - const IPC::Reposition_Params& params); + const Reposition_Params& params); void OnForwardContextMenuCommandToChrome(int tab_handle, int command); - void CreateExternalTab(const IPC::ExternalTabSettings& settings, + void CreateExternalTab(const ExternalTabSettings& settings, gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, int* tab_handle, diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 480a8ec..1b6973d 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -164,7 +164,7 @@ void NewTabUILoadObserver::Observe(NotificationType type, if (type == NotificationType::INITIAL_NEW_TAB_UI_LOAD) { Details<int> load_time(details); automation_->Send( - new AutomationMsg_InitialNewTabUILoadComplete(0, *load_time.ptr())); + new AutomationMsg_InitialNewTabUILoadComplete(*load_time.ptr())); } else { NOTREACHED(); } diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 7ff2bff..0ad5400 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -230,7 +230,7 @@ void AutomationProvider::WindowSimulateDrag(int handle, } void AutomationProvider::CreateExternalTab( - const IPC::ExternalTabSettings& settings, + const ExternalTabSettings& settings, gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, int* tab_handle, int* session_id) { TRACE_EVENT_BEGIN("AutomationProvider::CreateExternalTab", 0, ""); @@ -318,7 +318,7 @@ ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { } void AutomationProvider::OnTabReposition( - int tab_handle, const IPC::Reposition_Params& params) { + int tab_handle, const Reposition_Params& params) { if (!tab_tracker_->ContainsHandle(tab_handle)) return; diff --git a/chrome/browser/automation/automation_resource_message_filter.cc b/chrome/browser/automation/automation_resource_message_filter.cc index 500b62b..5d3ac14 100644 --- a/chrome/browser/automation/automation_resource_message_filter.cc +++ b/chrome/browser/automation/automation_resource_message_filter.cc @@ -407,7 +407,7 @@ bool AutomationResourceMessageFilter::SendDownloadRequestToHost( return false; } - return Send(new AutomationMsg_DownloadRequestInHost(0, tab_handle, + return Send(new AutomationMsg_DownloadRequestInHost(tab_handle, automation_request_id)); } @@ -459,7 +459,7 @@ bool AutomationResourceMessageFilter::GetCookiesForUrl( if (automation_details_iter->second.filter) { automation_details_iter->second.filter->Send( new AutomationMsg_GetCookiesFromHost( - 0, automation_details_iter->second.tab_handle, url, + automation_details_iter->second.tab_handle, url, completion_callback_id)); } return true; @@ -530,7 +530,7 @@ bool AutomationResourceMessageFilter::SetCookiesForUrl( if (automation_details_iter->second.filter) { automation_details_iter->second.filter->Send( new AutomationMsg_SetCookieAsync( - 0, automation_details_iter->second.tab_handle, url, cookie_line)); + automation_details_iter->second.tab_handle, url, cookie_line)); } return true; diff --git a/chrome/browser/automation/automation_resource_tracker.cc b/chrome/browser/automation/automation_resource_tracker.cc index 2cce41a..82c384a 100644 --- a/chrome/browser/automation/automation_resource_tracker.cc +++ b/chrome/browser/automation/automation_resource_tracker.cc @@ -78,7 +78,7 @@ void AutomationResourceTrackerImpl::HandleCloseNotification( return; sender_->Send( - new AutomationMsg_InvalidateHandle(0, resource_to_handle_[resource])); + new AutomationMsg_InvalidateHandle(resource_to_handle_[resource])); RemoveImpl(resource); } diff --git a/chrome/browser/automation/extension_port_container.cc b/chrome/browser/automation/extension_port_container.cc index d79900d..d1fb46f 100644 --- a/chrome/browser/automation/extension_port_container.cc +++ b/chrome/browser/automation/extension_port_container.cc @@ -40,7 +40,7 @@ bool ExtensionPortContainer::PostResponseToExternalPort( const std::string& message) { return automation_->Send( new AutomationMsg_ForwardMessageToExternalHost( - 0, tab_handle_, message, ext::kAutomationOrigin, + tab_handle_, message, ext::kAutomationOrigin, ext::kAutomationPortResponseTarget)); } @@ -48,7 +48,7 @@ bool ExtensionPortContainer::PostMessageToExternalPort( const std::string& message) { return automation_->Send( new AutomationMsg_ForwardMessageToExternalHost( - 0, tab_handle_, message, + tab_handle_, message, ext::kAutomationOrigin, ext::kAutomationPortRequestTarget)); } diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 9ecc0ef..78afce1 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -218,15 +218,12 @@ void TestingAutomationProvider::OnMessageReceived( IPC_MESSAGE_HANDLER(AutomationMsg_DeleteCookie, DeleteCookie) IPC_MESSAGE_HANDLER(AutomationMsg_ShowCollectedCookiesDialog, ShowCollectedCookiesDialog) - IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_NavigateToURL, NavigateToURL) IPC_MESSAGE_HANDLER_DELAY_REPLY( AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, NavigateToURLBlockUntilNavigationsComplete) IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsync, NavigationAsync) IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsyncWithDisposition, NavigationAsyncWithDisposition) - IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_GoBack, GoBack) - IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_GoForward, GoForward) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SetAuth, SetAuth) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CancelAuth, CancelAuth) @@ -281,7 +278,6 @@ void TestingAutomationProvider::OnMessageReceived( AutocompleteEditGetMatches) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForAutocompleteEditFocus, WaitForAutocompleteEditFocus) - IPC_MESSAGE_HANDLER(AutomationMsg_ApplyAccelerator, ApplyAccelerator) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, ExecuteJavascript) IPC_MESSAGE_HANDLER(AutomationMsg_ConstrainedWindowCount, @@ -298,8 +294,6 @@ void TestingAutomationProvider::OnMessageReceived( IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InspectElement, HandleInspectElementRequest) IPC_MESSAGE_HANDLER(AutomationMsg_DownloadDirectory, GetDownloadDirectory) - IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindow, - OpenNewBrowserWindow) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType, OpenNewBrowserWindowOfType) IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) @@ -569,12 +563,6 @@ void TestingAutomationProvider::ShowCollectedCookiesDialog( } } -void TestingAutomationProvider::NavigateToURL(int handle, - const GURL& url, - IPC::Message* reply_message) { - NavigateToURLBlockUntilNavigationsComplete(handle, url, 1, reply_message); -} - void TestingAutomationProvider::NavigateToURLBlockUntilNavigationsComplete( int handle, const GURL& url, int number_of_navigations, IPC::Message* reply_message) { @@ -595,7 +583,7 @@ void TestingAutomationProvider::NavigateToURLBlockUntilNavigationsComplete( } } - AutomationMsg_NavigateToURL::WriteReplyParams( + AutomationMsg_NavigateToURLBlockUntilNavigationsComplete::WriteReplyParams( reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); Send(reply_message); } @@ -629,40 +617,6 @@ void TestingAutomationProvider::NavigationAsyncWithDisposition( } } -void TestingAutomationProvider::GoBack(int handle, - IPC::Message* reply_message) { - if (tab_tracker_->ContainsHandle(handle)) { - NavigationController* tab = tab_tracker_->GetResource(handle); - Browser* browser = FindAndActivateTab(tab); - if (browser && browser->command_updater()->IsCommandEnabled(IDC_BACK)) { - AddNavigationStatusListener(tab, reply_message, 1, false); - browser->GoBack(CURRENT_TAB); - return; - } - } - - AutomationMsg_GoBack::WriteReplyParams( - reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); - Send(reply_message); -} - -void TestingAutomationProvider::GoForward(int handle, - IPC::Message* reply_message) { - if (tab_tracker_->ContainsHandle(handle)) { - NavigationController* tab = tab_tracker_->GetResource(handle); - Browser* browser = FindAndActivateTab(tab); - if (browser && browser->command_updater()->IsCommandEnabled(IDC_FORWARD)) { - AddNavigationStatusListener(tab, reply_message, 1, false); - browser->GoForward(CURRENT_TAB); - return; - } - } - - AutomationMsg_GoForward::WriteReplyParams( - reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); - Send(reply_message); -} - void TestingAutomationProvider::Reload(int handle, IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(handle)) { @@ -1148,11 +1102,6 @@ void TestingAutomationProvider::AutocompleteEditIsQueryInProgress( } } -void TestingAutomationProvider::ApplyAccelerator(int handle, int id) { - LOG(ERROR) << "ApplyAccelerator has been deprecated. " - << "Please use ExecuteBrowserCommandAsync instead."; -} - void TestingAutomationProvider::ExecuteJavascript( int handle, const std::wstring& frame_xpath, @@ -1218,12 +1167,6 @@ void TestingAutomationProvider::GetDownloadDirectory( } } -void TestingAutomationProvider::OpenNewBrowserWindow( - bool show, IPC::Message* reply_message) { - OpenNewBrowserWindowOfType(static_cast<int>(Browser::TYPE_NORMAL), show, - reply_message); -} - void TestingAutomationProvider::OpenNewBrowserWindowOfType( int type, bool show, IPC::Message* reply_message) { new BrowserOpenedNotificationObserver(this, reply_message); diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h index 8be1a11..57f9572 100644 --- a/chrome/browser/automation/testing_automation_provider.h +++ b/chrome/browser/automation/testing_automation_provider.h @@ -75,7 +75,6 @@ class TestingAutomationProvider : public AutomationProvider, void DeleteCookie(const GURL& url, const std::string& cookie_name, int handle, bool* success); void ShowCollectedCookiesDialog(int handle, bool* success); - void NavigateToURL(int handle, const GURL& url, IPC::Message* reply_message); void NavigateToURLBlockUntilNavigationsComplete(int handle, const GURL& url, int number_of_navigations, IPC::Message* reply_message); @@ -84,8 +83,6 @@ class TestingAutomationProvider : public AutomationProvider, const GURL& url, WindowOpenDisposition disposition, bool* status); - void GoBack(int handle, IPC::Message* reply_message); - void GoForward(int handle, IPC::Message* reply_message); void Reload(int handle, IPC::Message* reply_message); void SetAuth(int tab_handle, const std::wstring& username, const std::wstring& password, IPC::Message* reply_message); @@ -162,9 +159,6 @@ class TestingAutomationProvider : public AutomationProvider, void WaitForAutocompleteEditFocus(int autocomplete_edit_handle, IPC::Message* reply_message); - // Deprecated. - void ApplyAccelerator(int handle, int id); - void ExecuteJavascript(int handle, const std::wstring& frame_xpath, const std::wstring& script, @@ -197,7 +191,6 @@ class TestingAutomationProvider : public AutomationProvider, void GetDownloadDirectory(int handle, FilePath* download_directory); // If |show| is true, call Show() on the new window after creating it. - void OpenNewBrowserWindow(bool show, IPC::Message* reply_message); void OpenNewBrowserWindowOfType(int type, bool show, IPC::Message* reply_message); diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc index c120286..7e2bc57 100644 --- a/chrome/browser/automation/url_request_automation_job.cc +++ b/chrome/browser/automation/url_request_automation_job.cc @@ -148,7 +148,7 @@ void URLRequestAutomationJob::Start() { void URLRequestAutomationJob::Kill() { if (message_filter_.get()) { if (!is_pending()) { - message_filter_->Send(new AutomationMsg_RequestEnd(0, tab_, id_, + message_filter_->Send(new AutomationMsg_RequestEnd(tab_, id_, URLRequestStatus(URLRequestStatus::CANCELED, net::ERR_ABORTED))); } } @@ -168,8 +168,7 @@ bool URLRequestAutomationJob::ReadRawData( pending_buf_size_ = buf_size; if (message_filter_) { - message_filter_->Send(new AutomationMsg_RequestRead(0, tab_, id_, - buf_size)); + message_filter_->Send(new AutomationMsg_RequestRead(tab_, id_, buf_size)); SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); } else { MessageLoop::current()->PostTask( @@ -241,11 +240,8 @@ bool URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message, case AutomationMsg_RequestData::ID: case AutomationMsg_RequestEnd::ID: { void* iter = NULL; - int tab = 0; - if (message.ReadInt(&iter, &tab) && - message.ReadInt(&iter, request_id)) { + if (message.ReadInt(&iter, request_id)) return true; - } break; } } @@ -268,8 +264,8 @@ void URLRequestAutomationJob::OnMessage(const IPC::Message& message) { IPC_END_MESSAGE_MAP() } -void URLRequestAutomationJob::OnRequestStarted(int tab, int id, - const IPC::AutomationURLResponse& response) { +void URLRequestAutomationJob::OnRequestStarted( + int id, const AutomationURLResponse& response) { DVLOG(1) << "URLRequestAutomationJob: " << request_->url().spec() << " - response started."; set_expected_content_size(response.content_length); @@ -289,7 +285,7 @@ void URLRequestAutomationJob::OnRequestStarted(int tab, int id, } void URLRequestAutomationJob::OnDataAvailable( - int tab, int id, const std::string& bytes) { + int id, const std::string& bytes) { DVLOG(1) << "URLRequestAutomationJob: " << request_->url().spec() << " - data available, Size: " << bytes.size(); DCHECK(!bytes.empty()); @@ -313,7 +309,7 @@ void URLRequestAutomationJob::OnDataAvailable( } void URLRequestAutomationJob::OnRequestEnd( - int tab, int id, const URLRequestStatus& status) { + int id, const URLRequestStatus& status) { #ifndef NDEBUG std::string url; if (request_) @@ -436,7 +432,7 @@ void URLRequestAutomationJob::StartAsync() { } // Ask automation to start this request. - IPC::AutomationURLRequest automation_request( + AutomationURLRequest automation_request( request_->url().spec(), request_->method(), referrer.spec(), @@ -446,8 +442,8 @@ void URLRequestAutomationJob::StartAsync() { request_->load_flags()); DCHECK(message_filter_); - message_filter_->Send(new AutomationMsg_RequestStart(0, tab_, id_, - automation_request)); + message_filter_->Send(new AutomationMsg_RequestStart( + tab_, id_, automation_request)); } void URLRequestAutomationJob::DisconnectFromMessageFilter() { diff --git a/chrome/browser/automation/url_request_automation_job.h b/chrome/browser/automation/url_request_automation_job.h index 0c930ba..9256a77 100644 --- a/chrome/browser/automation/url_request_automation_job.h +++ b/chrome/browser/automation/url_request_automation_job.h @@ -13,6 +13,7 @@ #include "net/url_request/url_request_job.h" class AutomationResourceMessageFilter; +struct AutomationURLResponse; namespace net { class HttpResponseHeaders; @@ -21,7 +22,6 @@ class HttpResponseInfo; namespace IPC { class Message; -struct AutomationURLResponse; } // net::URLRequestJob implementation that loads the resources using @@ -81,10 +81,9 @@ class URLRequestAutomationJob : public net::URLRequestJob { void DisconnectFromMessageFilter(); // IPC message handlers. - void OnRequestStarted(int tab, int id, - const IPC::AutomationURLResponse& response); - void OnDataAvailable(int tab, int id, const std::string& bytes); - void OnRequestEnd(int tab, int id, const URLRequestStatus& status); + void OnRequestStarted(int id, const AutomationURLResponse& response); + void OnDataAvailable(int id, const std::string& bytes); + void OnRequestEnd(int id, const URLRequestStatus& status); private: virtual ~URLRequestAutomationJob(); |