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

Unified Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 459008: Mac: the return of the tab-modal-sheets patch. (Closed)
Patch Set: Merged ToT. Must ... commit ... soon. Created 11 years 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/tab_contents/tab_contents.h ('k') | chrome/browser/views/shell_dialogs_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/views/shell_dialogs_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698