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

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

Issue 5073002: Modifies the Instant loader to listen for RENDER_VIEW_HOST_CHANGED notificati... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « chrome/browser/instant/instant_loader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/instant/instant_loader.cc
===================================================================
--- chrome/browser/instant/instant_loader.cc (revision 66159)
+++ chrome/browser/instant/instant_loader.cc (working copy)
@@ -30,6 +30,7 @@
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_type.h"
#include "chrome/common/page_transition_types.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/renderer_preferences.h"
@@ -390,6 +391,8 @@
}
InstantLoader::~InstantLoader() {
+ registrar_.RemoveAll();
+
// Delete the TabContents before the delegate as the TabContents holds a
// reference to the delegate.
preview_contents_.reset(NULL);
@@ -429,6 +432,20 @@
tab_contents->view()->GetContainerBounds(&tab_bounds);
preview_contents_->view()->SizeContents(tab_bounds.size());
+#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 (preview_contents_->GetRenderWidgetHostView()) {
+ preview_contents_->GetRenderWidgetHostView()->
+ SetTakesFocusOnlyOnMouseDown(true);
+ }
+ registrar_.Add(
+ this,
+ NotificationType::RENDER_VIEW_HOST_CHANGED,
+ Source<NavigationController>(&preview_contents_->controller()));
+#endif
+
preview_contents_->ShowContents();
created_preview_contents = true;
} else {
@@ -537,6 +554,10 @@
#if defined(OS_MACOSX)
preview_contents_->GetRenderWidgetHostView()->
SetTakesFocusOnlyOnMouseDown(false);
+ registrar_.Remove(
+ this,
+ NotificationType::RENDER_VIEW_HOST_CHANGED,
+ Source<NavigationController>(&preview_contents_->controller()));
#endif
}
preview_contents_->set_delegate(NULL);
@@ -604,16 +625,26 @@
void InstantLoader::ShowPreview() {
if (!ready_) {
ready_ = true;
-#if defined(OS_MACOSX)
- if (preview_contents_->GetRenderWidgetHostView()) {
- preview_contents_->GetRenderWidgetHostView()->
- SetTakesFocusOnlyOnMouseDown(true);
- }
-#endif
delegate_->ShowInstantLoader(this);
}
}
+void InstantLoader::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+#if defined(OS_MACOSX)
+ if (type.value == NotificationType::RENDER_VIEW_HOST_CHANGED) {
+ if (preview_contents_->GetRenderWidgetHostView()) {
+ preview_contents_->GetRenderWidgetHostView()->
+ SetTakesFocusOnlyOnMouseDown(true);
+ }
+ return;
+ }
+#endif
+
+ NOTREACHED() << "Got a notification we didn't register for.";
+}
+
void InstantLoader::PageFinishedLoading() {
frame_load_observer_.reset();
// Wait for the user input before showing, this way the page should be up to
« no previous file with comments | « chrome/browser/instant/instant_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698