Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3897)

Unified Diff: chrome/browser/instant/instant_loader.cc

Issue 11421079: Persist the Instant API to committed search result pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fixes Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_loader.cc
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index 1eadd705ac5e1b1521e76df6c5ae38f1c9df759e..34fa5c0f0d600c5ed7764dfcd3ecdaa5af4ed9bc 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/instant/instant_controller.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/thumbnails/thumbnail_tab_helper.h"
#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
@@ -14,13 +13,11 @@
#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/render_messages.h"
-#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
-#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents_delegate.h"
+#include "ipc/ipc_message.h"
namespace {
@@ -47,19 +44,10 @@ class InstantLoaderUserData : public base::SupportsUserData::Data {
class InstantLoader::WebContentsDelegateImpl
: public ConstrainedWindowTabHelperDelegate,
public CoreTabHelperDelegate,
- public content::WebContentsDelegate,
- public content::WebContentsObserver {
+ public content::WebContentsDelegate {
public:
explicit WebContentsDelegateImpl(InstantLoader* loader);
- bool is_pointer_down_from_activate() const {
- return is_pointer_down_from_activate_;
- }
-
- // Start observing |web_contents| instead of whatever is currently being
- // observed. If |web_contents| is NULL, effectively stops observing.
- void ObserveContents(content::WebContents* web_contents);
-
private:
// Overridden from ConstrainedWindowTabHelperDelegate:
virtual bool ShouldFocusConstrainedWindow() OVERRIDE;
@@ -83,47 +71,16 @@ class InstantLoader::WebContentsDelegateImpl
virtual void DragEnded() OVERRIDE;
virtual bool OnGoToEntryOffset(int offset) OVERRIDE;
- // Overridden from content::WebContentsObserver:
- virtual void DidFinishLoad(
- int64 frame_id,
- const GURL& validated_url,
- bool is_main_frame,
- content::RenderViewHost* render_view_host) OVERRIDE;
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
-
- // Message from renderer indicating the page has suggestions.
- void OnSetSuggestions(int page_id,
- const std::vector<InstantSuggestion>& suggestions);
-
- // 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 shown.
- void OnShowInstantPreview(int page_id,
- InstantShownReason reason,
- int height,
- InstantSizeUnits units);
-
- void CommitFromPointerReleaseIfNecessary();
- void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant);
+ void MaybeCommitFromPointerRelease();
InstantLoader* const loader_;
- // True if the mouse or a touch pointer is down from an activate.
- bool is_pointer_down_from_activate_;
-
DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateImpl);
};
InstantLoader::WebContentsDelegateImpl::WebContentsDelegateImpl(
InstantLoader* loader)
- : loader_(loader),
- is_pointer_down_from_activate_(false) {
-}
-
-void InstantLoader::WebContentsDelegateImpl::ObserveContents(
- content::WebContents* web_contents) {
- Observe(web_contents);
+ : loader_(loader) {
}
bool InstantLoader::WebContentsDelegateImpl::ShouldFocusConstrainedWindow() {
@@ -136,8 +93,8 @@ bool InstantLoader::WebContentsDelegateImpl::ShouldFocusConstrainedWindow() {
void InstantLoader::WebContentsDelegateImpl::SwapTabContents(
content::WebContents* old_contents,
content::WebContents* new_contents) {
- // If this is being called, something is swapping in to our
- // |preview_contents_| before we've added it to the tab strip.
+ // If this is being called, something is swapping in to loader's |contents_|
+ // before we've added it to the tab strip.
loader_->ReplacePreviewContents(old_contents, new_contents);
}
@@ -151,125 +108,53 @@ bool InstantLoader::WebContentsDelegateImpl::ShouldFocusPageAfterCrash() {
}
void InstantLoader::WebContentsDelegateImpl::LostCapture() {
- CommitFromPointerReleaseIfNecessary();
+ MaybeCommitFromPointerRelease();
}
void InstantLoader::WebContentsDelegateImpl::WebContentsFocused(
- content::WebContents* contents) {
- loader_->controller_->InstantLoaderContentsFocused(loader_);
+ content::WebContents* /* contents */) {
+ loader_->controller_->InstantLoaderContentsFocused();
}
bool InstantLoader::WebContentsDelegateImpl::CanDownload(
- content::RenderViewHost* render_view_host,
- int request_id,
- const std::string& request_method) {
+ content::RenderViewHost* /* render_view_host */,
+ int /* request_id */,
+ const std::string& /* request_method */) {
// Downloads are disabled.
return false;
}
void InstantLoader::WebContentsDelegateImpl::HandleMouseDown() {
- is_pointer_down_from_activate_ = true;
+ loader_->is_pointer_down_from_activate_ = true;
}
void InstantLoader::WebContentsDelegateImpl::HandleMouseUp() {
- CommitFromPointerReleaseIfNecessary();
+ MaybeCommitFromPointerRelease();
}
void InstantLoader::WebContentsDelegateImpl::HandlePointerActivate() {
- is_pointer_down_from_activate_ = true;
+ loader_->is_pointer_down_from_activate_ = true;
}
void InstantLoader::WebContentsDelegateImpl::HandleGestureEnd() {
- CommitFromPointerReleaseIfNecessary();
+ MaybeCommitFromPointerRelease();
}
void InstantLoader::WebContentsDelegateImpl::DragEnded() {
// If the user drags, we won't get a mouse up (at least on Linux). Commit the
// Instant result when the drag ends, so that during the drag the page won't
// move around.
- CommitFromPointerReleaseIfNecessary();
+ MaybeCommitFromPointerRelease();
}
bool InstantLoader::WebContentsDelegateImpl::OnGoToEntryOffset(int offset) {
return false;
}
-void InstantLoader::WebContentsDelegateImpl::DidFinishLoad(
- int64 frame_id,
- const GURL& validated_url,
- bool is_main_frame,
- content::RenderViewHost* render_view_host) {
- if (is_main_frame && !loader_->supports_instant_)
- Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(routing_id()));
-}
-
-bool InstantLoader::WebContentsDelegateImpl::OnMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(WebContentsDelegateImpl, message)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined,
- OnInstantSupportDetermined)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantPreview,
- OnShowInstantPreview);
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions(
- int page_id,
- const std::vector<InstantSuggestion>& suggestions) {
- DCHECK(loader_->preview_contents());
- DCHECK(loader_->preview_contents_->web_contents());
- content::NavigationEntry* entry = loader_->preview_contents_->web_contents()->
- GetController().GetActiveEntry();
- if (entry && page_id == entry->GetPageID()) {
- MaybeSetAndNotifyInstantSupportDetermined(true);
- loader_->controller_->SetSuggestions(loader_, suggestions);
- }
-}
-
-void InstantLoader::WebContentsDelegateImpl::OnInstantSupportDetermined(
- int page_id,
- bool result) {
- DCHECK(loader_->preview_contents());
- DCHECK(loader_->preview_contents_->web_contents());
- content::NavigationEntry* entry = loader_->preview_contents_->web_contents()->
- GetController().GetActiveEntry();
- if (entry && page_id == entry->GetPageID())
- MaybeSetAndNotifyInstantSupportDetermined(result);
-}
-
-void InstantLoader::WebContentsDelegateImpl::OnShowInstantPreview(
- int page_id,
- InstantShownReason reason,
- int height,
- InstantSizeUnits units) {
- DCHECK(loader_->preview_contents());
- DCHECK(loader_->preview_contents_->web_contents());
- content::NavigationEntry* entry = loader_->preview_contents_->web_contents()->
- GetController().GetActiveEntry();
- if (entry && page_id == entry->GetPageID()) {
- MaybeSetAndNotifyInstantSupportDetermined(true);
- loader_->controller_->ShowInstantPreview(loader_, reason, height, units);
- }
-}
-
-void InstantLoader::WebContentsDelegateImpl
- ::CommitFromPointerReleaseIfNecessary() {
- if (is_pointer_down_from_activate_) {
- is_pointer_down_from_activate_ = false;
- loader_->controller_->CommitInstantLoader(loader_);
- }
-}
-
-void InstantLoader::WebContentsDelegateImpl
- ::MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant) {
- // If we already determined that the loader supports Instant, nothing to do.
- if (!loader_->supports_instant_) {
- loader_->supports_instant_ = supports_instant;
- loader_->controller_->InstantSupportDetermined(loader_, supports_instant);
+void InstantLoader::WebContentsDelegateImpl::MaybeCommitFromPointerRelease() {
+ if (loader_->is_pointer_down_from_activate_) {
+ loader_->is_pointer_down_from_activate_ = false;
+ loader_->controller_->CommitIfCurrent(INSTANT_COMMIT_FOCUS_LOST);
}
}
@@ -277,145 +162,118 @@ void InstantLoader::WebContentsDelegateImpl
// static
InstantLoader* InstantLoader::FromWebContents(
- content::WebContents* web_contents) {
+ const content::WebContents* web_contents) {
InstantLoaderUserData* data = static_cast<InstantLoaderUserData*>(
web_contents->GetUserData(&kUserDataKey));
return data ? data->loader() : NULL;
}
InstantLoader::InstantLoader(InstantController* controller,
- const std::string& instant_url,
- const TabContents* tab_contents)
- : controller_(controller),
- preview_delegate_(new WebContentsDelegateImpl(
- ALLOW_THIS_IN_INITIALIZER_LIST(this))),
- preview_contents_(
- TabContents::Factory::CreateTabContents(
- content::WebContents::CreateWithSessionStorage(
- tab_contents->profile(), NULL, MSG_ROUTING_NONE,
- tab_contents->web_contents(),
- tab_contents->web_contents()->GetController().
- GetSessionStorageNamespaceMap()))),
+ const std::string& instant_url)
+ : client_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ controller_(controller),
+ delegate_(new WebContentsDelegateImpl(
+ ALLOW_THIS_IN_INITIALIZER_LIST(this))),
+ instant_url_(instant_url),
supports_instant_(false),
- instant_url_(instant_url) {
+ is_pointer_down_from_activate_(false) {
}
InstantLoader::~InstantLoader() {
}
-void InstantLoader::Init() {
+void InstantLoader::InitContents(const content::WebContents* active_tab) {
+ contents_.reset(content::WebContents::CreateWithSessionStorage(
+ active_tab->GetBrowserContext(), NULL, MSG_ROUTING_NONE, active_tab,
+ active_tab->GetController().GetSessionStorageNamespaceMap()));
+ // Not a leak. TabContents will delete itself when the WebContents is gone.
+ TabContents::Factory::CreateTabContents(contents());
SetupPreviewContents();
- // This HTTP header and value are set on loads that originate from instant.
+
+ // This HTTP header and value are set on loads that originate from Instant.
const char kInstantHeader[] = "X-Purpose: Instant";
DVLOG(1) << "LoadURL: " << instant_url_;
- preview_contents_->web_contents()->GetController().LoadURL(GURL(instant_url_),
- content::Referrer(), content::PAGE_TRANSITION_GENERATED, kInstantHeader);
- preview_contents_->web_contents()->WasHidden();
+ contents_->GetController().LoadURL(GURL(instant_url_), content::Referrer(),
+ content::PAGE_TRANSITION_GENERATED, kInstantHeader);
+ contents_->WasHidden();
}
-void InstantLoader::Update(const string16& user_text, bool verbatim) {
- // TODO: Support real cursor position.
+content::WebContents* InstantLoader::ReleaseContents() {
+ CleanupPreviewContents();
+ return contents_.release();
+}
+
+void InstantLoader::DidNavigate(
+ const history::HistoryAddPageArgs& add_page_args) {
+ last_navigation_ = add_page_args;
+}
+
+void InstantLoader::Update(const string16& text,
+ size_t selection_start,
+ size_t selection_end,
+ bool verbatim) {
last_navigation_ = history::HistoryAddPageArgs();
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxChange(rvh->GetRoutingID(), user_text,
- verbatim, user_text.size(), user_text.size()));
+ client_.Update(text, selection_start, selection_end, verbatim);
+}
+
+void InstantLoader::Submit(const string16& text) {
+ client_.Submit(text);
+}
+
+void InstantLoader::Cancel(const string16& text) {
+ client_.Cancel(text);
}
void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxResize(rvh->GetRoutingID(), bounds));
+ client_.SetOmniboxBounds(bounds);
}
void InstantLoader::SendAutocompleteResults(
const std::vector<InstantAutocompleteResult>& results) {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxAutocompleteResults(rvh->GetRoutingID(),
- results));
+ client_.SendAutocompleteResults(results);
}
-void InstantLoader::SendThemeBackgroundInfo(
- const ThemeBackgroundInfo& theme_info) {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxThemeChanged(rvh->GetRoutingID(),
- theme_info));
-}
-
-void InstantLoader::SendThemeAreaHeight(int height) {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxThemeAreaHeightChanged(
- rvh->GetRoutingID(), height));
+void InstantLoader::UpOrDownKeyPressed(int count) {
+ client_.UpOrDownKeyPressed(count);
}
-void InstantLoader::SetDisplayInstantResults(bool display_instant_results) {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxSetDisplayInstantResults(
- rvh->GetRoutingID(), display_instant_results));
+void InstantLoader::SearchModeChanged(const chrome::search::Mode& mode) {
+ client_.SearchModeChanged(mode);
}
-void InstantLoader::OnUpOrDownKeyPressed(int count) {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxUpOrDownKeyPressed(rvh->GetRoutingID(),
- count));
+void InstantLoader::SendThemeBackgroundInfo(
+ const ThemeBackgroundInfo& theme_info) {
+ client_.SendThemeBackgroundInfo(theme_info);
}
-void InstantLoader::SearchModeChanged(const chrome::search::Mode& mode) {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxModeChanged(rvh->GetRoutingID(), mode));
+void InstantLoader::SendThemeAreaHeight(int height) {
+ client_.SendThemeAreaHeight(height);
}
-void InstantLoader::DidNavigate(
- const history::HistoryAddPageArgs& add_page_args) {
- last_navigation_ = add_page_args;
+void InstantLoader::SetDisplayInstantResults(bool display_instant_results) {
+ client_.SetDisplayInstantResults(display_instant_results);
}
-TabContents* InstantLoader::ReleasePreviewContents(InstantCommitType type,
- const string16& text) {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- if (type == INSTANT_COMMIT_FOCUS_LOST)
- rvh->Send(new ChromeViewMsg_SearchBoxCancel(rvh->GetRoutingID(), text));
- else
- rvh->Send(new ChromeViewMsg_SearchBoxSubmit(rvh->GetRoutingID(), text));
- CleanupPreviewContents();
- return preview_contents_.release();
+void InstantLoader::SetSuggestions(
+ const std::vector<InstantSuggestion>& suggestions) {
+ InstantSupportDetermined(true);
+ controller_->SetSuggestions(contents(), suggestions);
}
-void InstantLoader::CleanupPreviewContents() {
- content::WebContents* old_contents = preview_contents_->web_contents();
- old_contents->RemoveUserData(&kUserDataKey);
- old_contents->SetDelegate(NULL);
- preview_delegate_->ObserveContents(NULL);
-
- BlockedContentTabHelper::FromWebContents(old_contents)->
- SetAllContentsBlocked(false);
- ConstrainedWindowTabHelper::FromWebContents(old_contents)->set_delegate(NULL);
- TabSpecificContentSettings::FromWebContents(old_contents)->
- SetPopupsBlocked(false);
- CoreTabHelper::FromWebContents(old_contents)->set_delegate(NULL);
- if (ThumbnailTabHelper* thumbnail_tab_helper =
- ThumbnailTabHelper::FromWebContents(old_contents))
- thumbnail_tab_helper->set_enabled(true);
+void InstantLoader::InstantSupportDetermined(bool supports_instant) {
+ // If we had already determined that the page supports Instant, nothing to do.
+ if (supports_instant_)
+ return;
-#if defined(OS_MACOSX)
- if (content::RenderWidgetHostView* rwhv =
- old_contents->GetRenderWidgetHostView())
- rwhv->SetTakesFocusOnlyOnMouseDown(false);
- registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- content::Source<content::NavigationController>(
- &old_contents->GetController()));
-#endif
+ supports_instant_ = supports_instant;
+ controller_->InstantSupportDetermined(contents(), supports_instant);
}
-bool InstantLoader::IsPointerDownFromActivate() const {
- return preview_delegate_->is_pointer_down_from_activate();
+void InstantLoader::ShowInstantPreview(InstantShownReason reason,
+ int height,
+ InstantSizeUnits units) {
+ InstantSupportDetermined(true);
+ controller_->ShowInstantPreview(reason, height, units);
}
void InstantLoader::Observe(int type,
@@ -424,7 +282,7 @@ void InstantLoader::Observe(int type,
#if defined(OS_MACOSX)
if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
if (content::RenderWidgetHostView* rwhv =
- preview_contents_->web_contents()->GetRenderWidgetHostView())
+ contents_->GetRenderWidgetHostView())
rwhv->SetTakesFocusOnlyOnMouseDown(true);
return;
}
@@ -433,46 +291,79 @@ void InstantLoader::Observe(int type,
}
void InstantLoader::SetupPreviewContents() {
- content::WebContents* new_contents = preview_contents_->web_contents();
- new_contents->SetUserData(&kUserDataKey, new InstantLoaderUserData(this));
- WebContentsDelegateImpl* new_delegate = preview_delegate_.get();
- new_contents->SetDelegate(new_delegate);
- new_delegate->ObserveContents(new_contents);
+ client_.SetContents(contents());
+ contents_->SetUserData(&kUserDataKey, new InstantLoaderUserData(this));
+ contents_->SetDelegate(delegate_.get());
// Disable popups and such (mainly to avoid losing focus and reverting the
// preview prematurely).
- BlockedContentTabHelper::FromWebContents(new_contents)->
- SetAllContentsBlocked(true);
- ConstrainedWindowTabHelper::FromWebContents(new_contents)->
- set_delegate(new_delegate);
- TabSpecificContentSettings::FromWebContents(new_contents)->
- SetPopupsBlocked(true);
- CoreTabHelper::FromWebContents(new_contents)->set_delegate(new_delegate);
+ if (BlockedContentTabHelper* blocked_content_tab_helper =
+ BlockedContentTabHelper::FromWebContents(contents()))
+ blocked_content_tab_helper->SetAllContentsBlocked(true);
+ if (ConstrainedWindowTabHelper* constrained_window_tab_helper =
+ ConstrainedWindowTabHelper::FromWebContents(contents()))
+ constrained_window_tab_helper->set_delegate(delegate_.get());
+ if (TabSpecificContentSettings* tab_specific_content_settings =
+ TabSpecificContentSettings::FromWebContents(contents()))
+ tab_specific_content_settings->SetPopupsBlocked(true);
+ if (CoreTabHelper* core_tab_helper =
+ CoreTabHelper::FromWebContents(contents()))
+ core_tab_helper->set_delegate(delegate_.get());
if (ThumbnailTabHelper* thumbnail_tab_helper =
- ThumbnailTabHelper::FromWebContents(new_contents))
+ ThumbnailTabHelper::FromWebContents(contents()))
thumbnail_tab_helper->set_enabled(false);
#if defined(OS_MACOSX)
- // If |preview_contents_| does not currently have a RWHV, we will call
- // SetTakesFocusOnlyOnMouseDown() as a result of the RENDER_VIEW_HOST_CHANGED
- // notification.
+ // If |contents_| doesn't yet have a RWHV, SetTakesFocusOnlyOnMouseDown() will
+ // be called later, when NOTIFICATION_RENDER_VIEW_HOST_CHANGED is received.
if (content::RenderWidgetHostView* rwhv =
- new_contents->GetRenderWidgetHostView())
+ contents_->GetRenderWidgetHostView())
rwhv->SetTakesFocusOnlyOnMouseDown(true);
registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<content::NavigationController>(
- &new_contents->GetController()));
+ &contents_->GetController()));
+#endif
+}
+
+void InstantLoader::CleanupPreviewContents() {
+ client_.SetContents(NULL);
+ contents_->RemoveUserData(&kUserDataKey);
+ contents_->SetDelegate(NULL);
+
+ if (BlockedContentTabHelper* blocked_content_tab_helper =
+ BlockedContentTabHelper::FromWebContents(contents()))
+ blocked_content_tab_helper->SetAllContentsBlocked(false);
+ if (ConstrainedWindowTabHelper* constrained_window_tab_helper =
+ ConstrainedWindowTabHelper::FromWebContents(contents()))
+ constrained_window_tab_helper->set_delegate(NULL);
+ if (TabSpecificContentSettings* tab_specific_content_settings =
+ TabSpecificContentSettings::FromWebContents(contents()))
+ tab_specific_content_settings->SetPopupsBlocked(false);
+ if (CoreTabHelper* core_tab_helper =
+ CoreTabHelper::FromWebContents(contents()))
+ core_tab_helper->set_delegate(NULL);
+ if (ThumbnailTabHelper* thumbnail_tab_helper =
+ ThumbnailTabHelper::FromWebContents(contents()))
+ thumbnail_tab_helper->set_enabled(true);
+
+#if defined(OS_MACOSX)
+ if (content::RenderWidgetHostView* rwhv =
+ contents_->GetRenderWidgetHostView())
+ rwhv->SetTakesFocusOnlyOnMouseDown(false);
+ registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
+ content::Source<content::NavigationController>(
+ &contents_->GetController()));
#endif
}
void InstantLoader::ReplacePreviewContents(content::WebContents* old_contents,
content::WebContents* new_contents) {
- DCHECK_EQ(old_contents, preview_contents_->web_contents());
+ DCHECK_EQ(old_contents, contents());
CleanupPreviewContents();
// We release here without deleting so that the caller still has the
- // responsibility for deleting the TabContents.
- ignore_result(preview_contents_.release());
- preview_contents_.reset(TabContents::FromWebContents(new_contents));
+ // responsibility for deleting the WebContents.
+ ignore_result(contents_.release());
+ contents_.reset(new_contents);
SetupPreviewContents();
- controller_->SwappedTabContents(this);
+ controller_->SwappedWebContents();
}

Powered by Google App Engine
This is Rietveld 408576698