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

Side by Side Diff: chrome/browser/prerender/prerender_contents.cc

Issue 10107002: TabContents -> WebContentsImpl, part 18. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
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 "chrome/browser/prerender/prerender_contents.h" 5 #include "chrome/browser/prerender/prerender_contents.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 virtual void JSOutOfMemory(WebContents* tab) OVERRIDE { 175 virtual void JSOutOfMemory(WebContents* tab) OVERRIDE {
176 prerender_contents_->OnJSOutOfMemory(); 176 prerender_contents_->OnJSOutOfMemory();
177 } 177 }
178 178
179 virtual bool ShouldSuppressDialogs() OVERRIDE { 179 virtual bool ShouldSuppressDialogs() OVERRIDE {
180 return prerender_contents_->ShouldSuppressDialogs(); 180 return prerender_contents_->ShouldSuppressDialogs();
181 } 181 }
182 182
183 // Commits the History of Pages to the given TabContents. 183 // Commits the History of Pages to the given TabContentsWrapper.
184 void CommitHistory(TabContentsWrapper* tab) { 184 void CommitHistory(TabContentsWrapper* tab) {
185 for (size_t i = 0; i < add_page_vector_.size(); ++i) 185 for (size_t i = 0; i < add_page_vector_.size(); ++i)
186 tab->history_tab_helper()->UpdateHistoryForNavigation( 186 tab->history_tab_helper()->UpdateHistoryForNavigation(
187 add_page_vector_[i].get()); 187 add_page_vector_[i].get());
188 } 188 }
189 189
190 private: 190 private:
191 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> > 191 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> >
192 AddPageVector; 192 AddPageVector;
193 193
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 active_browser->active_index()); 309 active_browser->active_index());
310 if (active_web_contents) 310 if (active_web_contents)
311 active_web_contents->GetView()->GetContainerBounds(&tab_bounds); 311 active_web_contents->GetView()->GetContainerBounds(&tab_bounds);
312 } 312 }
313 #endif // !defined(OS_ANDROID) 313 #endif // !defined(OS_ANDROID)
314 } 314 }
315 315
316 tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); 316 tab_contents_delegate_.reset(new TabContentsDelegateImpl(this));
317 new_contents->SetDelegate(tab_contents_delegate_.get()); 317 new_contents->SetDelegate(tab_contents_delegate_.get());
318 318
319 // Set the size of the prerender TabContents. 319 // Set the size of the prerender WebContents.
320 prerender_contents_->web_contents()->GetView()->SizeContents( 320 prerender_contents_->web_contents()->GetView()->SizeContents(
321 tab_bounds.size()); 321 tab_bounds.size());
322 322
323 // Register as an observer of the RenderViewHost so we get messages. 323 // Register as an observer of the RenderViewHost so we get messages.
324 render_view_host_observer_.reset( 324 render_view_host_observer_.reset(
325 new PrerenderRenderViewHostObserver(this, render_view_host_mutable())); 325 new PrerenderRenderViewHostObserver(this, render_view_host_mutable()));
326 326
327 child_id_ = render_view_host()->GetProcess()->GetID(); 327 child_id_ = render_view_host()->GetProcess()->GetID();
328 route_id_ = render_view_host()->GetRoutingID(); 328 route_id_ = render_view_host()->GetRoutingID();
329 329
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 403
404 if (child_id_ != -1 && route_id_ != -1) { 404 if (child_id_ != -1 && route_id_ != -1) {
405 prerender_tracker_->OnPrerenderingFinished(child_id_, route_id_); 405 prerender_tracker_->OnPrerenderingFinished(child_id_, route_id_);
406 for (std::vector<GURL>::const_iterator it = alias_urls_.begin(); 406 for (std::vector<GURL>::const_iterator it = alias_urls_.begin();
407 it != alias_urls_.end(); 407 it != alias_urls_.end();
408 ++it) { 408 ++it) {
409 InformRenderProcessAboutPrerender(*it, false, creator_child_id_); 409 InformRenderProcessAboutPrerender(*it, false, creator_child_id_);
410 } 410 }
411 } 411 }
412 412
413 // If we still have a TabContents, clean up anything we need to and then 413 // If we still have a WebContents, clean up anything we need to and then
414 // destroy it. 414 // destroy it.
415 if (prerender_contents_.get()) 415 if (prerender_contents_.get())
416 delete ReleasePrerenderContents(); 416 delete ReleasePrerenderContents();
417 } 417 }
418 418
419 void PrerenderContents::Observe(int type, 419 void PrerenderContents::Observe(int type,
420 const content::NotificationSource& source, 420 const content::NotificationSource& source,
421 const content::NotificationDetails& details) { 421 const content::NotificationDetails& details) {
422 switch (type) { 422 switch (type) {
423 case chrome::NOTIFICATION_PROFILE_DESTROYED: 423 case chrome::NOTIFICATION_PROFILE_DESTROYED:
(...skipping 23 matching lines...) Expand all
447 } 447 }
448 448
449 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { 449 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: {
450 if (prerender_contents_.get()) { 450 if (prerender_contents_.get()) {
451 DCHECK_EQ(content::Source<WebContents>(source).ptr(), 451 DCHECK_EQ(content::Source<WebContents>(source).ptr(),
452 prerender_contents_->web_contents()); 452 prerender_contents_->web_contents());
453 453
454 content::Details<RenderViewHost> new_render_view_host(details); 454 content::Details<RenderViewHost> new_render_view_host(details);
455 OnRenderViewHostCreated(new_render_view_host.ptr()); 455 OnRenderViewHostCreated(new_render_view_host.ptr());
456 456
457 // When a new RenderView is created for a prerendering TabContents, 457 // When a new RenderView is created for a prerendering WebContents,
458 // tell the new RenderView it's being used for prerendering before any 458 // tell the new RenderView it's being used for prerendering before any
459 // navigations occur. Note that this is always triggered before the 459 // navigations occur. Note that this is always triggered before the
460 // first navigation, so there's no need to send the message just after 460 // first navigation, so there's no need to send the message just after
461 // the TabContents is created. 461 // the WebContents is created.
462 new_render_view_host->Send( 462 new_render_view_host->Send(
463 new PrerenderMsg_SetIsPrerendering( 463 new PrerenderMsg_SetIsPrerendering(
464 new_render_view_host->GetRoutingID(), 464 new_render_view_host->GetRoutingID(),
465 true)); 465 true));
466 466
467 // Make sure the size of the RenderViewHost has been passed to the new 467 // Make sure the size of the RenderViewHost has been passed to the new
468 // RenderView. Otherwise, the size may not be sent until the 468 // RenderView. Otherwise, the size may not be sent until the
469 // RenderViewReady event makes it from the render process to the UI 469 // RenderViewReady event makes it from the render process to the UI
470 // thread of the browser process. When the RenderView receives its 470 // thread of the browser process. When the RenderView receives its
471 // size, is also sets itself to be visible, which would then break the 471 // size, is also sets itself to be visible, which would then break the
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 bool PrerenderContents::IsCrossSiteNavigationPending() const { 705 bool PrerenderContents::IsCrossSiteNavigationPending() const {
706 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) 706 if (!prerender_contents_.get() || !prerender_contents_->web_contents())
707 return false; 707 return false;
708 const WebContents* web_contents = prerender_contents_->web_contents(); 708 const WebContents* web_contents = prerender_contents_->web_contents();
709 return (web_contents->GetSiteInstance() != 709 return (web_contents->GetSiteInstance() !=
710 web_contents->GetPendingSiteInstance()); 710 web_contents->GetPendingSiteInstance());
711 } 711 }
712 712
713 713
714 } // namespace prerender 714 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_contents.h ('k') | chrome/browser/prerender/prerender_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698