Popups opened from popups should be constrained and subject to constrained popup limits.

This solves the UI issue, but there's still the backend stuff which I've filled as http://crbug.com/3382

BUG=2632
Review URL: http://codereview.chromium.org/7233

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3313 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc
index f323524..44de4ab 100644
--- a/chrome/browser/tab_contents.cc
+++ b/chrome/browser/tab_contents.cc
@@ -266,13 +266,13 @@
   if (!delegate_)
     return;
 
-  if ((disposition == NEW_POPUP) && !delegate_->IsPopup(this)) {
-    if (user_gesture) {
-      delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
-                                user_gesture);
-    } else {
-      AddConstrainedPopup(new_contents, initial_pos);
-    }
+  if ((disposition == NEW_POPUP) && !user_gesture) {
+    // Unrequested popups from normal pages are constrained.
+    TabContents* popup_owner = this;
+    TabContents* our_owner = delegate_->GetConstrainingContents(this);
+    if (our_owner)
+      popup_owner = our_owner;
+    popup_owner->AddConstrainedPopup(new_contents, initial_pos);
   } else {
     delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
                               user_gesture);