OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 5 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
6 | 6 |
7 #include "chrome/browser/ui/constrained_window.h" | 7 #include "chrome/browser/ui/constrained_window.h" |
8 #include "chrome/browser/ui/constrained_window_tab_helper_delegate.h" | 8 #include "chrome/browser/ui/constrained_window_tab_helper_delegate.h" |
9 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 ConstrainedWindowTabHelper::~ConstrainedWindowTabHelper() { | 27 ConstrainedWindowTabHelper::~ConstrainedWindowTabHelper() { |
28 DCHECK(child_windows_.empty()); | 28 DCHECK(child_windows_.empty()); |
29 } | 29 } |
30 | 30 |
31 void ConstrainedWindowTabHelper::AddConstrainedDialog( | 31 void ConstrainedWindowTabHelper::AddConstrainedDialog( |
32 ConstrainedWindow* window) { | 32 ConstrainedWindow* window) { |
33 child_windows_.push_back(window); | 33 child_windows_.push_back(window); |
34 | 34 |
35 if (child_windows_.size() == 1) { | 35 if (child_windows_.size() == 1 && window->GetCanShowConstrainedWindow()) { |
36 window->ShowConstrainedWindow(); | 36 window->ShowConstrainedWindow(); |
37 BlockTabContent(true); | 37 BlockTabContent(true); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 void ConstrainedWindowTabHelper::CloseConstrainedWindows() { | 41 void ConstrainedWindowTabHelper::CloseConstrainedWindows() { |
42 // Clear out any constrained windows since we are leaving this page entirely. | 42 // Clear out any constrained windows since we are leaving this page entirely. |
43 // To ensure that we iterate over every element in child_windows_ we | 43 // To ensure that we iterate over every element in child_windows_ we |
44 // need to use a copy of child_windows_. Otherwise if | 44 // need to use a copy of child_windows_. Otherwise if |
45 // window->CloseConstrainedWindow() modifies child_windows_ we could end up | 45 // window->CloseConstrainedWindow() modifies child_windows_ we could end up |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 void ConstrainedWindowTabHelper::WebContentsDestroyed(WebContents* tab) { | 107 void ConstrainedWindowTabHelper::WebContentsDestroyed(WebContents* tab) { |
108 // First cleanly close all child windows. | 108 // First cleanly close all child windows. |
109 // TODO(mpcomplete): handle case if MaybeCloseChildWindows() already asked | 109 // TODO(mpcomplete): handle case if MaybeCloseChildWindows() already asked |
110 // some of these to close. CloseWindows is async, so it might get called | 110 // some of these to close. CloseWindows is async, so it might get called |
111 // twice before it runs. | 111 // twice before it runs. |
112 CloseConstrainedWindows(); | 112 CloseConstrainedWindows(); |
113 } | 113 } |
OLD | NEW |