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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 298283003: Add WasShown/WasHidden to RenderFrameObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT. Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/renderer/render_frame_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 1256f58c10f136a077a2871972a853f07725c108..6ed02ce9fe313491114cffcedede6a9f14b08ea0 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -217,6 +217,11 @@ void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) {
rfh->Send(message_copy);
}
+void AddRenderWidgetHostToSet(std::set<RenderWidgetHostImpl*>* set,
+ RenderFrameHost* rfh) {
+ set->insert(static_cast<RenderFrameHostImpl*>(rfh)->GetRenderWidgetHost());
+}
+
} // namespace
WebContents* WebContents::Create(const WebContents::CreateParams& params) {
@@ -938,12 +943,18 @@ base::TimeTicks WebContentsImpl::GetLastActiveTime() const {
void WebContentsImpl::WasShown() {
controller_.SetActive(true);
- RenderWidgetHostView* rwhv = GetRenderWidgetHostView();
- if (rwhv) {
- rwhv->Show();
+
+ std::set<RenderWidgetHostImpl*> widgets = GetRenderWidgetHostsInTree();
+ for (std::set<RenderWidgetHostImpl*>::iterator iter = widgets.begin();
+ iter != widgets.end();
+ iter++) {
+ RenderWidgetHostView* rwhv = (*iter)->GetView();
+ if (rwhv) {
+ rwhv->Show();
#if defined(OS_MACOSX)
- rwhv->SetActive(true);
+ rwhv->SetActive(true);
#endif
+ }
}
last_active_time_ = base::TimeTicks::Now();
@@ -971,9 +982,14 @@ void WebContentsImpl::WasHidden() {
// removes the |GetRenderViewHost()|; then when we actually destroy the
// window, OnWindowPosChanged() notices and calls WasHidden() (which
// calls us).
- RenderWidgetHostView* rwhv = GetRenderWidgetHostView();
- if (rwhv)
- rwhv->Hide();
+ std::set<RenderWidgetHostImpl*> widgets = GetRenderWidgetHostsInTree();
+ for (std::set<RenderWidgetHostImpl*>::iterator iter = widgets.begin();
+ iter != widgets.end();
+ iter++) {
+ RenderWidgetHostView* rwhv = (*iter)->GetView();
+ if (rwhv)
+ rwhv->Hide();
+ }
}
FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden());
@@ -1129,6 +1145,12 @@ void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) {
observers_.RemoveObserver(observer);
}
+std::set<RenderWidgetHostImpl*> WebContentsImpl::GetRenderWidgetHostsInTree() {
+ std::set<RenderWidgetHostImpl*> set;
+ ForEachFrame(base::Bind(&AddRenderWidgetHostToSet, base::Unretained(&set)));
+ return set;
+}
+
void WebContentsImpl::Activate() {
if (delegate_)
delegate_->ActivateContents(this);
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/renderer/render_frame_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698