Chromium Code Reviews| Index: chrome/browser/instant/instant_loader.cc |
| diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc |
| index b954746701cdaf852703817f32c0c4e51a446b63..5c54e171ad5dd8a303247a7c68a752a1f2b09b0e 100644 |
| --- a/chrome/browser/instant/instant_loader.cc |
| +++ b/chrome/browser/instant/instant_loader.cc |
| @@ -15,6 +15,7 @@ |
| #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
| #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| +#include "chrome/common/instant_types.h" |
|
sreeram
2012/09/18 22:24:24
No need for this (already brought in by instant_lo
Jered
2012/09/18 22:46:24
Done.
|
| #include "chrome/common/render_messages.h" |
| #include "content/public/browser/navigation_entry.h" |
| #include "content/public/browser/notification_source.h" |
| @@ -79,6 +80,11 @@ class InstantLoader::WebContentsDelegateImpl |
| // Message from the renderer determining whether it supports the Instant API. |
| void OnInstantSupportDetermined(int page_id, bool result); |
| + // Message from the renderer requesting the preview be resized. |
| + void OnSetInstantPreviewHeight(int page_id, |
| + int height, |
| + InstantSizeUnits units); |
| + |
| void CommitFromPointerReleaseIfNecessary(); |
| void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant); |
| @@ -190,6 +196,8 @@ bool InstantLoader::WebContentsDelegateImpl::OnMessageReceived( |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
| OnInstantSupportDetermined) |
| + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetInstantPreviewHeight, |
| + OnSetInstantPreviewHeight); |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| return handled; |
| @@ -227,6 +235,23 @@ void InstantLoader::WebContentsDelegateImpl::OnInstantSupportDetermined( |
| MaybeSetAndNotifyInstantSupportDetermined(result); |
| } |
| +void InstantLoader::WebContentsDelegateImpl::OnSetInstantPreviewHeight( |
| + int page_id, |
| + int height, |
| + InstantSizeUnits units) { |
| + DCHECK(loader_->preview_contents() && |
| + loader_->preview_contents_->web_contents()); |
| + // TODO(sreeram): Remove this 'if' bandaid once bug 141875 is confirmed fixed. |
| + if (!loader_->preview_contents() || |
| + !loader_->preview_contents_->web_contents()) |
| + return; |
| + content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
| + GetController().GetActiveEntry(); |
| + if (entry && page_id == entry->GetPageID()) { |
| + MaybeSetAndNotifyInstantSupportDetermined(true); |
| + loader_->loader_delegate_->SetInstantPreviewHeight(loader_, height, units); |
| + } |
| +} |
| void InstantLoader::WebContentsDelegateImpl |
| ::CommitFromPointerReleaseIfNecessary() { |