summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 23:18:33 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 23:18:33 +0000
commit2eaf9dd9583136aea0dbb133f632226d8771e02c (patch)
tree7fb4f12c3ea130e91acd5a603b1b241e2b2209af
parentf6dba747f2ab7dd162a7c2d10d69a172bebfd84d (diff)
downloadchromium_src-2eaf9dd9583136aea0dbb133f632226d8771e02c.zip
chromium_src-2eaf9dd9583136aea0dbb133f632226d8771e02c.tar.gz
chromium_src-2eaf9dd9583136aea0dbb133f632226d8771e02c.tar.bz2
Makes instant show SSL error page. Because these end up with a
different RenderViewHost I wasn't seeing the paint, and wasn't showing the preview. I've plumbed through notification so that I can detect this case. I'm writing the test for this separately. BUG=74085 TEST=see bug Review URL: http://codereview.chromium.org/6597056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76458 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/instant/instant_loader.cc40
-rw-r--r--chrome/common/notification_type.h4
-rw-r--r--content/browser/tab_contents/interstitial_page.cc6
3 files changed, 29 insertions, 21 deletions
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index 2578aaf..2163bb1 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -145,10 +145,6 @@ class InstantLoader::TabContentsDelegateImpl
// Invoked prior to loading a new URL.
void PrepareForNewLoad();
- // Invoked when removed as the delegate. Gives a chance to do any necessary
- // cleanup.
- void Reset();
-
// Invoked when the preview paints. Invokes PreviewPainted on the loader.
void PreviewPainted();
@@ -263,6 +259,9 @@ InstantLoader::TabContentsDelegateImpl::TabContentsDelegateImpl(
waiting_for_new_page_(true),
is_mouse_down_from_activate_(false),
user_typed_before_load_(false) {
+ DCHECK(loader->preview_contents());
+ registrar_.Add(this, NotificationType::INTERSTITIAL_ATTACHED,
+ Source<TabContents>(loader->preview_contents()->tab_contents()));
}
void InstantLoader::TabContentsDelegateImpl::PrepareForNewLoad() {
@@ -272,11 +271,6 @@ void InstantLoader::TabContentsDelegateImpl::PrepareForNewLoad() {
UnregisterForPaintNotifications();
}
-void InstantLoader::TabContentsDelegateImpl::Reset() {
- is_mouse_down_from_activate_ = false;
- UnregisterForPaintNotifications();
-}
-
void InstantLoader::TabContentsDelegateImpl::PreviewPainted() {
loader_->PreviewPainted();
}
@@ -367,13 +361,19 @@ void InstantLoader::TabContentsDelegateImpl::Observe(
NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- if (type == NotificationType::RENDER_WIDGET_HOST_DID_PAINT) {
- UnregisterForPaintNotifications();
- PreviewPainted();
- } else if (type == NotificationType::RENDER_WIDGET_HOST_DESTROYED) {
- UnregisterForPaintNotifications();
- } else {
- NOTREACHED() << "Got a notification we didn't register for.";
+ switch (type.value) {
+ case NotificationType::RENDER_WIDGET_HOST_DID_PAINT:
+ UnregisterForPaintNotifications();
+ PreviewPainted();
+ break;
+ case NotificationType::RENDER_WIDGET_HOST_DESTROYED:
+ UnregisterForPaintNotifications();
+ break;
+ case NotificationType::INTERSTITIAL_ATTACHED:
+ PreviewPainted();
+ break;
+ default:
+ NOTREACHED() << "Got a notification we didn't register for.";
}
}
@@ -570,14 +570,11 @@ InstantLoader::InstantLoader(InstantLoaderDelegate* delegate, TemplateURLID id)
template_url_id_(id),
ready_(false),
last_transition_type_(PageTransition::LINK) {
- preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this));
}
InstantLoader::~InstantLoader() {
registrar_.RemoveAll();
- preview_tab_contents_delegate_->Reset();
-
// Delete the TabContents before the delegate as the TabContents holds a
// reference to the delegate.
preview_contents_.reset();
@@ -716,7 +713,8 @@ void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) {
}
bool InstantLoader::IsMouseDownFromActivate() {
- return preview_tab_contents_delegate_->is_mouse_down_from_activate();
+ return preview_tab_contents_delegate_.get() &&
+ preview_tab_contents_delegate_->is_mouse_down_from_activate();
}
TabContentsWrapper* InstantLoader::ReleasePreviewContents(
@@ -762,7 +760,6 @@ TabContentsWrapper* InstantLoader::ReleasePreviewContents(
#endif
}
preview_contents_->tab_contents()->set_delegate(NULL);
- preview_tab_contents_delegate_->Reset();
ready_ = false;
}
update_bounds_timer_.Stop();
@@ -918,6 +915,7 @@ void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) {
if (max_page_id != -1)
preview_contents_->controller().set_max_restored_page_id(max_page_id + 1);
+ preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this));
new_contents->set_delegate(preview_tab_contents_delegate_.get());
gfx::Rect tab_bounds;
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index 094f2d7..8394620 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -407,6 +407,10 @@ class NotificationType {
// pointer.
RENDER_VIEW_HOST_CREATED_FOR_TAB,
+ // Notification than an interstitial has become associated with a tab. The
+ // source is the TabContents, the details not used.
+ INTERSTITIAL_ATTACHED,
+
// Stuff inside the tabs ---------------------------------------------------
// This message is sent after a constrained window has been closed. The
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc
index c97d946..0dd06ea 100644
--- a/content/browser/tab_contents/interstitial_page.cc
+++ b/content/browser/tab_contents/interstitial_page.cc
@@ -19,6 +19,7 @@
#include "chrome/common/bindings_policy.h"
#include "chrome/common/dom_storage_common.h"
#include "chrome/common/net/url_request_context_getter.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/notification_source.h"
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/render_process_host.h"
@@ -355,6 +356,11 @@ void InterstitialPage::DidNavigate(
render_view_host_->view()->Show();
tab_->set_interstitial_page(this);
+ NotificationService::current()->Notify(
+ NotificationType::INTERSTITIAL_ATTACHED,
+ Source<TabContents>(tab_),
+ NotificationService::NoDetails());
+
RenderWidgetHostView* rwh_view = tab_->render_view_host()->view();
// The RenderViewHost may already have crashed before we even get here.