| OLD | NEW |
| 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 // 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 <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/metrics/field_trial.h" | 17 #include "base/metrics/field_trial.h" |
| 18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_piece.h" | 20 #include "base/strings/string_piece.h" |
| 21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/renderer_preferences_util.h" | 27 #include "chrome/browser/renderer_preferences_util.h" |
| 28 #include "chrome/browser/safe_browsing/threat_details.h" | 28 #include "chrome/browser/safe_browsing/threat_details.h" |
| 29 #include "chrome/browser/safe_browsing/ui_manager.h" | 29 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 30 #include "chrome/browser/tab_contents/tab_util.h" | |
| 31 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/grit/generated_resources.h" | 33 #include "chrome/grit/generated_resources.h" |
| 35 #include "chrome/grit/locale_settings.h" | 34 #include "chrome/grit/locale_settings.h" |
| 36 #include "components/google/core/browser/google_util.h" | 35 #include "components/google/core/browser/google_util.h" |
| 37 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
| 38 #include "components/security_interstitials/core/common_string_util.h" | 37 #include "components/security_interstitials/core/common_string_util.h" |
| 39 #include "components/security_interstitials/core/controller_client.h" | 38 #include "components/security_interstitials/core/controller_client.h" |
| 40 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 factory_ = g_safe_browsing_blocking_page_factory_impl.Pointer(); | 488 factory_ = g_safe_browsing_blocking_page_factory_impl.Pointer(); |
| 490 return factory_->CreateSafeBrowsingPage(ui_manager, web_contents, | 489 return factory_->CreateSafeBrowsingPage(ui_manager, web_contents, |
| 491 main_frame_url, resources); | 490 main_frame_url, resources); |
| 492 } | 491 } |
| 493 | 492 |
| 494 // static | 493 // static |
| 495 void SafeBrowsingBlockingPage::ShowBlockingPage( | 494 void SafeBrowsingBlockingPage::ShowBlockingPage( |
| 496 SafeBrowsingUIManager* ui_manager, | 495 SafeBrowsingUIManager* ui_manager, |
| 497 const UnsafeResource& unsafe_resource) { | 496 const UnsafeResource& unsafe_resource) { |
| 498 DVLOG(1) << __func__ << " " << unsafe_resource.url.spec(); | 497 DVLOG(1) << __func__ << " " << unsafe_resource.url.spec(); |
| 499 WebContents* web_contents = tab_util::GetWebContentsByFrameID( | 498 WebContents* web_contents = unsafe_resource.web_contents_getter.Run(); |
| 500 unsafe_resource.render_process_host_id, unsafe_resource.render_frame_id); | |
| 501 | 499 |
| 502 InterstitialPage* interstitial = | 500 InterstitialPage* interstitial = |
| 503 InterstitialPage::GetInterstitialPage(web_contents); | 501 InterstitialPage::GetInterstitialPage(web_contents); |
| 504 if (interstitial && !unsafe_resource.is_subresource) { | 502 if (interstitial && !unsafe_resource.is_subresource) { |
| 505 // There is already an interstitial showing and we are about to display a | 503 // There is already an interstitial showing and we are about to display a |
| 506 // new one for the main frame. Just hide the current one, it is now | 504 // new one for the main frame. Just hide the current one, it is now |
| 507 // irrelevent | 505 // irrelevent |
| 508 interstitial->DontProceed(); | 506 interstitial->DontProceed(); |
| 509 interstitial = NULL; | 507 interstitial = NULL; |
| 510 } | 508 } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } else { | 753 } else { |
| 756 load_time_data->SetString( | 754 load_time_data->SetString( |
| 757 "finalParagraph", | 755 "finalParagraph", |
| 758 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 756 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
| 759 } | 757 } |
| 760 | 758 |
| 761 PopulateExtendedReportingOption(load_time_data); | 759 PopulateExtendedReportingOption(load_time_data); |
| 762 } | 760 } |
| 763 | 761 |
| 764 } // namespace safe_browsing | 762 } // namespace safe_browsing |
| OLD | NEW |