| 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 4279332301f67b1bdb30d0a9c8cd2dbf42da5e40..6ae91253e82dcad77d762bd741bda206607e5420 100644
|
| --- a/chrome/browser/tab_contents/tab_contents.cc
|
| +++ b/chrome/browser/tab_contents/tab_contents.cc
|
| @@ -247,6 +247,7 @@ TabContents::TabContents(Profile* profile,
|
| encoding_(),
|
| blocked_popups_(NULL),
|
| infobar_delegates_(),
|
| + tab_modal_count_(0),
|
| find_ui_active_(false),
|
| find_op_aborted_(false),
|
| current_find_request_id_(find_request_id_counter_++),
|
| @@ -342,6 +343,12 @@ TabContents::~TabContents() {
|
| if (window)
|
| window->CloseConstrainedWindow();
|
| }
|
| + child_windows_.clear(); // Should be unnecessary, strictly speaking.
|
| + tab_modal_count_ = 0;
|
| +
|
| + // Notify whomever that things have changed.
|
| + if (delegate_)
|
| + delegate_->ChildWindowsChanged(this);
|
|
|
| if (blocked_popups_)
|
| blocked_popups_->Destroy();
|
| @@ -813,12 +820,46 @@ 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);
|
| +
|
| + // Possibly enter into the fully-tab-modal state.
|
| + if (window->GetModalityLevel() >= ConstrainedWindow::kModalForTab) {
|
| + DCHECK(tab_modal_count_ == 0);
|
| + tab_modal_count_++;
|
| + }
|
| +
|
| + // Notify whomever that things have changed.
|
| + if (delegate_)
|
| + delegate_->ChildWindowsChanged(this);
|
| +
|
| return window;
|
| }
|
|
|
| +ConstrainedWindow::ModalityLevel TabContents::GetTabModalityLevel() {
|
| + if (constrained_window_count() > 0) {
|
| + return (tab_modal_count_ > 0) ? ConstrainedWindow::kModalForTab :
|
| + ConstrainedWindow::kModalForContent;
|
| + }
|
| + return ConstrainedWindow::kModalNone;
|
| +}
|
| +
|
| +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,
|
| @@ -1036,8 +1077,24 @@ void TabContents::OnStartDownload(DownloadItem* download) {
|
| void TabContents::WillClose(ConstrainedWindow* window) {
|
| ConstrainedWindowList::iterator it =
|
| find(child_windows_.begin(), child_windows_.end(), window);
|
| - if (it != child_windows_.end())
|
| + if (it != child_windows_.end()) {
|
| + // Possibly move out of fully-tab-modal state.
|
| + if (window->GetModalityLevel() >= ConstrainedWindow::kModalForTab) {
|
| + if (tab_modal_count_ > 0)
|
| + tab_modal_count_--;
|
| + else
|
| + NOTREACHED();
|
| + }
|
| +
|
| + // Notify whomever that things have changed.
|
| + if (delegate_)
|
| + delegate_->ChildWindowsChanged(this);
|
| +
|
| + // Erase this child from our child-window list.
|
| child_windows_.erase(it);
|
| + } else {
|
| + NOTREACHED() << "Did not find child window being removed.";
|
| + }
|
| }
|
|
|
| void TabContents::WillCloseBlockedPopupContainer(
|
| @@ -1416,15 +1473,9 @@ 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.
|
| + // Those which are "content-area" windows should close themselves in response.
|
| + NotifyChildrenOfPendingEvent(ConstrainedWindow::kEventNavigate);
|
|
|
| // Close the popup container.
|
| if (blocked_popups_) {
|
| @@ -2243,9 +2294,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(
|
| @@ -2569,7 +2625,7 @@ void TabContents::Observe(NotificationType type,
|
| ) {
|
| UpdateWebPreferences();
|
| } else {
|
| - NOTREACHED() << "unexpected pref change notification" << *pref_name_in;
|
| + NOTREACHED() << "unexpected pref change notification " << *pref_name_in;
|
| }
|
| break;
|
| }
|
|
|