diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 00:32:16 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 00:32:16 +0000 |
commit | b888919c4ebb50770e1a4e17207576d8b61d7e72 (patch) | |
tree | e7e8d24675205ee57f32d3b95789ab8b9f09fd1d | |
parent | 557daa507219947eda302f87dc5465616e4a0277 (diff) | |
download | chromium_src-b888919c4ebb50770e1a4e17207576d8b61d7e72.zip chromium_src-b888919c4ebb50770e1a4e17207576d8b61d7e72.tar.gz chromium_src-b888919c4ebb50770e1a4e17207576d8b61d7e72.tar.bz2 |
Handle the ViewHostMsg_FindReply message which is sent by content(renderer) via the TabContentsDelegate.
The other change is to remove an unused Browser member from the ExternalTabContainer class.
BUG=87335
Review URL: http://codereview.chromium.org/7828025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99275 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/external_tab_container_win.cc | 13 | ||||
-rw-r--r-- | chrome/browser/external_tab_container_win.h | 9 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 41 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 15 | ||||
-rw-r--r-- | chrome/browser/ui/find_bar/find_tab_helper.cc | 19 | ||||
-rw-r--r-- | chrome/browser/ui/find_bar/find_tab_helper.h | 13 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 10 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 3 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_delegate.cc | 8 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_delegate.h | 10 |
10 files changed, 106 insertions, 35 deletions
diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index 253c586..00351e6 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -775,6 +775,16 @@ void ExternalTabContainer::WebIntentDispatch(TabContents* tab, intent_id); } +void ExternalTabContainer::FindReply(TabContents* tab, + int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update) { + Browser::FindReplyHelper(tab, request_id, number_of_matches, selection_rect, + active_match_ordinal, final_update); +} + bool ExternalTabContainer::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ExternalTabContainer, message) @@ -891,9 +901,6 @@ void ExternalTabContainer::OnDestroy() { prop_.reset(); Uninitialize(); NativeWidgetWin::OnDestroy(); - if (browser_.get()) { - ::DestroyWindow(browser_->window()->GetNativeHandle()); - } } void ExternalTabContainer::OnFinalMessage(HWND window) { diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h index 76aaf58..e87ca0e 100644 --- a/chrome/browser/external_tab_container_win.h +++ b/chrome/browser/external_tab_container_win.h @@ -176,6 +176,12 @@ class ExternalTabContainer : public TabContentsDelegate, const string16& type, const string16& data, int intent_id); + virtual void FindReply(TabContents* tab, + int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update); void RegisterRenderViewHost(RenderViewHost* render_view_host); void UnregisterRenderViewHost(RenderViewHost* render_view_host); @@ -289,9 +295,6 @@ class ExternalTabContainer : public TabContentsDelegate, // whether top level URL requests are to be handled by the automation client. bool handle_top_level_requests_; - // Scoped browser object for this ExternalTabContainer instance. - scoped_ptr<Browser> browser_; - // Contains ExternalTabContainers that have not been connected to as yet. static base::LazyInstance<PendingTabs> pending_tabs_; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 92491f8..935ee68 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2526,6 +2526,23 @@ void Browser::WebIntentDispatchHelper(TabContents* tab, tcw->web_intent_picker_controller()->ShowDialog(action, type); } +// static +void Browser::FindReplyHelper(TabContents* tab, + int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update) { + TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( + tab); + if (!tcw || !tcw->find_tab_helper()) + return; + + tcw->find_tab_helper()->HandleFindReply(request_id, number_of_matches, + selection_rect, active_match_ordinal, + final_update); +} + void Browser::ExecuteCommandWithDisposition( int id, WindowOpenDisposition disposition) { // No commands are enabled if there is not yet any selected tab. @@ -3732,12 +3749,12 @@ content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { void Browser::RunFileChooser(TabContents* tab, const ViewHostMsg_RunFileChooser_Params& params) { - Browser::RunFileChooserHelper(tab, params); + RunFileChooserHelper(tab, params); } void Browser::EnumerateDirectory(TabContents* tab, int request_id, const FilePath& path) { - Browser::EnumerateDirectoryHelper(tab, request_id, path); + EnumerateDirectoryHelper(tab, request_id, path); } void Browser::ToggleFullscreenModeForTab(TabContents* tab, @@ -3753,14 +3770,14 @@ void Browser::ToggleFullscreenModeForTab(TabContents* tab, } void Browser::JSOutOfMemory(TabContents* tab) { - Browser::JSOutOfMemoryHelper(tab); + JSOutOfMemoryHelper(tab); } void Browser::RegisterProtocolHandler(TabContents* tab, const std::string& protocol, const GURL& url, const string16& title) { - Browser::RegisterProtocolHandlerHelper(tab, protocol, url, title); + RegisterProtocolHandlerHelper(tab, protocol, url, title); } void Browser::RegisterIntentHandler(TabContents* tab, @@ -3768,7 +3785,7 @@ void Browser::RegisterIntentHandler(TabContents* tab, const string16& type, const string16& href, const string16& title) { - Browser::RegisterIntentHandlerHelper(tab, action, type, href, title); + RegisterIntentHandlerHelper(tab, action, type, href, title); } void Browser::WebIntentDispatch(TabContents* tab, @@ -3777,8 +3794,18 @@ void Browser::WebIntentDispatch(TabContents* tab, const string16& type, const string16& data, int intent_id) { - Browser::WebIntentDispatchHelper(tab, routing_id, action, type, data, - intent_id); + WebIntentDispatchHelper(tab, routing_id, action, type, data, + intent_id); +} + +void Browser::FindReply(TabContents* tab, + int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update) { + FindReplyHelper(tab, request_id, number_of_matches, selection_rect, + active_match_ordinal, final_update); } void Browser::ExitTabbedFullscreenModeIfNecessary() { diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 6963963..f83843e 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -684,6 +684,14 @@ class Browser : public TabHandlerDelegate, const string16& data, int intent_id); + // Helper function to handle find results. + static void FindReplyHelper(TabContents* tab, + int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update); + // Calls ExecuteCommandWithDisposition with the given disposition. void ExecuteCommandWithDisposition(int id, WindowOpenDisposition); @@ -960,6 +968,13 @@ class Browser : public TabHandlerDelegate, const string16& data, int intent_id) OVERRIDE; + virtual void FindReply(TabContents* tab, + int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update) OVERRIDE; + // Overridden from TabContentsWrapperDelegate: virtual void OnDidGetApplicationInfo(TabContentsWrapper* source, int32 page_id) OVERRIDE; diff --git a/chrome/browser/ui/find_bar/find_tab_helper.cc b/chrome/browser/ui/find_bar/find_tab_helper.cc index a595e53..9c5e538 100644 --- a/chrome/browser/ui/find_bar/find_tab_helper.cc +++ b/chrome/browser/ui/find_bar/find_tab_helper.cc @@ -124,20 +124,11 @@ void FindTabHelper::StopFinding( tab_contents()->render_view_host()->routing_id(), params)); } -bool FindTabHelper::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(FindTabHelper, message) - IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void FindTabHelper::OnFindReply(int request_id, - int number_of_matches, - const gfx::Rect& selection_rect, - int active_match_ordinal, - bool final_update) { +void FindTabHelper::HandleFindReply(int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update) { // Ignore responses for requests that have been aborted. // Ignore responses for requests other than the one we have most recently // issued. That way we won't act on stale results when the user has diff --git a/chrome/browser/ui/find_bar/find_tab_helper.h b/chrome/browser/ui/find_bar/find_tab_helper.h index 555d972..5e26c31 100644 --- a/chrome/browser/ui/find_bar/find_tab_helper.h +++ b/chrome/browser/ui/find_bar/find_tab_helper.h @@ -58,16 +58,13 @@ class FindTabHelper : public TabContentsObserver { return last_search_result_; } - // TabContentsObserver overrides. - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + void HandleFindReply(int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update); private: - void OnFindReply(int request_id, - int number_of_matches, - const gfx::Rect& selection_rect, - int active_match_ordinal, - bool final_update); - // Each time a search request comes in we assign it an id before passing it // over the IPC so that when the results come in we can evaluate whether we // still care about the results of the search (in some cases we don't because diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 6762a65..9271d1b 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -301,6 +301,7 @@ bool TabContents::OnMessageReceived(const IPC::Message& message) { OnRegisterIntentHandler) IPC_MESSAGE_HANDLER(ViewHostMsg_WebIntentDispatch, OnWebIntentDispatch) + IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() @@ -1134,6 +1135,15 @@ void TabContents::OnWebIntentDispatch(const IPC::Message& message, data, intent_id); } +void TabContents::OnFindReply(int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update) { + delegate()->FindReply(this, request_id, number_of_matches, selection_rect, + active_match_ordinal, final_update); +} + // Notifies the RenderWidgetHost instance about the fact that the page is // loading, or done loading and calls the base implementation. void TabContents::SetIsLoading(bool is_loading, diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 5111387..1e996c0 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -577,6 +577,9 @@ class TabContents : public PageNavigator, const string16& type, const string16& data, int intent_id); + void OnFindReply(int request_id, int number_of_matches, + const gfx::Rect& selection_rect, int active_match_ordinal, + bool final_update); // Changes the IsLoading state and notifies delegate as needed // |details| is used to provide details on the load that just finished diff --git a/content/browser/tab_contents/tab_contents_delegate.cc b/content/browser/tab_contents/tab_contents_delegate.cc index 5652481..a6bdb98 100644 --- a/content/browser/tab_contents/tab_contents_delegate.cc +++ b/content/browser/tab_contents/tab_contents_delegate.cc @@ -316,6 +316,14 @@ void TabContentsDelegate::WebIntentDispatch(TabContents* tab, int intent_id) { } +void TabContentsDelegate::FindReply(TabContents* tab, + int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update) { +} + TabContentsDelegate::~TabContentsDelegate() { while (!attached_contents_.empty()) { TabContents* tab_contents = *attached_contents_.begin(); diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h index 5894faf..9638775 100644 --- a/content/browser/tab_contents/tab_contents_delegate.h +++ b/content/browser/tab_contents/tab_contents_delegate.h @@ -338,6 +338,16 @@ class TabContentsDelegate { const string16& data, int intent_id); + // Result of string search in the page. This includes the number of matches + // found and the selection rect (in screen coordinates) for the string found. + // If |final_update| is false, it indicates that more results follow. + virtual void FindReply(TabContents* tab, + int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update); + protected: virtual ~TabContentsDelegate(); |