| Index: chrome/browser/tab_contents/tab_contents.cc
|
| diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
|
| index b4acc38e88f0e38efa1776587443259ab8028030..8bc7e74c4cc18c855becf1becefd17ffb4ea09fd 100644
|
| --- a/chrome/browser/tab_contents/tab_contents.cc
|
| +++ b/chrome/browser/tab_contents/tab_contents.cc
|
| @@ -331,6 +331,7 @@ TabContents::~TabContents() {
|
| if (window)
|
| window->CloseConstrainedWindow();
|
| }
|
| + child_windows_.clear(); // Should be unnecessary, strictly speaking.
|
|
|
| if (blocked_popups_)
|
| blocked_popups_->Destroy();
|
| @@ -761,12 +762,27 @@ void TabContents::ShowPageInfo(const GURL& url,
|
|
|
| ConstrainedWindow* TabContents::CreateConstrainedDialog(
|
| ConstrainedWindowDelegate* delegate) {
|
| + DCHECK(delegate);
|
| +
|
| ConstrainedWindow* window =
|
| ConstrainedWindow::CreateConstrainedDialog(this, delegate);
|
| + DCHECK(window);
|
| child_windows_.push_back(window);
|
| return window;
|
| }
|
|
|
| +void TabContents::NotifyChildrenOfPendingEvent(ConstrainedWindow::Event event) {
|
| + // Make a copy of the list, since child windows may delete themselves from it
|
| + // (or conceivably worse) while we're iterating through.
|
| + ConstrainedWindowList children = child_windows_;
|
| +
|
| + ConstrainedWindowList::iterator it, end;
|
| + for (it = children.begin(), end = children.end(); it != end; ++it) {
|
| + if (*it)
|
| + (*it)->ParentWillDo(event);
|
| + }
|
| +}
|
| +
|
| void TabContents::AddNewContents(TabContents* new_contents,
|
| WindowOpenDisposition disposition,
|
| const gfx::Rect& initial_pos,
|
| @@ -998,6 +1014,8 @@ void TabContents::WillClose(ConstrainedWindow* window) {
|
| find(child_windows_.begin(), child_windows_.end(), window);
|
| if (it != child_windows_.end())
|
| child_windows_.erase(it);
|
| + else
|
| + NOTREACHED();
|
| }
|
|
|
| void TabContents::WillCloseBlockedPopupContainer(
|
| @@ -1387,15 +1405,10 @@ void TabContents::MaybeCloseChildWindows(const GURL& previous_url,
|
| previous_url, current_url))
|
| return;
|
|
|
| - // Clear out any child windows since we are leaving this page entirely.
|
| - // We use indices instead of iterators in case CloseWindow does something
|
| - // that may invalidate an iterator.
|
| - int size = static_cast<int>(child_windows_.size());
|
| - for (int i = size - 1; i >= 0; --i) {
|
| - ConstrainedWindow* window = child_windows_[i];
|
| - if (window)
|
| - window->CloseConstrainedWindow();
|
| - }
|
| + // We inform constrained child windows that we are about to navigate away;
|
| + // they should close themselves in response if appropriate (e.g., if they are
|
| + // "content-area" windows).
|
| + NotifyChildrenOfPendingEvent(ConstrainedWindow::kEventNavigate);
|
|
|
| // Close the popup container.
|
| if (blocked_popups_) {
|
| @@ -2264,9 +2277,14 @@ void TabContents::RunFileChooser(bool multiple_files,
|
| SelectFileDialog::Type dialog_type =
|
| multiple_files ? SelectFileDialog::SELECT_OPEN_MULTI_FILE :
|
| SelectFileDialog::SELECT_OPEN_FILE;
|
| +#if defined(OS_MACOSX)
|
| + select_file_dialog_->SelectFileInTab(dialog_type, title, default_file, NULL,
|
| + 0, FILE_PATH_LITERAL(""), this, NULL);
|
| +#else
|
| select_file_dialog_->SelectFile(dialog_type, title, default_file,
|
| NULL, 0, FILE_PATH_LITERAL(""),
|
| view_->GetTopLevelNativeWindow(), NULL);
|
| +#endif
|
| }
|
|
|
| void TabContents::RunJavaScriptMessage(
|
|
|