summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-06 17:21:55 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-06 17:21:55 +0000
commit91468a91aa86108533d5b1908652db0b63ff0acc (patch)
tree6f88226097ab40d26909c9b7a3bf7d1767b139bb
parent8307fb471e16aff98e34509b33c3205382d865d7 (diff)
downloadchromium_src-91468a91aa86108533d5b1908652db0b63ff0acc.zip
chromium_src-91468a91aa86108533d5b1908652db0b63ff0acc.tar.gz
chromium_src-91468a91aa86108533d5b1908652db0b63ff0acc.tar.bz2
Added ERR_BLOCKED_BY_ADMINISTRATOR and a custom error page.
This distinguishes navigations blocked by administrator policy from other ERR_NETWORK_ACCESS_DENIED sources. The custom error page can then inform the user that a policy configured by the administrator prevents access to the site. BUG=88702 Review URL: https://chromiumcodereview.appspot.com/12226113 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186455 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd15
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc4
-rw-r--r--chrome/browser/policy/policy_browsertest.cc4
-rw-r--r--chrome/common/localized_error.cc43
-rw-r--r--chrome/renderer/resources/neterror.html6
-rw-r--r--net/base/net_error_list.h4
6 files changed, 63 insertions, 13 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 6e09e3f..6c6b5ac 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -9299,6 +9299,12 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1
<message name="IDS_ERRORPAGES_SUGGESTION_LEARNMORE" desc="When a webpage fails to load, we provide a link to the help center to learn more about the failure.">
<ph name="BEGIN_LINK">&lt;a jsvalues="href:learnMoreUrl"&gt;</ph>Learn more<ph name="END_LINK">&lt;/a&gt;<ex>&lt;/a&gt;</ex></ph> about this problem.
</message>
+ <message name="IDS_ERRORPAGES_SUGGESTION_VIEW_POLICIES" desc="When a webpage fails to load, sometimes we suggest to the user to view the current policies.">
+ Visit &lt;strong&gt;chrome://policy&lt;/strong&gt; to see the list of blacklisted URLs and other policies enforced by your system administrator.
+ </message>
+ <message name="IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMINISTRATOR" desc="When a webpage fails to load, sometimes we suggest to the user to contact his system administrator.">
+ Contact your system administrator for more information.
+ </message>
<message name="IDS_ERRORPAGES_TITLE_NOT_AVAILABLE" desc="Title of the error page when we can't connect to a site.">
<ph name="SITE">$1<ex>google.com</ex></ph> is not available
@@ -9361,6 +9367,9 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1
<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_HEADING_BLOCKED_BY_ADMINISTRATOR" desc="Heading of the error page when a request is blocked by the administrator policy.">
+ Webpage Blocked
+ </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>
@@ -9765,9 +9774,15 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1
<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_SUMMARY_BLOCKED_BY_ADMINISTRATOR" desc="Summary in the error page when an administrator policy blocks a request.">
+ Your &lt;strong&gt;system administrator&lt;/strong&gt; 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_DETAILS_BLOCKED_BY_ADMINISTRATOR" desc="The error message displayed when a policy blocks a request.">
+ Requests to the server have been blocked by a policy.
+ </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.
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 896f97db..b3cdada 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -372,7 +372,7 @@ int ChromeNetworkDelegate::OnBeforeURLRequest(
net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST,
net::NetLog::StringCallback("url",
&request->url().possibly_invalid_spec()));
- return net::ERR_NETWORK_ACCESS_DENIED;
+ return net::ERR_BLOCKED_BY_ADMINISTRATOR;
}
#endif
@@ -657,7 +657,7 @@ int ChromeNetworkDelegate::OnBeforeSocketStreamConnect(
net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST,
net::NetLog::StringCallback("url",
&socket->url().possibly_invalid_spec()));
- return net::ERR_NETWORK_ACCESS_DENIED;
+ return net::ERR_BLOCKED_BY_ADMINISTRATOR;
}
#endif
return net::OK;
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 04c68ad..f8d6595 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -235,7 +235,7 @@ void CheckURLIsBlocked(Browser* browser, const char* spec) {
content::WebContents* contents =
browser->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(url, contents->GetURL());
- string16 title = UTF8ToUTF16(url.spec() + " is not available");
+ string16 title = UTF8ToUTF16(url.spec() + " was blocked");
EXPECT_EQ(title, contents->GetTitle());
// Verify that the expected error page is being displayed.
@@ -246,7 +246,7 @@ void CheckURLIsBlocked(Browser* browser, const char* spec) {
"var hasError = false;"
"var error = document.getElementById('errorDetails');"
"if (error)"
- " hasError = error.textContent.indexOf('Error 138') == 0;"
+ " hasError = error.textContent.indexOf('Error 22') == 0;"
"domAutomationController.send(hasError);",
&result));
EXPECT_TRUE(result);
diff --git a/chrome/common/localized_error.cc b/chrome/common/localized_error.cc
index bfc59a6..34bd43d 100644
--- a/chrome/common/localized_error.cc
+++ b/chrome/common/localized_error.cc
@@ -43,15 +43,17 @@ static const char kAppWarningLearnMoreUrl[] =
#endif // defined(OS_CHROMEOS)
enum NAV_SUGGESTIONS {
- SUGGEST_NONE = 0,
- SUGGEST_RELOAD = 1 << 0,
- SUGGEST_HOSTNAME = 1 << 1,
- SUGGEST_CHECK_CONNECTION = 1 << 2,
- SUGGEST_DNS_CONFIG = 1 << 3,
- SUGGEST_FIREWALL_CONFIG = 1 << 4,
- SUGGEST_PROXY_CONFIG = 1 << 5,
- SUGGEST_DISABLE_EXTENSION = 1 << 6,
- SUGGEST_LEARNMORE = 1 << 7,
+ SUGGEST_NONE = 0,
+ SUGGEST_RELOAD = 1 << 0,
+ SUGGEST_HOSTNAME = 1 << 1,
+ SUGGEST_CHECK_CONNECTION = 1 << 2,
+ SUGGEST_DNS_CONFIG = 1 << 3,
+ SUGGEST_FIREWALL_CONFIG = 1 << 4,
+ SUGGEST_PROXY_CONFIG = 1 << 5,
+ SUGGEST_DISABLE_EXTENSION = 1 << 6,
+ SUGGEST_LEARNMORE = 1 << 7,
+ SUGGEST_VIEW_POLICIES = 1 << 8,
+ SUGGEST_CONTACT_ADMINISTRATOR = 1 << 9,
};
struct LocalizedErrorMap {
@@ -279,6 +281,13 @@ const LocalizedErrorMap net_error_options[] = {
IDS_ERRORPAGES_DETAILS_NETWORK_CHANGED,
SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION,
},
+ {net::ERR_BLOCKED_BY_ADMINISTRATOR,
+ IDS_ERRORPAGES_TITLE_BLOCKED,
+ IDS_ERRORPAGES_HEADING_BLOCKED_BY_ADMINISTRATOR,
+ IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_ADMINISTRATOR,
+ IDS_ERRORPAGES_DETAILS_BLOCKED_BY_ADMINISTRATOR,
+ SUGGEST_VIEW_POLICIES | SUGGEST_CONTACT_ADMINISTRATOR,
+ },
};
const LocalizedErrorMap http_error_options[] = {
@@ -662,6 +671,22 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error,
error_strings->Set("suggestionsLearnMore", suggest_learn_more);
}
}
+
+ if (options.suggestions & SUGGEST_VIEW_POLICIES) {
+ DictionaryValue* suggestion = new DictionaryValue;
+ suggestion->SetString("msg",
+ l10n_util::GetStringUTF16(
+ IDS_ERRORPAGES_SUGGESTION_VIEW_POLICIES));
+ error_strings->Set("suggestionsViewPolicies", suggestion);
+ }
+
+ if (options.suggestions & SUGGEST_CONTACT_ADMINISTRATOR) {
+ DictionaryValue* suggestion = new DictionaryValue;
+ suggestion->SetString("msg",
+ l10n_util::GetStringUTF16(
+ IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMINISTRATOR));
+ error_strings->Set("suggestionsContactAdministrator", suggestion);
+ }
}
string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error) {
diff --git a/chrome/renderer/resources/neterror.html b/chrome/renderer/resources/neterror.html
index cba8ef003..8d7273f 100644
--- a/chrome/renderer/resources/neterror.html
+++ b/chrome/renderer/resources/neterror.html
@@ -211,6 +211,12 @@ if (window.screen.colorDepth >= 24)
<li jsselect="suggestionsLearnMore">
<span jsvalues=".innerHTML:msg"></span>
</li>
+ <li jsselect="suggestionsViewPolicies">
+ <span jsvalues=".innerHTML:msg"></span>
+ </li>
+ <li jsselect="suggestionsContactAdministrator">
+ <span jsvalues=".innerHTML:msg"></span>
+ </li>
</ul>
</div>
diff --git a/net/base/net_error_list.h b/net/base/net_error_list.h
index 30d23ca..c0c71ea 100644
--- a/net/base/net_error_list.h
+++ b/net/base/net_error_list.h
@@ -87,6 +87,10 @@ NET_ERROR(BLOCKED_BY_CLIENT, -20)
// The network changed.
NET_ERROR(NETWORK_CHANGED, -21)
+// The request was blocked by the URL blacklist configured by the domain
+// administrator.
+NET_ERROR(BLOCKED_BY_ADMINISTRATOR, -22)
+
// A connection was closed (corresponding to a TCP FIN).
NET_ERROR(CONNECTION_CLOSED, -100)