summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-19 00:42:30 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-19 00:42:30 +0000
commita3a1d14240d6e41a0b6732ebcd3600399c64b26a (patch)
treea38ced2761bdf4447bf180470fd5dade857ef11b /chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
parent5b62083c99317965244123c031c707d53f0a03f1 (diff)
downloadchromium_src-a3a1d14240d6e41a0b6732ebcd3600399c64b26a.zip
chromium_src-a3a1d14240d6e41a0b6732ebcd3600399c64b26a.tar.gz
chromium_src-a3a1d14240d6e41a0b6732ebcd3600399c64b26a.tar.bz2
Review URL: http://codereview.chromium.org/14809
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7281 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/safe_browsing_blocking_page.cc')
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page.cc47
1 files changed, 22 insertions, 25 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index 6c6433a..265e4c7 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -43,7 +43,7 @@ static const wchar_t* const kSbDiagnosticHtml =
SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
SafeBrowsingService* sb_service,
const SafeBrowsingService::BlockingPageParam& param)
- : InterstitialPage(tab_util::GetTabContentsByID(
+ : InterstitialPage(tab_util::GetWebContentsByID(
param.render_process_host_id, param.render_view_id),
param.resource_type == ResourceType::MAIN_FRAME,
param.url),
@@ -55,6 +55,12 @@ SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
proceed_(false),
did_notify_(false),
is_main_frame_(param.resource_type == ResourceType::MAIN_FRAME) {
+ if (!is_main_frame_) {
+ navigation_entry_index_to_remove_ =
+ tab()->controller()->GetLastCommittedEntryIndex();
+ } else {
+ navigation_entry_index_to_remove_ = -1;
+ }
}
SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() {
@@ -138,8 +144,6 @@ std::string SafeBrowsingBlockingPage::GetHTMLContents() {
}
void SafeBrowsingBlockingPage::CommandReceived(const std::string& command) {
- DCHECK(tab()->type() == TAB_CONTENTS_WEB);
- WebContents* web = tab()->AsWebContents();
if (command == "2") {
// User pressed "Learn more".
GURL url;
@@ -150,7 +154,7 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& command) {
} else {
NOTREACHED();
}
- web->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::LINK);
+ tab()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::LINK);
return;
}
if (command == "3") {
@@ -161,8 +165,8 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& command) {
GURL report_url =
safe_browsing_util::GeneratePhishingReportUrl(kSbReportPhishingUrl,
url().spec());
- web->HideInterstitialPage(false, false);
- web->OpenURL(report_url, GURL(), CURRENT_TAB, PageTransition::LINK);
+ Hide();
+ tab()->OpenURL(report_url, GURL(), CURRENT_TAB, PageTransition::LINK);
return;
}
if (command == "4") {
@@ -173,33 +177,26 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& command) {
GURL diagnostic_url(diagnostic);
diagnostic_url = google_util::AppendGoogleLocaleParam(diagnostic_url);
DCHECK(result_ == SafeBrowsingService::URL_MALWARE);
- web->HideInterstitialPage(false, false);
- web->OpenURL(diagnostic_url, GURL(), CURRENT_TAB, PageTransition::LINK);
+ tab()->OpenURL(diagnostic_url, GURL(), CURRENT_TAB, PageTransition::LINK);
return;
}
proceed_ = command == "1";
- if (proceed_) {
- if (is_main_frame_)
- web->HideInterstitialPage(true, true);
- else
- web->HideInterstitialPage(false, false);
- } else {
- if (is_main_frame_) {
- DontProceed();
- } else {
- NavigationController* controller = web->controller();
- controller->RemoveEntryAtIndex(controller->GetLastCommittedEntryIndex(),
- NewTabUIURL());
- }
- }
+ if (proceed_)
+ Proceed();
+ else
+ DontProceed();
+
NotifyDone();
}
-void SafeBrowsingBlockingPage::InterstitialClosed() {
- NotifyDone();
- InterstitialPage::InterstitialClosed();
+void SafeBrowsingBlockingPage::DontProceed() {
+ if (navigation_entry_index_to_remove_ != -1) {
+ tab()->controller()->RemoveEntryAtIndex(navigation_entry_index_to_remove_,
+ NewTabUIURL());
+ }
+ InterstitialPage::DontProceed();
// We are now deleted.
}