summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-21 22:25:42 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-21 22:25:42 +0000
commit073e501cfce275852b138e41e01136814a39983d (patch)
treeb82b9726c6696fc744a63fe12e31c28bf2e9f9c0 /chrome
parent93d529cafc6423e431a88612dff69d06d4f0759f (diff)
downloadchromium_src-073e501cfce275852b138e41e01136814a39983d.zip
chromium_src-073e501cfce275852b138e41e01136814a39983d.tar.gz
chromium_src-073e501cfce275852b138e41e01136814a39983d.tar.bz2
Use a better error code for when an extension blocks a network request using
the webrequest API. BUG=97392 TEST=install a webrequest extension like AdBlock+ experimental and navigate to a URL that is blocked. You should see a descriptive error message. Review URL: http://codereview.chromium.org/8345032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106794 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd16
-rw-r--r--chrome/browser/extensions/extension_webrequest_api.cc6
-rw-r--r--chrome/browser/extensions/extension_webrequest_api_unittest.cc2
-rw-r--r--chrome/renderer/localized_error.cc18
-rw-r--r--chrome/renderer/resources/neterror.html3
-rw-r--r--chrome/test/data/extensions/api_test/webrequest/test_blocking.html4
6 files changed, 41 insertions, 8 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 96bfaeb..84ea4ce 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6720,6 +6720,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_ERRORPAGES_SUGGESTION_RELOAD" desc="When a page fails to load, we provide a suggestion that the user try reloading the page later">
<ph name="BEGIN_LINK">&lt;a jsvalues="href:reloadUrl"&gt;</ph>Reload<ph name="END_LINK">&lt;/a&gt;</ph> this webpage later.
</message>
+ <message name="IDS_ERRORPAGES_SUGGESTION_DISABLE_EXTENSION" desc="When a page fails to load, we provide a suggestion that the user try disabling an extension that's blocking it">
+ Disable your extensions and then <ph name="BEGIN_LINK">&lt;a jsvalues="href:reloadUrl"&gt;</ph>reload<ph name="END_LINK">&lt;/a&gt;</ph> this webpage.
+ </message>
<message name="IDS_ERRORPAGES_SUGGESTION_HOMEPAGE" desc="When a page fails to load, sometimes we provide a suggesting of trying just the hostname of the site.">
Go to the home page of the site:
</message>
@@ -6836,6 +6839,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_ERRORPAGES_TITLE_LOAD_FAILED" desc="Title of the error page when we can't load a page.">
<ph name="URL">$1<ex>http://some-unreliable-site.com/</ex></ph> failed to load
</message>
+ <message name="IDS_ERRORPAGES_TITLE_BLOCKED" desc="Title in the error page when a request is blocked (e.g. by an extension).">
+ <ph name="URL">$1<ex>http://www.google.com/foo/bar</ex></ph> was blocked
+ </message>
<message name="IDS_ERRORPAGES_HEADING_NOT_AVAILABLE" desc="Heading in the error page when we can't connect to a site.">
This webpage is not available
</message>
@@ -6878,6 +6884,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_ERRORPAGES_HEADING_KASPERSKY_ANTI_VIRUS_SSL_INTERCEPTION" desc="Heading of the error page when we detect that Kaspersky anti-virus is running and intercepting our HTTPS connections. 'Kaspersky' is a product name and may be best left untranslated.">
Cannot make secure connection because of Kaspersky anti-virus
</message>
+ <message name="IDS_ERRORPAGES_HEADING_BLOCKED" desc="Heading of the error page when a request is blocked by an extension.">
+ This webpage was blocked by an extension
+ </message>
<message name="IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE" desc="Summary in the error page when we can't connect to a site.">
The webpage at <ph name="URL">&lt;strong jscontent="failedUrl"&gt;&lt;/strong&gt;</ph> might be temporarily down or it may have moved permanently to a new web address.
</message>
@@ -7253,6 +7262,13 @@ Keep your key file in a safe place. You will need it to create new versions of y
Requests to the server have been temporarily throttled.
</message>
+ <message name="IDS_ERRORPAGES_SUMMARY_BLOCKED" desc="Summary in the error page when an extension blocks a request.">
+ A third-party extension has blocked access to this webpage.
+ </message>
+ <message name="IDS_ERRORPAGES_DETAILS_BLOCKED" desc="The error message displayed when an extension blocks a request.">
+ Requests to the server have been blocked by an extension.
+ </message>
+
<message name="IDS_ERRORPAGES_HTTP_POST_WARNING" desc="The error message displayed when the user navigates back or forward to a page which would resubmit post data. They can hit reload to send POST data again and load the page.">
This webpage requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press Reload to resend that data and display this page.
</message>
diff --git a/chrome/browser/extensions/extension_webrequest_api.cc b/chrome/browser/extensions/extension_webrequest_api.cc
index 85a9989..616dea4 100644
--- a/chrome/browser/extensions/extension_webrequest_api.cc
+++ b/chrome/browser/extensions/extension_webrequest_api.cc
@@ -1471,11 +1471,9 @@ void ExtensionWebRequestEventRouter::DecrementBlockCount(
request_time_tracker_->SetRequestRedirected(request_id);
}
- // This signals a failed request to subscribers of onErrorOccurred in case
- // a request is cancelled because net::ERR_EMPTY_RESPONSE cannot be
- // distinguished from a regular failure.
if (blocked_request.callback) {
- int rv = canceled ? net::ERR_EMPTY_RESPONSE : net::OK;
+ // This triggers onErrorOccurred.
+ int rv = canceled ? net::ERR_BLOCKED_BY_CLIENT : net::OK;
net::OldCompletionCallback* callback = blocked_request.callback;
// Ensure that request is removed before callback because the callback
// might trigger the next event.
diff --git a/chrome/browser/extensions/extension_webrequest_api_unittest.cc b/chrome/browser/extensions/extension_webrequest_api_unittest.cc
index 1c6a8c4..c1901c2 100644
--- a/chrome/browser/extensions/extension_webrequest_api_unittest.cc
+++ b/chrome/browser/extensions/extension_webrequest_api_unittest.cc
@@ -286,7 +286,7 @@ TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceCancel) {
EXPECT_TRUE(!request.is_pending());
EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status());
- EXPECT_EQ(net::ERR_EMPTY_RESPONSE, request.status().error());
+ EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, request.status().error());
EXPECT_EQ(request_url, request.url());
EXPECT_EQ(1U, request.url_chain().size());
EXPECT_EQ(0U, ipc_sender_.GetNumTasks());
diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc
index ad14e96..a3a30f4 100644
--- a/chrome/renderer/localized_error.cc
+++ b/chrome/renderer/localized_error.cc
@@ -47,7 +47,8 @@ enum NAV_SUGGESTIONS {
SUGGEST_DNS_CONFIG = 1 << 3,
SUGGEST_FIREWALL_CONFIG = 1 << 4,
SUGGEST_PROXY_CONFIG = 1 << 5,
- SUGGEST_LEARNMORE = 1 << 6,
+ SUGGEST_DISABLE_EXTENSION = 1 << 6,
+ SUGGEST_LEARNMORE = 1 << 7,
};
struct LocalizedErrorMap {
@@ -261,6 +262,13 @@ const LocalizedErrorMap net_error_options[] = {
IDS_ERRORPAGES_DETAILS_TEMPORARILY_THROTTLED,
SUGGEST_NONE,
},
+ {net::ERR_BLOCKED_BY_CLIENT,
+ IDS_ERRORPAGES_TITLE_BLOCKED,
+ IDS_ERRORPAGES_HEADING_BLOCKED,
+ IDS_ERRORPAGES_SUMMARY_BLOCKED,
+ IDS_ERRORPAGES_DETAILS_BLOCKED,
+ SUGGEST_DISABLE_EXTENSION,
+ },
};
const LocalizedErrorMap http_error_options[] = {
@@ -593,6 +601,14 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error,
error_strings->Set("suggestionsProxyConfig", suggest_proxy_config);
}
+ if (options.suggestions & SUGGEST_DISABLE_EXTENSION) {
+ DictionaryValue* suggestion = new DictionaryValue;
+ suggestion->SetString("msg",
+ l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_DISABLE_EXTENSION));
+ suggestion->SetString("reloadUrl", failed_url_string);
+ error_strings->Set("suggestionsDisableExtension", suggestion);
+ }
+
if (options.suggestions & SUGGEST_LEARNMORE) {
GURL learn_more_url;
switch (options.error_code) {
diff --git a/chrome/renderer/resources/neterror.html b/chrome/renderer/resources/neterror.html
index dd456af..ac3172c 100644
--- a/chrome/renderer/resources/neterror.html
+++ b/chrome/renderer/resources/neterror.html
@@ -178,6 +178,9 @@ if (window.screen.colorDepth >= 24)
<li jsselect="suggestionsProxyDisable">
<span jsvalues=".innerHTML:msg"></span>
</li>
+ <li jsselect="suggestionsDisableExtension">
+ <span jsvalues=".innerHTML:msg"></span>
+ </li>
<li jsselect="suggestionsLearnMore">
<span jsvalues=".innerHTML:msg"></span>
</li>
diff --git a/chrome/test/data/extensions/api_test/webrequest/test_blocking.html b/chrome/test/data/extensions/api_test/webrequest/test_blocking.html
index aadb354..8e12ac1 100644
--- a/chrome/test/data/extensions/api_test/webrequest/test_blocking.html
+++ b/chrome/test/data/extensions/api_test/webrequest/test_blocking.html
@@ -38,7 +38,7 @@ runTests([
details: {
url: getURL("complexLoad/b.html"),
fromCache: false,
- error: "net::ERR_EMPTY_RESPONSE"
+ error: "net::ERR_BLOCKED_BY_CLIENT"
// Request to chrome-extension:// url has no IP.
}
},
@@ -102,7 +102,7 @@ runTests([
details: {
url: getURLHttpSimpleLoad(),
fromCache: false,
- error: "net::ERR_EMPTY_RESPONSE"
+ error: "net::ERR_BLOCKED_BY_CLIENT"
// Request to chrome-extension:// url has no IP.
}
},