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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc

Issue 273022: Fixing a bug with interstitial pages triggered with malware.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Implementation of the SafeBrowsingBlockingPage class. 5 // Implementation of the SafeBrowsingBlockingPage class.
6 6
7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 return Singleton<UnsafeResourceMap>::get(); 454 return Singleton<UnsafeResourceMap>::get();
455 } 455 }
456 456
457 // static 457 // static
458 void SafeBrowsingBlockingPage::ShowBlockingPage( 458 void SafeBrowsingBlockingPage::ShowBlockingPage(
459 SafeBrowsingService* sb_service, 459 SafeBrowsingService* sb_service,
460 const SafeBrowsingService::UnsafeResource& unsafe_resource) { 460 const SafeBrowsingService::UnsafeResource& unsafe_resource) {
461 TabContents* tab_contents = tab_util::GetTabContentsByID( 461 TabContents* tab_contents = tab_util::GetTabContentsByID(
462 unsafe_resource.render_process_host_id, unsafe_resource.render_view_id); 462 unsafe_resource.render_process_host_id, unsafe_resource.render_view_id);
463 463
464 if (!InterstitialPage::GetInterstitialPage(tab_contents)) { 464 InterstitialPage* interstitial =
465 InterstitialPage::GetInterstitialPage(tab_contents);
466 if (interstitial &&
467 unsafe_resource.resource_type == ResourceType::MAIN_FRAME) {
468 // There is already an interstitial showing and we are about to display a
469 // new one for the main frame. Just hide the current one, it is now
470 // irrelevent
471 interstitial->DontProceed();
472 interstitial = NULL;
473 }
474
475 if (!interstitial) {
465 // There are no interstitial currently showing in that tab, go ahead and 476 // There are no interstitial currently showing in that tab, go ahead and
466 // show this interstitial. 477 // show this interstitial.
467 std::vector<SafeBrowsingService::UnsafeResource> resources; 478 std::vector<SafeBrowsingService::UnsafeResource> resources;
468 resources.push_back(unsafe_resource); 479 resources.push_back(unsafe_resource);
469 // Set up the factory if this has not been done already (tests do that 480 // Set up the factory if this has not been done already (tests do that
470 // before this method is called). 481 // before this method is called).
471 if (!factory_) 482 if (!factory_)
472 factory_ = Singleton<SafeBrowsingBlockingPageFactoryImpl>::get(); 483 factory_ = Singleton<SafeBrowsingBlockingPageFactoryImpl>::get();
473 SafeBrowsingBlockingPage* blocking_page = 484 SafeBrowsingBlockingPage* blocking_page =
474 factory_->CreateSafeBrowsingPage(sb_service, tab_contents, resources); 485 factory_->CreateSafeBrowsingPage(sb_service, tab_contents, resources);
475 blocking_page->Show(); 486 blocking_page->Show();
476 return; 487 return;
477 } 488 }
478 489
479 // Let's queue the interstitial. 490 // This is an interstitial for a page's resource, let's queue it.
480 // Note we only expect resources from the page at this point.
481 DCHECK(unsafe_resource.resource_type != ResourceType::MAIN_FRAME);
482 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); 491 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
483 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource); 492 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource);
484 } 493 }
485 494
486 // static 495 // static
487 bool SafeBrowsingBlockingPage::IsMainPage( 496 bool SafeBrowsingBlockingPage::IsMainPage(
488 const UnsafeResourceList& unsafe_resources) { 497 const UnsafeResourceList& unsafe_resources) {
489 return unsafe_resources.size() == 1 && 498 return unsafe_resources.size() == 1 &&
490 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME; 499 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME;
491 } 500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698