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

Side by Side Diff: chrome/browser/instant/instant_loader.cc

Issue 10938033: Switch BlockedContentTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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/instant/instant_loader.h" 5 #include "chrome/browser/instant/instant_loader.h"
6 6
7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
8 #include "chrome/browser/history/history_types.h" 8 #include "chrome/browser/history/history_types.h"
9 #include "chrome/browser/instant/instant_loader_delegate.h" 9 #include "chrome/browser/instant/instant_loader_delegate.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 371 }
372 372
373 void InstantLoader::SetupPreviewContents() { 373 void InstantLoader::SetupPreviewContents() {
374 content::WebContents* new_contents = preview_contents_->web_contents(); 374 content::WebContents* new_contents = preview_contents_->web_contents();
375 preview_delegate_.reset(new WebContentsDelegateImpl(this)); 375 preview_delegate_.reset(new WebContentsDelegateImpl(this));
376 WebContentsDelegateImpl* new_delegate = preview_delegate_.get(); 376 WebContentsDelegateImpl* new_delegate = preview_delegate_.get();
377 new_contents->SetDelegate(new_delegate); 377 new_contents->SetDelegate(new_delegate);
378 378
379 // Disable popups and such (mainly to avoid losing focus and reverting the 379 // Disable popups and such (mainly to avoid losing focus and reverting the
380 // preview prematurely). 380 // preview prematurely).
381 preview_contents_->blocked_content_tab_helper()->SetAllContentsBlocked(true); 381 BlockedContentTabHelper::FromWebContents(new_contents)->
382 SetAllContentsBlocked(true);
382 preview_contents_->constrained_window_tab_helper()-> 383 preview_contents_->constrained_window_tab_helper()->
383 set_delegate(new_delegate); 384 set_delegate(new_delegate);
384 preview_contents_->content_settings()->SetPopupsBlocked(true); 385 preview_contents_->content_settings()->SetPopupsBlocked(true);
385 CoreTabHelper::FromWebContents(new_contents)->set_delegate(new_delegate); 386 CoreTabHelper::FromWebContents(new_contents)->set_delegate(new_delegate);
386 if (ThumbnailGenerator* tg = preview_contents_->thumbnail_generator()) 387 if (ThumbnailGenerator* tg = preview_contents_->thumbnail_generator())
387 tg->set_enabled(false); 388 tg->set_enabled(false);
388 389
389 #if defined(OS_MACOSX) 390 #if defined(OS_MACOSX)
390 // If |preview_contents_| does not currently have a RWHV, we will call 391 // If |preview_contents_| does not currently have a RWHV, we will call
391 // SetTakesFocusOnlyOnMouseDown() as a result of the RENDER_VIEW_HOST_CHANGED 392 // SetTakesFocusOnlyOnMouseDown() as a result of the RENDER_VIEW_HOST_CHANGED
392 // notification. 393 // notification.
393 if (content::RenderWidgetHostView* rwhv = 394 if (content::RenderWidgetHostView* rwhv =
394 new_contents->GetRenderWidgetHostView()) 395 new_contents->GetRenderWidgetHostView())
395 rwhv->SetTakesFocusOnlyOnMouseDown(true); 396 rwhv->SetTakesFocusOnlyOnMouseDown(true);
396 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 397 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
397 content::Source<content::NavigationController>( 398 content::Source<content::NavigationController>(
398 &new_contents->GetController())); 399 &new_contents->GetController()));
399 #endif 400 #endif
400 } 401 }
401 402
402 void InstantLoader::CleanupPreviewContents() { 403 void InstantLoader::CleanupPreviewContents() {
403 content::WebContents* old_contents = preview_contents_->web_contents(); 404 content::WebContents* old_contents = preview_contents_->web_contents();
404 old_contents->SetDelegate(NULL); 405 old_contents->SetDelegate(NULL);
405 preview_delegate_.reset(); 406 preview_delegate_.reset();
406 407
407 preview_contents_->blocked_content_tab_helper()->SetAllContentsBlocked(false); 408 BlockedContentTabHelper::FromWebContents(old_contents)->
409 SetAllContentsBlocked(false);
408 preview_contents_->constrained_window_tab_helper()->set_delegate(NULL); 410 preview_contents_->constrained_window_tab_helper()->set_delegate(NULL);
409 preview_contents_->content_settings()->SetPopupsBlocked(false); 411 preview_contents_->content_settings()->SetPopupsBlocked(false);
410 CoreTabHelper::FromWebContents(old_contents)->set_delegate(NULL); 412 CoreTabHelper::FromWebContents(old_contents)->set_delegate(NULL);
411 if (ThumbnailGenerator* tg = preview_contents_->thumbnail_generator()) 413 if (ThumbnailGenerator* tg = preview_contents_->thumbnail_generator())
412 tg->set_enabled(true); 414 tg->set_enabled(true);
413 415
414 #if defined(OS_MACOSX) 416 #if defined(OS_MACOSX)
415 if (content::RenderWidgetHostView* rwhv = 417 if (content::RenderWidgetHostView* rwhv =
416 old_contents->GetRenderWidgetHostView()) 418 old_contents->GetRenderWidgetHostView())
417 rwhv->SetTakesFocusOnlyOnMouseDown(false); 419 rwhv->SetTakesFocusOnlyOnMouseDown(false);
418 registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 420 registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
419 content::Source<content::NavigationController>( 421 content::Source<content::NavigationController>(
420 &old_contents->GetController())); 422 &old_contents->GetController()));
421 #endif 423 #endif
422 } 424 }
423 425
424 void InstantLoader::ReplacePreviewContents(content::WebContents* old_contents, 426 void InstantLoader::ReplacePreviewContents(content::WebContents* old_contents,
425 content::WebContents* new_contents) { 427 content::WebContents* new_contents) {
426 DCHECK(old_contents == preview_contents_->web_contents()); 428 DCHECK(old_contents == preview_contents_->web_contents());
427 CleanupPreviewContents(); 429 CleanupPreviewContents();
428 // We release here without deleting so that the caller still has the 430 // We release here without deleting so that the caller still has the
429 // responsibility for deleting the TabContents. 431 // responsibility for deleting the TabContents.
430 ignore_result(preview_contents_.release()); 432 ignore_result(preview_contents_.release());
431 preview_contents_.reset(TabContents::FromWebContents(new_contents)); 433 preview_contents_.reset(TabContents::FromWebContents(new_contents));
432 SetupPreviewContents(); 434 SetupPreviewContents();
433 loader_delegate_->SwappedTabContents(this); 435 loader_delegate_->SwappedTabContents(this);
434 } 436 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_request_limiter.cc ('k') | chrome/browser/popup_blocker_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698