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 6b1407b78e0ace939218a24a5478b0c23d48f1c3..5f5e8f4658be5c5c67a33877d31bfd996c6045c5 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -279,15 +279,16 @@ void WebContentsImpl::FriendZone::RemoveCreatedCallbackForTesting( |
} |
} |
-WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { |
+WebContents* WebContents::FromRenderViewHost(RenderViewHost* rvh) { |
+ if (!rvh) |
+ return nullptr; |
return rvh->GetDelegate()->GetAsWebContents(); |
} |
WebContents* WebContents::FromRenderFrameHost(RenderFrameHost* rfh) { |
- RenderFrameHostImpl* rfh_impl = static_cast<RenderFrameHostImpl*>(rfh); |
- if (!rfh_impl) |
- return NULL; |
- return rfh_impl->delegate()->GetAsWebContents(); |
+ if (!rfh) |
+ return nullptr; |
+ return static_cast<RenderFrameHostImpl*>(rfh)->delegate()->GetAsWebContents(); |
} |
// WebContentsImpl::DestructionObserver ---------------------------------------- |
@@ -548,19 +549,17 @@ std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() { |
RenderWidgetHostImpl::GetRenderWidgetHosts()); |
std::set<WebContentsImpl*> web_contents_set; |
ncarter (slow)
2015/10/26 20:27:35
Delete this line.
Avi (use Gerrit)
2015/10/26 20:36:57
Done.
|
while (RenderWidgetHost* rwh = widgets->GetNextHost()) { |
- if (!rwh->IsRenderView()) |
- continue; |
RenderViewHost* rvh = RenderViewHost::From(rwh); |
if (!rvh) |
continue; |
WebContents* web_contents = WebContents::FromRenderViewHost(rvh); |
if (!web_contents) |
continue; |
- WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents); |
- if (web_contents_set.find(wci) == web_contents_set.end()) { |
- web_contents_set.insert(wci); |
- result.push_back(wci); |
- } |
+ if (web_contents->GetRenderViewHost() != rvh) |
+ continue; |
+ // Because a WebContents can only have one current RVH at a time, there will |
+ // be no duplicate WebContents here. |
+ result.push_back(static_cast<WebContentsImpl*>(web_contents)); |
} |
return result; |
} |