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

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

Issue 7880003: content: Move constrained window code from TabContents to TabContentsWrapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac compile (add forward declaration to file that didn't have it) Created 9 years, 3 months 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/automation/testing_automation_provider.cc ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/instant/instant_loader.cc
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index d0a7d4a60fc44dddae797b928f73c459d5c00361..7794bfee23c1d0add859e81310c31e9e28408806 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -22,6 +22,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
+#include "chrome/browser/ui/constrained_window_tab_helper.h"
+#include "chrome/browser/ui/constrained_window_tab_helper_delegate.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h"
#include "chrome/common/chrome_notification_types.h"
@@ -146,6 +148,7 @@ void InstantLoader::FrameLoadObserver::Observe(
class InstantLoader::TabContentsDelegateImpl
: public TabContentsDelegate,
public TabContentsWrapperDelegate,
+ public ConstrainedWindowTabHelperDelegate,
public NotificationObserver,
public TabContentsObserver {
public:
@@ -184,8 +187,6 @@ class InstantLoader::TabContentsDelegateImpl
unsigned changed_flags) OVERRIDE;
virtual void AddNavigationHeaders(const GURL& url,
std::string* headers) OVERRIDE;
- virtual bool ShouldFocusConstrainedWindow() OVERRIDE;
- virtual void WillShowConstrainedWindow(TabContents* source) OVERRIDE;
virtual bool ShouldSuppressDialogs() OVERRIDE;
virtual void BeforeUnloadFired(TabContents* tab,
bool proceed,
@@ -209,6 +210,10 @@ class InstantLoader::TabContentsDelegateImpl
virtual void SwapTabContents(TabContentsWrapper* old_tc,
TabContentsWrapper* new_tc) OVERRIDE;
+ // ConstrainedWindowTabHelperDelegate:
+ virtual void WillShowConstrainedWindow(TabContentsWrapper* source) OVERRIDE;
+ virtual bool ShouldFocusConstrainedWindow() OVERRIDE;
+
// TabContentsObserver:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
@@ -421,23 +426,6 @@ void InstantLoader::TabContentsDelegateImpl::AddNavigationHeaders(
headers);
}
-bool InstantLoader::TabContentsDelegateImpl::ShouldFocusConstrainedWindow() {
- // Return false so that constrained windows are not initially focused. If
- // we did otherwise the preview would prematurely get committed when focus
- // goes to the constrained window.
- return false;
-}
-
-void InstantLoader::TabContentsDelegateImpl::WillShowConstrainedWindow(
- TabContents* source) {
- if (!loader_->ready()) {
- // A constrained window shown for an auth may not paint. Show the preview
- // contents.
- UnregisterForPaintNotifications();
- loader_->ShowPreview();
- }
-}
-
bool InstantLoader::TabContentsDelegateImpl::ShouldSuppressDialogs() {
// Any message shown during instant cancels instant, so we suppress them.
return true;
@@ -504,6 +492,22 @@ void InstantLoader::TabContentsDelegateImpl::SwapTabContents(
loader_->ReplacePreviewContents(old_tc, new_tc);
}
+bool InstantLoader::TabContentsDelegateImpl::ShouldFocusConstrainedWindow() {
+ // Return false so that constrained windows are not initially focused. If
+ // we did otherwise the preview would prematurely get committed when focus
+ // goes to the constrained window.
+ return false;
+}
+
+void InstantLoader::TabContentsDelegateImpl::WillShowConstrainedWindow(
+ TabContentsWrapper* source) {
+ if (!loader_->ready()) {
+ // A constrained window shown for an auth may not paint. Show the preview
+ // contents.
+ UnregisterForPaintNotifications();
+ loader_->ShowPreview();
+ }
+}
bool InstantLoader::TabContentsDelegateImpl::OnMessageReceived(
const IPC::Message& message) {
@@ -947,6 +951,7 @@ void InstantLoader::ReplacePreviewContents(TabContentsWrapper* old_tc,
SetupPreviewContents(old_tc);
// Cleanup the old preview contents.
+ old_tc->constrained_window_tab_helper()->set_delegate(NULL);
old_tc->tab_contents()->set_delegate(NULL);
old_tc->set_delegate(NULL);
@@ -972,6 +977,8 @@ void InstantLoader::SetupPreviewContents(TabContentsWrapper* tab_contents) {
preview_contents_->tab_contents()->set_delegate(
preview_tab_contents_delegate_.get());
preview_contents_->blocked_content_tab_helper()->SetAllContentsBlocked(true);
+ preview_contents_->constrained_window_tab_helper()->set_delegate(
+ preview_tab_contents_delegate_.get());
// Propagate the max page id. That way if we end up merging the two
// NavigationControllers (which happens if we commit) none of the page ids
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698