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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 321253003: Ensure show/hide are properly called on interstitial pages if present. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test compilation, add test case for the bug. Created 6 years, 6 months 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 unified diff | Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 on_frame.Run(node->current_frame_host()); 209 on_frame.Run(node->current_frame_host());
210 return true; 210 return true;
211 } 211 }
212 212
213 void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) { 213 void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) {
214 IPC::Message* message_copy = new IPC::Message(*message); 214 IPC::Message* message_copy = new IPC::Message(*message);
215 message_copy->set_routing_id(rfh->GetRoutingID()); 215 message_copy->set_routing_id(rfh->GetRoutingID());
216 rfh->Send(message_copy); 216 rfh->Send(message_copy);
217 } 217 }
218 218
219 void AddRenderWidgetHostToSet(std::set<RenderWidgetHostImpl*>* set, 219 void AddRenderWidgetHostViewToSet(std::set<RenderWidgetHostView*>* set,
220 RenderFrameHost* rfh) { 220 RenderFrameHost* rfh) {
221 set->insert(static_cast<RenderFrameHostImpl*>(rfh)->GetRenderWidgetHost()); 221 RenderWidgetHostView* rwhv = static_cast<RenderFrameHostImpl*>(rfh)
222 ->frame_tree_node()
223 ->render_manager()
224 ->GetRenderWidgetHostView();
225 set->insert(rwhv);
222 } 226 }
223 227
224 } // namespace 228 } // namespace
225 229
226 WebContents* WebContents::Create(const WebContents::CreateParams& params) { 230 WebContents* WebContents::Create(const WebContents::CreateParams& params) {
227 return WebContentsImpl::CreateWithOpener( 231 return WebContentsImpl::CreateWithOpener(
228 params, static_cast<WebContentsImpl*>(params.opener)); 232 params, static_cast<WebContentsImpl*>(params.opener));
229 } 233 }
230 234
231 WebContents* WebContents::CreateWithSessionStorage( 235 WebContents* WebContents::CreateWithSessionStorage(
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 delegate_->NavigationStateChanged(this, changed_flags); 938 delegate_->NavigationStateChanged(this, changed_flags);
935 } 939 }
936 940
937 base::TimeTicks WebContentsImpl::GetLastActiveTime() const { 941 base::TimeTicks WebContentsImpl::GetLastActiveTime() const {
938 return last_active_time_; 942 return last_active_time_;
939 } 943 }
940 944
941 void WebContentsImpl::WasShown() { 945 void WebContentsImpl::WasShown() {
942 controller_.SetActive(true); 946 controller_.SetActive(true);
943 947
944 std::set<RenderWidgetHostImpl*> widgets = GetRenderWidgetHostsInTree(); 948 std::set<RenderWidgetHostView*> widgets = GetRenderWidgetHostViewsInTree();
945 for (std::set<RenderWidgetHostImpl*>::iterator iter = widgets.begin(); 949 for (std::set<RenderWidgetHostView*>::iterator iter = widgets.begin();
946 iter != widgets.end(); 950 iter != widgets.end();
947 iter++) { 951 iter++) {
948 RenderWidgetHostView* rwhv = (*iter)->GetView(); 952 if (*iter) {
949 if (rwhv) { 953 (*iter)->Show();
950 rwhv->Show();
951 #if defined(OS_MACOSX) 954 #if defined(OS_MACOSX)
952 rwhv->SetActive(true); 955 (*iter)->SetActive(true);
953 #endif 956 #endif
954 } 957 }
955 } 958 }
956 959
957 last_active_time_ = base::TimeTicks::Now(); 960 last_active_time_ = base::TimeTicks::Now();
958 961
959 // The resize rect might have changed while this was inactive -- send the new 962 // The resize rect might have changed while this was inactive -- send the new
960 // one to make sure it's up to date. 963 // one to make sure it's up to date.
961 RenderViewHostImpl* rvh = 964 RenderViewHostImpl* rvh =
962 static_cast<RenderViewHostImpl*>(GetRenderViewHost()); 965 static_cast<RenderViewHostImpl*>(GetRenderViewHost());
963 if (rvh) { 966 if (rvh) {
964 rvh->ResizeRectChanged(GetRootWindowResizerRect()); 967 rvh->ResizeRectChanged(GetRootWindowResizerRect());
965 } 968 }
966 969
967 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); 970 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown());
968 971
969 should_normally_be_visible_ = true; 972 should_normally_be_visible_ = true;
970 } 973 }
971 974
972 void WebContentsImpl::WasHidden() { 975 void WebContentsImpl::WasHidden() {
973 // If there are entities capturing screenshots or video (e.g., mirroring), 976 // If there are entities capturing screenshots or video (e.g., mirroring),
974 // don't activate the "disable rendering" optimization. 977 // don't activate the "disable rendering" optimization.
975 if (capturer_count_ == 0) { 978 if (capturer_count_ == 0) {
976 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to 979 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to
977 // open a tab in the background, then closes the tab before selecting it. 980 // open a tab in the background, then closes the tab before selecting it.
978 // This is because closing the tab calls WebContentsImpl::Destroy(), which 981 // This is because closing the tab calls WebContentsImpl::Destroy(), which
979 // removes the |GetRenderViewHost()|; then when we actually destroy the 982 // removes the |GetRenderViewHost()|; then when we actually destroy the
980 // window, OnWindowPosChanged() notices and calls WasHidden() (which 983 // window, OnWindowPosChanged() notices and calls WasHidden() (which
981 // calls us). 984 // calls us).
982 std::set<RenderWidgetHostImpl*> widgets = GetRenderWidgetHostsInTree(); 985 std::set<RenderWidgetHostView*> widgets = GetRenderWidgetHostViewsInTree();
983 for (std::set<RenderWidgetHostImpl*>::iterator iter = widgets.begin(); 986 for (std::set<RenderWidgetHostView*>::iterator iter = widgets.begin();
984 iter != widgets.end(); 987 iter != widgets.end();
985 iter++) { 988 iter++) {
986 RenderWidgetHostView* rwhv = (*iter)->GetView(); 989 if (*iter)
987 if (rwhv) 990 (*iter)->Hide();
988 rwhv->Hide();
989 } 991 }
990 } 992 }
991 993
992 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); 994 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden());
993 995
994 should_normally_be_visible_ = false; 996 should_normally_be_visible_ = false;
995 } 997 }
996 998
997 bool WebContentsImpl::NeedToFireBeforeUnload() { 999 bool WebContentsImpl::NeedToFireBeforeUnload() {
998 // TODO(creis): Should we fire even for interstitial pages? 1000 // TODO(creis): Should we fire even for interstitial pages?
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 } 1137 }
1136 1138
1137 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { 1139 void WebContentsImpl::AddObserver(WebContentsObserver* observer) {
1138 observers_.AddObserver(observer); 1140 observers_.AddObserver(observer);
1139 } 1141 }
1140 1142
1141 void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) { 1143 void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) {
1142 observers_.RemoveObserver(observer); 1144 observers_.RemoveObserver(observer);
1143 } 1145 }
1144 1146
1145 std::set<RenderWidgetHostImpl*> WebContentsImpl::GetRenderWidgetHostsInTree() { 1147 std::set<RenderWidgetHostView*>
1146 std::set<RenderWidgetHostImpl*> set; 1148 WebContentsImpl::GetRenderWidgetHostViewsInTree() {
1147 ForEachFrame(base::Bind(&AddRenderWidgetHostToSet, base::Unretained(&set))); 1149 std::set<RenderWidgetHostView*> set;
1150 if (ShowingInterstitialPage()) {
1151 set.insert(GetRenderWidgetHostView());
1152 } else {
1153 ForEachFrame(
1154 base::Bind(&AddRenderWidgetHostViewToSet, base::Unretained(&set)));
1155 }
1148 return set; 1156 return set;
1149 } 1157 }
1150 1158
1151 void WebContentsImpl::Activate() { 1159 void WebContentsImpl::Activate() {
1152 if (delegate_) 1160 if (delegate_)
1153 delegate_->ActivateContents(this); 1161 delegate_->ActivateContents(this);
1154 } 1162 }
1155 1163
1156 void WebContentsImpl::Deactivate() { 1164 void WebContentsImpl::Deactivate() {
1157 if (delegate_) 1165 if (delegate_)
(...skipping 2900 matching lines...) Expand 10 before | Expand all | Expand 10 after
4058 4066
4059 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 4067 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
4060 if (!delegate_) 4068 if (!delegate_)
4061 return; 4069 return;
4062 const gfx::Size new_size = GetPreferredSize(); 4070 const gfx::Size new_size = GetPreferredSize();
4063 if (new_size != old_size) 4071 if (new_size != old_size)
4064 delegate_->UpdatePreferredSize(this, new_size); 4072 delegate_->UpdatePreferredSize(this, new_size);
4065 } 4073 }
4066 4074
4067 } // namespace content 4075 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698