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

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

Issue 1411203010: Separate RenderViewHost from RenderWidgetHost, part 4: delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nick Created 5 years, 1 month 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
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/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void WebContentsImpl::FriendZone::RemoveCreatedCallbackForTesting( 272 void WebContentsImpl::FriendZone::RemoveCreatedCallbackForTesting(
273 const CreatedCallback& callback) { 273 const CreatedCallback& callback) {
274 for (size_t i = 0; i < g_created_callbacks.Get().size(); ++i) { 274 for (size_t i = 0; i < g_created_callbacks.Get().size(); ++i) {
275 if (g_created_callbacks.Get().at(i).Equals(callback)) { 275 if (g_created_callbacks.Get().at(i).Equals(callback)) {
276 g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i); 276 g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i);
277 return; 277 return;
278 } 278 }
279 } 279 }
280 } 280 }
281 281
282 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { 282 WebContents* WebContents::FromRenderViewHost(RenderViewHost* rvh) {
283 if (!rvh)
284 return nullptr;
283 return rvh->GetDelegate()->GetAsWebContents(); 285 return rvh->GetDelegate()->GetAsWebContents();
284 } 286 }
285 287
286 WebContents* WebContents::FromRenderFrameHost(RenderFrameHost* rfh) { 288 WebContents* WebContents::FromRenderFrameHost(RenderFrameHost* rfh) {
287 RenderFrameHostImpl* rfh_impl = static_cast<RenderFrameHostImpl*>(rfh); 289 if (!rfh)
288 if (!rfh_impl) 290 return nullptr;
289 return NULL; 291 return static_cast<RenderFrameHostImpl*>(rfh)->delegate()->GetAsWebContents();
290 return rfh_impl->delegate()->GetAsWebContents();
291 } 292 }
292 293
293 // WebContentsImpl::DestructionObserver ---------------------------------------- 294 // WebContentsImpl::DestructionObserver ----------------------------------------
294 295
295 class WebContentsImpl::DestructionObserver : public WebContentsObserver { 296 class WebContentsImpl::DestructionObserver : public WebContentsObserver {
296 public: 297 public:
297 DestructionObserver(WebContentsImpl* owner, WebContents* watched_contents) 298 DestructionObserver(WebContentsImpl* owner, WebContents* watched_contents)
298 : WebContentsObserver(watched_contents), 299 : WebContentsObserver(watched_contents),
299 owner_(owner) { 300 owner_(owner) {
300 } 301 }
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } 540 }
540 new_contents->Init(params); 541 new_contents->Init(params);
541 return new_contents; 542 return new_contents;
542 } 543 }
543 544
544 // static 545 // static
545 std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() { 546 std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() {
546 std::vector<WebContentsImpl*> result; 547 std::vector<WebContentsImpl*> result;
547 scoped_ptr<RenderWidgetHostIterator> widgets( 548 scoped_ptr<RenderWidgetHostIterator> widgets(
548 RenderWidgetHostImpl::GetRenderWidgetHosts()); 549 RenderWidgetHostImpl::GetRenderWidgetHosts());
549 std::set<WebContentsImpl*> web_contents_set; 550 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.
550 while (RenderWidgetHost* rwh = widgets->GetNextHost()) { 551 while (RenderWidgetHost* rwh = widgets->GetNextHost()) {
551 if (!rwh->IsRenderView())
552 continue;
553 RenderViewHost* rvh = RenderViewHost::From(rwh); 552 RenderViewHost* rvh = RenderViewHost::From(rwh);
554 if (!rvh) 553 if (!rvh)
555 continue; 554 continue;
556 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); 555 WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
557 if (!web_contents) 556 if (!web_contents)
558 continue; 557 continue;
559 WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents); 558 if (web_contents->GetRenderViewHost() != rvh)
560 if (web_contents_set.find(wci) == web_contents_set.end()) { 559 continue;
561 web_contents_set.insert(wci); 560 // Because a WebContents can only have one current RVH at a time, there will
562 result.push_back(wci); 561 // be no duplicate WebContents here.
563 } 562 result.push_back(static_cast<WebContentsImpl*>(web_contents));
564 } 563 }
565 return result; 564 return result;
566 } 565 }
567 566
568 // static 567 // static
569 WebContentsImpl* WebContentsImpl::FromFrameTreeNode( 568 WebContentsImpl* WebContentsImpl::FromFrameTreeNode(
570 FrameTreeNode* frame_tree_node) { 569 FrameTreeNode* frame_tree_node) {
571 return static_cast<WebContentsImpl*>( 570 return static_cast<WebContentsImpl*>(
572 WebContents::FromRenderFrameHost(frame_tree_node->current_frame_host())); 571 WebContents::FromRenderFrameHost(frame_tree_node->current_frame_host()));
573 } 572 }
(...skipping 4076 matching lines...) Expand 10 before | Expand all | Expand 10 after
4650 return NULL; 4649 return NULL;
4651 } 4650 }
4652 4651
4653 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4652 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4654 force_disable_overscroll_content_ = force_disable; 4653 force_disable_overscroll_content_ = force_disable;
4655 if (view_) 4654 if (view_)
4656 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4655 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4657 } 4656 }
4658 4657
4659 } // namespace content 4658 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698