diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-23 14:09:28 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-23 14:09:28 +0000 |
commit | 772c1e6593566f95f9008107c3f81fd81e2604c5 (patch) | |
tree | f652b07ef1d55868d9b07f75ec605a90e15c7b25 /chrome/browser/instant | |
parent | 5c229910d99a862e56998157e03979560c2f679d (diff) | |
download | chromium_src-772c1e6593566f95f9008107c3f81fd81e2604c5.zip chromium_src-772c1e6593566f95f9008107c3f81fd81e2604c5.tar.gz chromium_src-772c1e6593566f95f9008107c3f81fd81e2604c5.tar.bz2 |
Moves instant related tab contents messages into instant and out of
TabContents.
BUG=77091
TEST=none
R=jam@chromium.org
Review URL: http://codereview.chromium.org/6724014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79118 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/instant')
-rw-r--r-- | chrome/browser/instant/instant_loader.cc | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index 6eda28f..84ea27b 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -138,7 +138,8 @@ void InstantLoader::FrameLoadObserver::Observe( class InstantLoader::TabContentsDelegateImpl : public TabContentsDelegate, - public NotificationObserver { + public NotificationObserver, + public TabContentsObserver { public: explicit TabContentsDelegateImpl(InstantLoader* loader); @@ -213,17 +214,25 @@ class InstantLoader::TabContentsDelegateImpl virtual bool ShouldAddNavigationToHistory( const history::HistoryAddPageArgs& add_page_args, NavigationType::Type navigation_type) OVERRIDE; - virtual void OnSetSuggestions( - int32 page_id, - const std::vector<std::string>& suggestions, - InstantCompleteBehavior behavior) OVERRIDE; - virtual void OnInstantSupportDetermined(int32 page_id, bool result) OVERRIDE; virtual bool ShouldShowHungRendererDialog() OVERRIDE; + // TabContentsObserver: + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + private: typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> > AddPageVector; + // Message from renderer indicating the page has suggestions. + void OnSetSuggestions( + int32 page_id, + const std::vector<std::string>& suggestions, + InstantCompleteBehavior behavior); + + // Messages from the renderer when we've determined whether the page supports + // instant. + void OnInstantSupportDetermined(int32 page_id, bool result); + void CommitFromMouseReleaseIfNecessary(); InstantLoader* loader_; @@ -255,7 +264,8 @@ class InstantLoader::TabContentsDelegateImpl InstantLoader::TabContentsDelegateImpl::TabContentsDelegateImpl( InstantLoader* loader) - : loader_(loader), + : TabContentsObserver(loader->preview_contents()->tab_contents()), + loader_(loader), registered_render_widget_host_(NULL), waiting_for_new_page_(true), is_mouse_down_from_activate_(false), @@ -535,6 +545,25 @@ bool InstantLoader::TabContentsDelegateImpl::ShouldAddNavigationToHistory( return false; } +bool InstantLoader::TabContentsDelegateImpl::ShouldShowHungRendererDialog() { + // If we allow the hung renderer dialog to be shown it'll gain focus, + // stealing focus from the omnibox causing instant to be cancelled. Return + // false so that doesn't happen. + return false; +} + +bool InstantLoader::TabContentsDelegateImpl::OnMessageReceived( + const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(TabContentsDelegateImpl, message) + IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestions, OnSetSuggestions) + IPC_MESSAGE_HANDLER(ViewHostMsg_InstantSupportDetermined, + OnInstantSupportDetermined) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions( int32 page_id, const std::vector<std::string>& suggestions, @@ -570,13 +599,6 @@ void InstantLoader::TabContentsDelegateImpl::OnInstantSupportDetermined( loader_->PageDoesntSupportInstant(user_typed_before_load_); } -bool InstantLoader::TabContentsDelegateImpl::ShouldShowHungRendererDialog() { - // If we allow the hung renderer dialog to be shown it'll gain focus, - // stealing focus from the omnibox causing instant to be cancelled. Return - // false so that doesn't happen. - return false; -} - void InstantLoader::TabContentsDelegateImpl ::CommitFromMouseReleaseIfNecessary() { bool was_down = is_mouse_down_from_activate_; |