Chromium Code Reviews| 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 #include "components/error_page/common/localized_error.h" | 5 #include "components/error_page/common/localized_error.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 namespace error_page { | 40 namespace error_page { |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 // Some error pages have no details. | 44 // Some error pages have no details. |
| 45 const unsigned int kErrorPagesNoDetails = 0; | 45 const unsigned int kErrorPagesNoDetails = 0; |
| 46 | 46 |
| 47 static const char kRedirectLoopLearnMoreUrl[] = | 47 static const char kRedirectLoopLearnMoreUrl[] = |
| 48 "https://support.google.com/chrome/answer/95626"; | 48 "https://support.google.com/chrome?p=rl_error"; |
| 49 static const char kWeakDHKeyLearnMoreUrl[] = | 49 static const char kWeakDHKeyLearnMoreUrl[] = |
| 50 "https://support.google.com/chrome?p=dh_error"; | 50 "https://support.google.com/chrome?p=dh_error"; |
| 51 static const int kGoogleCachedCopySuggestionType = 0; | 51 static const int kGoogleCachedCopySuggestionType = 0; |
| 52 | 52 |
| 53 enum NAV_SUGGESTIONS { | 53 enum NAV_SUGGESTIONS { |
| 54 SUGGEST_NONE = 0, | 54 SUGGEST_NONE = 0, |
| 55 SUGGEST_RELOAD = 1 << 0, | 55 SUGGEST_RELOAD = 1 << 0, |
| 56 SUGGEST_CHECK_CONNECTION = 1 << 1, | 56 SUGGEST_CHECK_CONNECTION = 1 << 1, |
| 57 SUGGEST_DNS_CONFIG = 1 << 2, | 57 SUGGEST_DNS_CONFIG = 1 << 2, |
| 58 SUGGEST_FIREWALL_CONFIG = 1 << 3, | 58 SUGGEST_FIREWALL_CONFIG = 1 << 3, |
| 59 SUGGEST_PROXY_CONFIG = 1 << 4, | 59 SUGGEST_PROXY_CONFIG = 1 << 4, |
| 60 SUGGEST_DISABLE_EXTENSION = 1 << 5, | 60 SUGGEST_DISABLE_EXTENSION = 1 << 5, |
| 61 SUGGEST_LEARNMORE = 1 << 6, | 61 SUGGEST_LEARNMORE = 1 << 6, |
| 62 SUGGEST_VIEW_POLICIES = 1 << 7, | 62 // Unprefixed suggestion which occurs in a list. |
| 63 SUGGEST_CONTACT_ADMINISTRATOR = 1 << 8, | 63 SUGGEST_CONTACT_ADMINISTRATOR = 1 << 7, |
| 64 SUGGEST_UNSUPPORTED_CIPHER = 1 << 9, | 64 // Standalone suggestion which cannot be mixed with others. |
| 65 // Includes 'Try' prefix to the bulleted suggestion. | |
| 66 SUGGEST_CONTACT_ADMINISTRATOR_STANDALONE = 1 << 8, | |
| 67 SUGGEST_UNSUPPORTED_CIPHER = 1 << 9, | |
| 68 SUGGEST_ANTIVIRUS_CONFIG = 1 << 10, | |
| 69 SUGGEST_OFFLINE_CHECKS = 1 << 11, | |
| 70 // Standalone suggestion to complete the device setup. | |
| 71 // Should not be mixed with others and is not prefixed with 'Try'. | |
| 72 SUGGEST_COMPLETE_SETUP_STANDALONE = 1 << 12, | |
| 73 // Standalone reload page suggestion for pages created by a post. | |
| 74 // Should not be mixed with others and is not prefixed with 'Try'. | |
| 75 SUGGEST_RELOAD_STANDALONE = 1 << 13, | |
| 65 }; | 76 }; |
| 66 | 77 |
| 67 struct LocalizedErrorMap { | 78 struct LocalizedErrorMap { |
| 68 int error_code; | 79 int error_code; |
| 69 unsigned int title_resource_id; | 80 unsigned int title_resource_id; |
| 70 unsigned int heading_resource_id; | 81 unsigned int heading_resource_id; |
| 71 // Detailed summary used when the error is in the main frame. | 82 // Detailed summary used when the error is in the main frame. |
| 72 unsigned int summary_resource_id; | 83 unsigned int summary_resource_id; |
| 73 // Short one sentence description shown on mouse over when the error is in | 84 // Short one sentence description shown on mouse over when the error is in |
| 74 // a frame. | 85 // a frame. |
| 75 unsigned int details_resource_id; | 86 unsigned int details_resource_id; |
| 76 int suggestions; // Bitmap of SUGGEST_* values. | 87 int suggestions; // Bitmap of SUGGEST_* values. |
| 77 unsigned int error_explanation_id; | |
| 78 }; | 88 }; |
| 79 | 89 |
| 80 const LocalizedErrorMap net_error_options[] = { | 90 const LocalizedErrorMap net_error_options[] = { |
| 81 {net::ERR_TIMED_OUT, | 91 {net::ERR_TIMED_OUT, |
| 82 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 92 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 83 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 93 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 84 IDS_ERRORPAGES_SUMMARY_TIMED_OUT, | 94 IDS_ERRORPAGES_SUMMARY_TIMED_OUT, |
| 85 IDS_ERRORPAGES_DETAILS_TIMED_OUT, | 95 IDS_ERRORPAGES_DETAILS_TIMED_OUT, |
| 86 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG | | 96 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG | |
| 87 SUGGEST_PROXY_CONFIG, | 97 SUGGEST_PROXY_CONFIG, |
| 88 }, | 98 }, |
| 89 {net::ERR_CONNECTION_TIMED_OUT, | 99 {net::ERR_CONNECTION_TIMED_OUT, |
| 90 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 100 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 91 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 101 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 92 IDS_ERRORPAGES_SUMMARY_TIMED_OUT, | 102 IDS_ERRORPAGES_SUMMARY_TIMED_OUT, |
| 93 IDS_ERRORPAGES_DETAILS_TIMED_OUT, | 103 IDS_ERRORPAGES_DETAILS_TIMED_OUT, |
| 94 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG | | 104 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG | |
| 95 SUGGEST_PROXY_CONFIG, | 105 SUGGEST_PROXY_CONFIG, |
| 96 }, | 106 }, |
| 97 {net::ERR_CONNECTION_CLOSED, | 107 {net::ERR_CONNECTION_CLOSED, |
| 98 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 108 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 99 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 109 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 100 IDS_ERRORPAGES_SUMMARY_CONNECTION_CLOSED, | 110 IDS_ERRORPAGES_SUMMARY_CONNECTION_CLOSED, |
| 101 IDS_ERRORPAGES_DETAILS_CONNECTION_CLOSED, | 111 IDS_ERRORPAGES_DETAILS_CONNECTION_CLOSED, |
| 102 SUGGEST_RELOAD, | 112 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG | |
| 113 SUGGEST_PROXY_CONFIG, | |
| 103 }, | 114 }, |
| 104 {net::ERR_CONNECTION_RESET, | 115 {net::ERR_CONNECTION_RESET, |
| 105 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 116 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 106 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 117 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 107 IDS_ERRORPAGES_SUMMARY_CONNECTION_RESET, | 118 IDS_ERRORPAGES_SUMMARY_CONNECTION_RESET, |
| 108 IDS_ERRORPAGES_DETAILS_CONNECTION_RESET, | 119 IDS_ERRORPAGES_DETAILS_CONNECTION_RESET, |
| 109 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG | | 120 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG | |
| 110 SUGGEST_PROXY_CONFIG, | 121 SUGGEST_PROXY_CONFIG, |
| 111 }, | 122 }, |
| 112 {net::ERR_CONNECTION_REFUSED, | 123 {net::ERR_CONNECTION_REFUSED, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 137 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 148 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 138 IDS_ERRORPAGES_SUMMARY_ICANN_NAME_COLLISION, | 149 IDS_ERRORPAGES_SUMMARY_ICANN_NAME_COLLISION, |
| 139 IDS_ERRORPAGES_DETAILS_ICANN_NAME_COLLISION, | 150 IDS_ERRORPAGES_DETAILS_ICANN_NAME_COLLISION, |
| 140 SUGGEST_NONE, | 151 SUGGEST_NONE, |
| 141 }, | 152 }, |
| 142 {net::ERR_ADDRESS_UNREACHABLE, | 153 {net::ERR_ADDRESS_UNREACHABLE, |
| 143 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 154 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 144 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 155 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 145 IDS_ERRORPAGES_SUMMARY_ADDRESS_UNREACHABLE, | 156 IDS_ERRORPAGES_SUMMARY_ADDRESS_UNREACHABLE, |
| 146 IDS_ERRORPAGES_DETAILS_ADDRESS_UNREACHABLE, | 157 IDS_ERRORPAGES_DETAILS_ADDRESS_UNREACHABLE, |
| 147 SUGGEST_RELOAD | SUGGEST_FIREWALL_CONFIG | SUGGEST_PROXY_CONFIG, | 158 SUGGEST_RELOAD, |
| 148 }, | 159 }, |
| 149 {net::ERR_NETWORK_ACCESS_DENIED, | 160 {net::ERR_NETWORK_ACCESS_DENIED, |
| 150 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 161 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 151 IDS_ERRORPAGES_HEADING_NETWORK_ACCESS_DENIED, | 162 IDS_ERRORPAGES_HEADING_NETWORK_ACCESS_DENIED, |
| 152 IDS_ERRORPAGES_SUMMARY_NETWORK_ACCESS_DENIED, | 163 IDS_ERRORPAGES_SUMMARY_NETWORK_ACCESS_DENIED, |
| 153 IDS_ERRORPAGES_DETAILS_NETWORK_ACCESS_DENIED, | 164 IDS_ERRORPAGES_DETAILS_NETWORK_ACCESS_DENIED, |
| 154 SUGGEST_FIREWALL_CONFIG, | 165 SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG | |
| 166 SUGGEST_ANTIVIRUS_CONFIG, | |
| 155 }, | 167 }, |
| 156 {net::ERR_PROXY_CONNECTION_FAILED, | 168 {net::ERR_PROXY_CONNECTION_FAILED, |
| 157 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 169 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 158 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED, | 170 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED, |
| 159 IDS_ERRORPAGES_SUMMARY_PROXY_CONNECTION_FAILED, | 171 IDS_ERRORPAGES_SUMMARY_PROXY_CONNECTION_FAILED, |
| 160 IDS_ERRORPAGES_DETAILS_PROXY_CONNECTION_FAILED, | 172 IDS_ERRORPAGES_DETAILS_PROXY_CONNECTION_FAILED, |
| 161 SUGGEST_PROXY_CONFIG, | 173 SUGGEST_PROXY_CONFIG | SUGGEST_CONTACT_ADMINISTRATOR, |
| 162 }, | 174 }, |
| 163 {net::ERR_INTERNET_DISCONNECTED, | 175 {net::ERR_INTERNET_DISCONNECTED, |
| 164 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 176 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 165 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED, | 177 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED, |
| 166 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED, | 178 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED, |
| 167 IDS_ERRORPAGES_DETAILS_INTERNET_DISCONNECTED, | 179 IDS_ERRORPAGES_DETAILS_INTERNET_DISCONNECTED, |
| 168 SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG, | 180 SUGGEST_OFFLINE_CHECKS, |
| 169 }, | 181 }, |
| 170 {net::ERR_FILE_NOT_FOUND, | 182 {net::ERR_FILE_NOT_FOUND, |
| 171 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 183 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| 172 IDS_ERRORPAGES_HEADING_FILE_NOT_FOUND, | 184 IDS_ERRORPAGES_HEADING_FILE_NOT_FOUND, |
| 173 IDS_ERRORPAGES_SUMMARY_FILE_NOT_FOUND, | 185 IDS_ERRORPAGES_SUMMARY_FILE_NOT_FOUND, |
| 174 IDS_ERRORPAGES_DETAILS_FILE_NOT_FOUND, | 186 IDS_ERRORPAGES_DETAILS_FILE_NOT_FOUND, |
| 175 SUGGEST_RELOAD, | 187 SUGGEST_RELOAD, |
| 176 }, | 188 }, |
| 177 {net::ERR_CACHE_MISS, | 189 {net::ERR_CACHE_MISS, |
| 178 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 190 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 IDS_ERRORPAGES_HEADING_PAGE_NOT_WORKING, | 254 IDS_ERRORPAGES_HEADING_PAGE_NOT_WORKING, |
| 243 IDS_ERRORPAGES_SUMMARY_CONNECTION_CLOSED, | 255 IDS_ERRORPAGES_SUMMARY_CONNECTION_CLOSED, |
| 244 IDS_ERRORPAGES_DETAILS_CONNECTION_CLOSED, | 256 IDS_ERRORPAGES_DETAILS_CONNECTION_CLOSED, |
| 245 SUGGEST_RELOAD, | 257 SUGGEST_RELOAD, |
| 246 }, | 258 }, |
| 247 {net::ERR_SSL_PROTOCOL_ERROR, | 259 {net::ERR_SSL_PROTOCOL_ERROR, |
| 248 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 260 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| 249 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, | 261 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, |
| 250 IDS_ERRORPAGES_SUMMARY_INVALID_RESPONSE, | 262 IDS_ERRORPAGES_SUMMARY_INVALID_RESPONSE, |
| 251 IDS_ERRORPAGES_DETAILS_SSL_PROTOCOL_ERROR, | 263 IDS_ERRORPAGES_DETAILS_SSL_PROTOCOL_ERROR, |
| 252 SUGGEST_NONE, | 264 SUGGEST_RELOAD, |
| 253 }, | 265 }, |
| 254 {net::ERR_BAD_SSL_CLIENT_AUTH_CERT, | 266 {net::ERR_BAD_SSL_CLIENT_AUTH_CERT, |
| 255 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 267 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| 256 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, | 268 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, |
| 257 IDS_ERRORPAGES_SUMMARY_BAD_SSL_CLIENT_AUTH_CERT, | 269 IDS_ERRORPAGES_SUMMARY_BAD_SSL_CLIENT_AUTH_CERT, |
| 258 IDS_ERRORPAGES_DETAILS_BAD_SSL_CLIENT_AUTH_CERT, | 270 IDS_ERRORPAGES_DETAILS_BAD_SSL_CLIENT_AUTH_CERT, |
| 259 SUGGEST_NONE, | 271 SUGGEST_CONTACT_ADMINISTRATOR_STANDALONE, |
| 260 }, | 272 }, |
| 261 {net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY, | 273 {net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY, |
| 262 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 274 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| 263 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, | 275 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, |
| 264 IDS_ERRORPAGES_SUMMARY_SSL_SECURITY_ERROR, | 276 IDS_ERRORPAGES_SUMMARY_SSL_SECURITY_ERROR, |
| 265 IDS_ERRORPAGES_DETAILS_SSL_PROTOCOL_ERROR, | 277 IDS_ERRORPAGES_DETAILS_SSL_PROTOCOL_ERROR, |
| 266 SUGGEST_LEARNMORE, | 278 SUGGEST_LEARNMORE, |
| 267 }, | 279 }, |
| 268 {net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN, | 280 {net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN, |
| 269 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 281 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| 270 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, | 282 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, |
| 271 IDS_CERT_ERROR_SUMMARY_PINNING_FAILURE_DETAILS, | 283 IDS_CERT_ERROR_SUMMARY_PINNING_FAILURE_DETAILS, |
| 272 IDS_CERT_ERROR_SUMMARY_PINNING_FAILURE_DESCRIPTION, | 284 IDS_CERT_ERROR_SUMMARY_PINNING_FAILURE_DESCRIPTION, |
| 273 SUGGEST_NONE, | 285 SUGGEST_NONE, |
| 274 }, | 286 }, |
| 275 {net::ERR_TEMPORARILY_THROTTLED, | 287 {net::ERR_TEMPORARILY_THROTTLED, |
| 276 IDS_ERRORPAGES_TITLE_ACCESS_DENIED, | 288 IDS_ERRORPAGES_TITLE_ACCESS_DENIED, |
| 277 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 289 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 278 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE, | 290 IDS_ERRORPAGES_SUMMARY_NOT_AVAILABLE, |
| 279 IDS_ERRORPAGES_DETAILS_TEMPORARILY_THROTTLED, | 291 IDS_ERRORPAGES_DETAILS_TEMPORARILY_THROTTLED, |
| 280 SUGGEST_NONE, | 292 SUGGEST_DISABLE_EXTENSION, |
| 281 }, | 293 }, |
| 282 {net::ERR_BLOCKED_BY_CLIENT, | 294 {net::ERR_BLOCKED_BY_CLIENT, |
| 283 IDS_ERRORPAGES_TITLE_BLOCKED, | 295 IDS_ERRORPAGES_TITLE_BLOCKED, |
| 284 IDS_ERRORPAGES_HEADING_BLOCKED, | 296 IDS_ERRORPAGES_HEADING_BLOCKED, |
| 285 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_EXTENSION, | 297 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_EXTENSION, |
| 286 IDS_ERRORPAGES_DETAILS_BLOCKED_BY_EXTENSION, | 298 IDS_ERRORPAGES_DETAILS_BLOCKED_BY_EXTENSION, |
| 287 SUGGEST_RELOAD | SUGGEST_DISABLE_EXTENSION, | 299 SUGGEST_RELOAD | SUGGEST_DISABLE_EXTENSION, |
| 288 }, | 300 }, |
| 289 {net::ERR_NETWORK_CHANGED, | 301 {net::ERR_NETWORK_CHANGED, |
| 290 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 302 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| 291 IDS_ERRORPAGES_HEADING_CONNECTION_INTERRUPTED, | 303 IDS_ERRORPAGES_HEADING_CONNECTION_INTERRUPTED, |
| 292 IDS_ERRORPAGES_SUMMARY_NETWORK_CHANGED, | 304 IDS_ERRORPAGES_SUMMARY_NETWORK_CHANGED, |
| 293 IDS_ERRORPAGES_DETAILS_NETWORK_CHANGED, | 305 IDS_ERRORPAGES_DETAILS_NETWORK_CHANGED, |
| 294 SUGGEST_RELOAD | SUGGEST_CHECK_CONNECTION, | 306 SUGGEST_RELOAD, |
| 295 }, | 307 }, |
| 296 {net::ERR_BLOCKED_BY_ADMINISTRATOR, | 308 {net::ERR_BLOCKED_BY_ADMINISTRATOR, |
| 297 IDS_ERRORPAGES_TITLE_BLOCKED, | 309 IDS_ERRORPAGES_TITLE_BLOCKED, |
| 298 IDS_ERRORPAGES_HEADING_BLOCKED, | 310 IDS_ERRORPAGES_HEADING_BLOCKED, |
| 299 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_ADMINISTRATOR, | 311 IDS_ERRORPAGES_SUMMARY_BLOCKED_BY_ADMINISTRATOR, |
| 300 IDS_ERRORPAGES_DETAILS_BLOCKED_BY_ADMINISTRATOR, | 312 IDS_ERRORPAGES_DETAILS_BLOCKED_BY_ADMINISTRATOR, |
| 301 SUGGEST_VIEW_POLICIES | SUGGEST_CONTACT_ADMINISTRATOR, | 313 SUGGEST_CONTACT_ADMINISTRATOR_STANDALONE, |
| 302 }, | 314 }, |
| 303 {net::ERR_BLOCKED_ENROLLMENT_CHECK_PENDING, | 315 {net::ERR_BLOCKED_ENROLLMENT_CHECK_PENDING, |
| 304 IDS_ERRORPAGES_TITLE_BLOCKED, | 316 IDS_ERRORPAGES_TITLE_BLOCKED, |
| 305 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED, | 317 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED, |
| 306 IDS_ERRORPAGES_SUMMARY_BLOCKED_ENROLLMENT_CHECK_PENDING, | 318 IDS_ERRORPAGES_SUMMARY_BLOCKED_ENROLLMENT_CHECK_PENDING, |
| 307 IDS_ERRORPAGES_DETAILS_BLOCKED_ENROLLMENT_CHECK_PENDING, | 319 IDS_ERRORPAGES_DETAILS_BLOCKED_ENROLLMENT_CHECK_PENDING, |
| 308 SUGGEST_CHECK_CONNECTION, | 320 SUGGEST_COMPLETE_SETUP_STANDALONE, |
| 309 }, | 321 }, |
| 310 {net::ERR_SSL_FALLBACK_BEYOND_MINIMUM_VERSION, | 322 {net::ERR_SSL_FALLBACK_BEYOND_MINIMUM_VERSION, |
| 311 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 323 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| 312 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, | 324 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, |
| 313 IDS_ERRORPAGES_SUMMARY_SSL_SECURITY_ERROR, | 325 IDS_ERRORPAGES_SUMMARY_INVALID_RESPONSE, |
| 314 IDS_ERRORPAGES_DETAILS_SSL_FALLBACK_BEYOND_MINIMUM_VERSION, | 326 IDS_ERRORPAGES_DETAILS_SSL_FALLBACK_BEYOND_MINIMUM_VERSION, |
| 315 SUGGEST_NONE, | 327 SUGGEST_NONE, |
| 316 }, | 328 }, |
| 317 {net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH, | 329 {net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH, |
| 318 IDS_ERRORPAGES_TITLE_LOAD_FAILED, | 330 IDS_ERRORPAGES_TITLE_LOAD_FAILED, |
| 319 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, | 331 IDS_ERRORPAGES_HEADING_INSECURE_CONNECTION, |
| 320 IDS_ERRORPAGES_SUMMARY_SSL_VERSION_OR_CIPHER_MISMATCH, | 332 IDS_ERRORPAGES_SUMMARY_SSL_VERSION_OR_CIPHER_MISMATCH, |
| 321 IDS_ERRORPAGES_DETAILS_SSL_VERSION_OR_CIPHER_MISMATCH, | 333 IDS_ERRORPAGES_DETAILS_SSL_VERSION_OR_CIPHER_MISMATCH, |
| 322 SUGGEST_UNSUPPORTED_CIPHER, | 334 SUGGEST_UNSUPPORTED_CIPHER, |
| 323 }, | 335 }, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 339 | 351 |
| 340 // Special error page to be used in the case of navigating back to a page | 352 // Special error page to be used in the case of navigating back to a page |
| 341 // generated by a POST. LocalizedError::HasStrings expects this net error code | 353 // generated by a POST. LocalizedError::HasStrings expects this net error code |
| 342 // to also appear in the array above. | 354 // to also appear in the array above. |
| 343 const LocalizedErrorMap repost_error = { | 355 const LocalizedErrorMap repost_error = { |
| 344 net::ERR_CACHE_MISS, | 356 net::ERR_CACHE_MISS, |
| 345 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 357 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 346 IDS_HTTP_POST_WARNING_TITLE, | 358 IDS_HTTP_POST_WARNING_TITLE, |
| 347 IDS_ERRORPAGES_HTTP_POST_WARNING, | 359 IDS_ERRORPAGES_HTTP_POST_WARNING, |
| 348 IDS_ERRORPAGES_DETAILS_CACHE_READ_FAILURE, | 360 IDS_ERRORPAGES_DETAILS_CACHE_READ_FAILURE, |
| 349 SUGGEST_RELOAD, | 361 SUGGEST_RELOAD_STANDALONE, |
| 350 }; | 362 }; |
| 351 | 363 |
| 352 const LocalizedErrorMap http_error_options[] = { | 364 const LocalizedErrorMap http_error_options[] = { |
| 353 {403, | 365 {403, |
| 354 IDS_ERRORPAGES_TITLE_ACCESS_DENIED, | 366 IDS_ERRORPAGES_TITLE_ACCESS_DENIED, |
| 355 IDS_ERRORPAGES_HEADING_ACCESS_DENIED, | 367 IDS_ERRORPAGES_HEADING_ACCESS_DENIED, |
| 356 IDS_ERRORPAGES_SUMMARY_FORBIDDEN, | 368 IDS_ERRORPAGES_SUMMARY_FORBIDDEN, |
| 357 IDS_ERRORPAGES_DETAILS_FORBIDDEN, | 369 IDS_ERRORPAGES_DETAILS_FORBIDDEN, |
| 358 SUGGEST_NONE, | 370 SUGGEST_RELOAD, |
| 359 }, | 371 }, |
| 360 {410, | 372 {410, |
| 361 IDS_ERRORPAGES_TITLE_NOT_FOUND, | 373 IDS_ERRORPAGES_TITLE_NOT_FOUND, |
| 362 IDS_ERRORPAGES_HEADING_NOT_FOUND, | 374 IDS_ERRORPAGES_HEADING_NOT_FOUND, |
| 363 IDS_ERRORPAGES_SUMMARY_GONE, | 375 IDS_ERRORPAGES_SUMMARY_GONE, |
| 364 IDS_ERRORPAGES_DETAILS_GONE, | 376 IDS_ERRORPAGES_DETAILS_GONE, |
| 365 SUGGEST_NONE, | 377 SUGGEST_NONE, |
| 366 }, | 378 }, |
| 367 | 379 |
| 368 {500, | 380 {500, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 }, | 436 }, |
| 425 | 437 |
| 426 // DNS_PROBE_FINISHED_UNKNOWN is not here; NetErrorHelper will restore the | 438 // DNS_PROBE_FINISHED_UNKNOWN is not here; NetErrorHelper will restore the |
| 427 // original error, which might be one of several DNS-related errors. | 439 // original error, which might be one of several DNS-related errors. |
| 428 | 440 |
| 429 {error_page::DNS_PROBE_FINISHED_NO_INTERNET, | 441 {error_page::DNS_PROBE_FINISHED_NO_INTERNET, |
| 430 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 442 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 431 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED, | 443 IDS_ERRORPAGES_HEADING_INTERNET_DISCONNECTED, |
| 432 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED, | 444 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED, |
| 433 IDS_ERRORPAGES_DETAILS_INTERNET_DISCONNECTED, | 445 IDS_ERRORPAGES_DETAILS_INTERNET_DISCONNECTED, |
| 434 SUGGEST_CHECK_CONNECTION | SUGGEST_FIREWALL_CONFIG, | 446 SUGGEST_OFFLINE_CHECKS, |
| 435 }, | 447 }, |
| 436 {error_page::DNS_PROBE_FINISHED_BAD_CONFIG, | 448 {error_page::DNS_PROBE_FINISHED_BAD_CONFIG, |
| 437 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 449 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 438 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 450 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 439 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED, | 451 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED, |
| 440 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED, | 452 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED, |
| 441 SUGGEST_RELOAD | SUGGEST_DNS_CONFIG | SUGGEST_FIREWALL_CONFIG, | 453 SUGGEST_RELOAD | SUGGEST_DNS_CONFIG | SUGGEST_FIREWALL_CONFIG | |
| 454 SUGGEST_PROXY_CONFIG, | |
| 442 }, | 455 }, |
| 443 {error_page::DNS_PROBE_FINISHED_NXDOMAIN, | 456 {error_page::DNS_PROBE_FINISHED_NXDOMAIN, |
| 444 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, | 457 IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, |
| 445 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, | 458 IDS_ERRORPAGES_HEADING_NOT_AVAILABLE, |
| 446 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED, | 459 IDS_ERRORPAGES_SUMMARY_NAME_NOT_RESOLVED, |
| 447 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED, | 460 IDS_ERRORPAGES_DETAILS_NAME_NOT_RESOLVED, |
| 448 SUGGEST_RELOAD, | 461 SUGGEST_RELOAD, |
| 449 }, | 462 }, |
| 450 }; | 463 }; |
| 451 | 464 |
| 452 const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps, | 465 const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps, |
| 453 size_t num_maps, | 466 size_t num_maps, |
| 454 int error_code) { | 467 int error_code) { |
| 455 for (size_t i = 0; i < num_maps; ++i) { | 468 for (size_t i = 0; i < num_maps; ++i) { |
| 456 if (maps[i].error_code == error_code) | 469 if (maps[i].error_code == error_code) |
| 457 return &maps[i]; | 470 return &maps[i]; |
| 458 } | 471 } |
| 459 return NULL; | 472 return nullptr; |
| 460 } | 473 } |
| 461 | 474 |
| 462 const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain, | 475 const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain, |
| 463 int error_code, bool is_post) { | 476 int error_code, bool is_post) { |
| 464 if (error_domain == net::kErrorDomain) { | 477 if (error_domain == net::kErrorDomain) { |
| 465 // Display a different page in the special case of navigating through the | 478 // Display a different page in the special case of navigating through the |
| 466 // history to an uncached page created by a POST. | 479 // history to an uncached page created by a POST. |
| 467 if (is_post && error_code == net::ERR_CACHE_MISS) | 480 if (is_post && error_code == net::ERR_CACHE_MISS) |
| 468 return &repost_error; | 481 return &repost_error; |
| 469 return FindErrorMapInArray(net_error_options, | 482 return FindErrorMapInArray(net_error_options, |
| 470 arraysize(net_error_options), | 483 arraysize(net_error_options), |
| 471 error_code); | 484 error_code); |
| 472 } else if (error_domain == LocalizedError::kHttpErrorDomain) { | 485 } else if (error_domain == LocalizedError::kHttpErrorDomain) { |
| 473 return FindErrorMapInArray(http_error_options, | 486 return FindErrorMapInArray(http_error_options, |
| 474 arraysize(http_error_options), | 487 arraysize(http_error_options), |
| 475 error_code); | 488 error_code); |
| 476 } else if (error_domain == error_page::kDnsProbeErrorDomain) { | 489 } else if (error_domain == error_page::kDnsProbeErrorDomain) { |
| 477 const LocalizedErrorMap* map = | 490 const LocalizedErrorMap* map = |
| 478 FindErrorMapInArray(dns_probe_error_options, | 491 FindErrorMapInArray(dns_probe_error_options, |
| 479 arraysize(dns_probe_error_options), | 492 arraysize(dns_probe_error_options), |
| 480 error_code); | 493 error_code); |
| 481 DCHECK(map); | 494 DCHECK(map); |
| 482 return map; | 495 return map; |
| 483 } else { | 496 } else { |
| 484 NOTREACHED(); | 497 NOTREACHED(); |
| 485 return NULL; | 498 return nullptr; |
| 486 } | 499 } |
| 487 } | 500 } |
| 488 | 501 |
| 489 // Returns a dictionary containing the strings for the settings menu under the | 502 // Returns a dictionary containing the strings for the settings menu under the |
| 490 // app menu, and the advanced settings button. | 503 // app menu, and the advanced settings button. |
| 491 base::DictionaryValue* GetStandardMenuItemsText() { | 504 base::DictionaryValue* GetStandardMenuItemsText() { |
| 492 base::DictionaryValue* standard_menu_items_text = new base::DictionaryValue(); | 505 base::DictionaryValue* standard_menu_items_text = new base::DictionaryValue(); |
| 493 standard_menu_items_text->SetString("settingsTitle", | 506 standard_menu_items_text->SetString("settingsTitle", |
| 494 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); | 507 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); |
| 495 standard_menu_items_text->SetString("advancedTitle", | 508 standard_menu_items_text->SetString("advancedTitle", |
| 496 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS)); | 509 l10n_util::GetStringUTF16(IDS_SETTINGS_SHOW_ADVANCED_SETTINGS)); |
| 497 return standard_menu_items_text; | 510 return standard_menu_items_text; |
| 498 } | 511 } |
| 499 | 512 |
| 500 // Gets the icon class for a given |error_domain| and |error_code|. | 513 // Gets the icon class for a given |error_domain| and |error_code|. |
| 501 const char* GetIconClassForError(const std::string& error_domain, | 514 const char* GetIconClassForError(const std::string& error_domain, |
| 502 int error_code) { | 515 int error_code) { |
| 503 if ((error_code == net::ERR_INTERNET_DISCONNECTED && | 516 if ((error_code == net::ERR_INTERNET_DISCONNECTED && |
| 504 error_domain == net::kErrorDomain) || | 517 error_domain == net::kErrorDomain) || |
| 505 (error_code == error_page::DNS_PROBE_FINISHED_NO_INTERNET && | 518 (error_code == error_page::DNS_PROBE_FINISHED_NO_INTERNET && |
| 506 error_domain == error_page::kDnsProbeErrorDomain)) | 519 error_domain == error_page::kDnsProbeErrorDomain)) |
| 507 return "icon-offline"; | 520 return "icon-offline"; |
| 508 | 521 |
| 509 return "icon-generic"; | 522 return "icon-generic"; |
| 510 } | 523 } |
| 511 | 524 |
| 512 // If the first suggestion is for a Google cache copy link. Promote the | 525 // If the first suggestion is for a Google cache copy link. Promote the |
| 513 // suggestion to a separate set of strings for displaying as a button. | 526 // suggestion to a separate set of strings for displaying as a button. |
| 514 void AddGoogleCachedCopyButton(base::ListValue* suggestions, | 527 void AddGoogleCachedCopyButton(base::ListValue* suggestions_summary_list, |
| 515 base::DictionaryValue* error_strings) { | 528 base::DictionaryValue* error_strings) { |
| 516 if (!suggestions->empty()) { | 529 if (!suggestions_summary_list->empty()) { |
| 517 base::DictionaryValue* suggestion; | 530 base::DictionaryValue* suggestion; |
| 518 suggestions->GetDictionary(0, &suggestion); | 531 suggestions_summary_list->GetDictionary(0, &suggestion); |
| 519 int type = -1; | 532 int type = -1; |
| 520 suggestion->GetInteger("type", &type); | 533 suggestion->GetInteger("type", &type); |
| 521 | 534 |
| 522 if (type == kGoogleCachedCopySuggestionType) { | 535 if (type == kGoogleCachedCopySuggestionType) { |
| 523 base::string16 cache_url; | 536 base::string16 cache_url; |
| 524 suggestion->GetString("urlCorrection", &cache_url); | 537 suggestion->GetString("urlCorrection", &cache_url); |
| 525 int cache_tracking_id = -1; | 538 int cache_tracking_id = -1; |
| 526 suggestion->GetInteger("trackingId", &cache_tracking_id); | 539 suggestion->GetInteger("trackingId", &cache_tracking_id); |
| 527 scoped_ptr<base::DictionaryValue> cache_button(new base::DictionaryValue); | 540 scoped_ptr<base::DictionaryValue> cache_button(new base::DictionaryValue); |
| 528 cache_button->SetString( | 541 cache_button->SetString( |
| 529 "msg", | 542 "msg", |
| 530 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY)); | 543 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY)); |
| 531 cache_button->SetString("cacheUrl", cache_url); | 544 cache_button->SetString("cacheUrl", cache_url); |
| 532 cache_button->SetInteger("trackingId", cache_tracking_id); | 545 cache_button->SetInteger("trackingId", cache_tracking_id); |
| 533 error_strings->Set("cacheButton", cache_button.release()); | 546 error_strings->Set("cacheButton", cache_button.release()); |
| 534 | 547 |
| 535 // Remove the item from suggestions dictionary so that it does not get | 548 // Remove the item from suggestions dictionary so that it does not get |
| 536 // displayed by the template in the details section. | 549 // displayed by the template in the details section. |
| 537 suggestions->Remove(0, nullptr); | 550 suggestions_summary_list->Remove(0, nullptr); |
| 538 } | 551 } |
| 539 } | 552 } |
| 540 } | 553 } |
| 541 | 554 |
| 555 // Helper function that creates a single entry dictionary and adds it | |
| 556 // to a ListValue, | |
| 557 void AddSingleEntryDictionaryToList(base::ListValue* list, | |
| 558 const char* path, | |
| 559 int message_id, | |
| 560 bool insert_as_first_item) { | |
| 561 base::DictionaryValue* suggestion_list_item = new base::DictionaryValue; | |
| 562 suggestion_list_item->SetString(path, l10n_util::GetStringUTF16(message_id)); | |
| 563 | |
| 564 if (insert_as_first_item) { | |
| 565 list->Insert(0, suggestion_list_item); | |
| 566 } else { | |
| 567 list->Append(suggestion_list_item); | |
| 568 } | |
| 569 } | |
| 570 | |
| 571 // Creates a list of suggestions that a user may try to resolve a particular | |
| 572 // network error. Appears above the fold underneath heading and intro paragraph. | |
| 573 void GetSuggestionsSummaryList(int error_code, | |
| 574 base::DictionaryValue* error_strings, | |
| 575 int suggestions, | |
| 576 const std::string& locale, | |
| 577 base::ListValue* suggestions_summary_list) { | |
| 578 if (suggestions & SUGGEST_CONTACT_ADMINISTRATOR_STANDALONE) { | |
| 579 DCHECK(suggestions_summary_list->empty()); | |
| 580 DCHECK(!(suggestions & ~SUGGEST_CONTACT_ADMINISTRATOR_STANDALONE)); | |
| 581 DCHECK(suggestions & ~SUGGEST_COMPLETE_SETUP_STANDALONE); | |
| 582 DCHECK(suggestions & ~SUGGEST_RELOAD_STANDALONE); | |
|
mmenke
2016/02/25 22:01:03
These two aren't needed (They should be !(suggesti
edwardjung
2016/02/26 01:02:18
Done.
| |
| 583 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 584 IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMIN_SUMMARY_WITH_PREFIX, false); | |
| 585 return; | |
| 586 } | |
| 587 | |
| 588 if (suggestions & SUGGEST_COMPLETE_SETUP_STANDALONE) { | |
| 589 DCHECK(suggestions_summary_list->empty()); | |
| 590 DCHECK(!(suggestions & ~SUGGEST_COMPLETE_SETUP_STANDALONE)); | |
| 591 DCHECK(suggestions & ~SUGGEST_CONTACT_ADMINISTRATOR_STANDALONE); | |
| 592 DCHECK(suggestions & ~SUGGEST_RELOAD_STANDALONE); | |
|
mmenke
2016/02/25 22:01:03
These last two are redundant.
| |
| 593 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 594 IDS_ERRORPAGES_SUGGESTION_DIAGNOSE_CONNECTION_SUMMARY, false); | |
| 595 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 596 IDS_ERRORPAGES_SUGGESTION_COMPLETE_SETUP_SUMMARY, false); | |
| 597 return; | |
| 598 } | |
| 599 | |
| 600 if (suggestions & SUGGEST_RELOAD_STANDALONE) { | |
| 601 DCHECK(suggestions_summary_list->empty()); | |
| 602 DCHECK(!(suggestions & ~SUGGEST_RELOAD_STANDALONE)); | |
| 603 DCHECK(suggestions & ~SUGGEST_CONTACT_ADMINISTRATOR_STANDALONE); | |
| 604 DCHECK(suggestions & ~SUGGEST_COMPLETE_SETUP_STANDALONE); | |
|
mmenke
2016/02/25 22:01:03
These last two are redundant.
| |
| 605 // If the page was created by a post, it can't be reloaded in the same | |
| 606 // way, so just add a suggestion instead. | |
| 607 // TODO(mmenke): Make the reload button bring up the repost confirmation | |
| 608 // dialog for pages resulting from posts. | |
| 609 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 610 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_SUMMARY, false); | |
| 611 return; | |
| 612 } | |
| 613 | |
| 614 if (suggestions & SUGGEST_CHECK_CONNECTION) { | |
| 615 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 616 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_SUMMARY, false); | |
| 617 } | |
| 618 | |
| 619 if ((suggestions & SUGGEST_DNS_CONFIG) && | |
| 620 (suggestions & SUGGEST_FIREWALL_CONFIG) && | |
| 621 (suggestions & SUGGEST_PROXY_CONFIG)) { | |
| 622 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 623 IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_FIREWALL_DNS_SUMMARY, false); | |
| 624 } else if ((suggestions & SUGGEST_FIREWALL_CONFIG) && | |
| 625 (suggestions & SUGGEST_ANTIVIRUS_CONFIG)) { | |
| 626 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 627 IDS_ERRORPAGES_SUGGESTION_CHECK_FIREWALL_ANTIVIRUS_SUMMARY, false); | |
| 628 } else if ((suggestions & SUGGEST_PROXY_CONFIG) && | |
| 629 (suggestions & SUGGEST_FIREWALL_CONFIG)) { | |
| 630 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 631 IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_FIREWALL_SUMMARY, false); | |
| 632 } else if (suggestions & SUGGEST_PROXY_CONFIG) { | |
| 633 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 634 IDS_ERRORPAGES_SUGGESTION_CHECK_PROXY_ADDRESS_SUMMARY, false); | |
| 635 } else { | |
| 636 DCHECK(!(suggestions & SUGGEST_PROXY_CONFIG)); | |
| 637 DCHECK(!(suggestions & SUGGEST_FIREWALL_CONFIG)); | |
| 638 DCHECK(!(suggestions & SUGGEST_DNS_CONFIG)); | |
| 639 } | |
| 640 | |
| 641 if (suggestions & SUGGEST_CONTACT_ADMINISTRATOR) { | |
| 642 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 643 IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMIN_SUMMARY, false); | |
| 644 } | |
| 645 | |
| 646 if (suggestions & SUGGEST_OFFLINE_CHECKS) { | |
| 647 #if defined(OS_ANDROID) || defined(OS_IOS) | |
| 648 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 649 IDS_ERRORPAGES_SUGGESTION_TURN_OFF_AIRPLANE_SUMMARY, false); | |
| 650 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 651 IDS_ERRORPAGES_SUGGESTION_TURN_ON_DATA_SUMMARY, false); | |
| 652 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 653 IDS_ERRORPAGES_SUGGESTION_CHECKING_SIGNAL_SUMMARY, false); | |
| 654 #else | |
| 655 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 656 IDS_ERRORPAGES_SUGGESTION_CHECK_CABLES_SUMMARY, false); | |
| 657 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 658 IDS_ERRORPAGES_SUGGESTION_RESET_HARDWARE_SUMMARY, false); | |
| 659 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 660 IDS_ERRORPAGES_SUGGESTION_CHECK_WIFI_SUMMARY, false); | |
| 661 #endif | |
| 662 } | |
| 663 | |
| 664 if (suggestions & SUGGEST_DISABLE_EXTENSION) { | |
| 665 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 666 IDS_ERRORPAGES_SUGGESTION_DISABLE_EXTENSION_SUMMARY, false); | |
| 667 } | |
| 668 | |
| 669 if (suggestions & SUGGEST_LEARNMORE) { | |
| 670 GURL learn_more_url; | |
| 671 base::string16 suggestion_string; | |
| 672 switch (error_code) { | |
| 673 case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY: | |
| 674 learn_more_url = GURL(kWeakDHKeyLearnMoreUrl); | |
| 675 suggestion_string = l10n_util::GetStringUTF16( | |
| 676 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_SUMMARY); | |
| 677 break; | |
| 678 case net::ERR_TOO_MANY_REDIRECTS: | |
| 679 learn_more_url = GURL(kRedirectLoopLearnMoreUrl); | |
| 680 suggestion_string = l10n_util::GetStringUTF16( | |
| 681 IDS_ERRORPAGES_SUGGESTION_CLEAR_COOKIES_SUMMARY); | |
| 682 break; | |
| 683 default: | |
| 684 NOTREACHED(); | |
| 685 break; | |
| 686 } | |
| 687 | |
| 688 DCHECK(learn_more_url.is_valid()); | |
| 689 // Add the language parameter to the URL. | |
| 690 std::string query = learn_more_url.query() + "&hl=" + locale; | |
| 691 GURL::Replacements repl; | |
| 692 repl.SetQueryStr(query); | |
| 693 learn_more_url = learn_more_url.ReplaceComponents(repl); | |
| 694 | |
| 695 base::DictionaryValue* suggestion_list_item = new base::DictionaryValue; | |
| 696 suggestion_list_item->SetString("summary", suggestion_string); | |
| 697 suggestion_list_item->SetString("learnMoreUrl", learn_more_url.spec()); | |
| 698 suggestions_summary_list->Append(suggestion_list_item); | |
| 699 } | |
| 700 | |
| 701 // Only add a explicit reload suggestion if there are other suggestions. | |
| 702 // Otherwise rely on the reload button being used. | |
| 703 if (!suggestions_summary_list->empty() && (suggestions & SUGGEST_RELOAD)) { | |
| 704 AddSingleEntryDictionaryToList(suggestions_summary_list, "summary", | |
| 705 IDS_ERRORPAGES_SUGGESTION_RELOAD_SUMMARY, true); | |
| 706 } | |
| 707 | |
| 708 // Add list prefix header. | |
| 709 error_strings->SetString("suggestionsSummaryListHeader", | |
| 710 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LIST_HEADER)); | |
| 711 } | |
| 712 | |
| 713 // Creates a dictionary with "header" and "body" entries and adds it | |
| 714 // to a ListValue, Returns the dictionary to allow further items to be added. | |
| 715 base::DictionaryValue* AddSuggestionDetailDictionaryToList( | |
| 716 base::ListValue* list, | |
| 717 int header_message_id, | |
| 718 int body_message_id, | |
| 719 bool append_standard_menu_items) { | |
| 720 base::DictionaryValue* suggestion_list_item; | |
| 721 if (append_standard_menu_items) { | |
| 722 suggestion_list_item = GetStandardMenuItemsText(); | |
| 723 } else { | |
| 724 suggestion_list_item = new base::DictionaryValue; | |
| 725 } | |
| 726 | |
| 727 if (header_message_id) { | |
| 728 suggestion_list_item->SetString("header", | |
| 729 l10n_util::GetStringUTF16(header_message_id)); | |
| 730 } | |
| 731 if (body_message_id) { | |
| 732 suggestion_list_item->SetString("body", | |
| 733 l10n_util::GetStringUTF16(body_message_id)); | |
| 734 } | |
| 735 list->Append(suggestion_list_item); | |
| 736 return suggestion_list_item; | |
| 737 } | |
| 738 | |
| 739 // Certain suggestions have supporting details which get displayed under | |
| 740 // the "Details" button. | |
| 741 void AddSuggestionsDetails(int error_code, | |
| 742 base::DictionaryValue* error_strings, | |
| 743 int suggestions, | |
| 744 base::ListValue* suggestions_details) { | |
| 745 if (suggestions & SUGGEST_CHECK_CONNECTION) { | |
| 746 AddSuggestionDetailDictionaryToList(suggestions_details, | |
| 747 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER, | |
| 748 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_BODY, false); | |
| 749 } | |
| 750 | |
| 751 if (suggestions & SUGGEST_DNS_CONFIG) { | |
| 752 AddSuggestionDetailDictionaryToList(suggestions_details, | |
| 753 IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_HEADER, | |
| 754 IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_BODY, false); | |
| 755 | |
| 756 base::DictionaryValue* suggest_network_prediction = | |
| 757 AddSuggestionDetailDictionaryToList(suggestions_details, | |
| 758 IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_HEADER, | |
| 759 IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_BODY, true); | |
| 760 | |
| 761 suggest_network_prediction->SetString( | |
| 762 "noNetworkPredictionTitle", | |
| 763 l10n_util::GetStringUTF16( | |
| 764 IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION)); | |
| 765 } | |
| 766 | |
| 767 if (suggestions & SUGGEST_FIREWALL_CONFIG) { | |
| 768 AddSuggestionDetailDictionaryToList(suggestions_details, | |
| 769 IDS_ERRORPAGES_SUGGESTION_FIREWALL_CONFIG_HEADER, | |
| 770 IDS_ERRORPAGES_SUGGESTION_FIREWALL_CONFIG_BODY, false); | |
| 771 } | |
| 772 | |
| 773 if (suggestions & SUGGEST_PROXY_CONFIG) { | |
| 774 base::DictionaryValue* suggest_proxy_config = | |
| 775 AddSuggestionDetailDictionaryToList(suggestions_details, | |
| 776 IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_HEADER, | |
| 777 0, true); | |
| 778 | |
| 779 // Custom body string. | |
| 780 suggest_proxy_config->SetString("body", | |
| 781 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_BODY, | |
| 782 l10n_util::GetStringUTF16( | |
| 783 IDS_ERRORPAGES_SUGGESTION_PROXY_DISABLE_PLATFORM))); | |
| 784 | |
| 785 suggest_proxy_config->SetString("proxyTitle", | |
| 786 l10n_util::GetStringUTF16(IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON)); | |
| 787 } | |
| 788 | |
| 789 if (suggestions & SUGGEST_CONTACT_ADMINISTRATOR_STANDALONE && | |
| 790 error_code == net::ERR_BLOCKED_BY_ADMINISTRATOR) { | |
|
edwardjung
2016/02/25 19:00:03
Removed the view policies suggestion so the standa
mmenke
2016/02/25 22:01:03
Ahh...forgot that the standalone was just for abov
| |
| 791 AddSuggestionDetailDictionaryToList(suggestions_details, | |
| 792 IDS_ERRORPAGES_SUGGESTION_VIEW_POLICIES_HEADER, | |
| 793 IDS_ERRORPAGES_SUGGESTION_VIEW_POLICIES_BODY, false); | |
| 794 } | |
| 795 | |
| 796 if (suggestions & SUGGEST_UNSUPPORTED_CIPHER) { | |
| 797 AddSuggestionDetailDictionaryToList(suggestions_details, | |
| 798 IDS_ERRORPAGES_SUGGESTION_UNSUPPORTED_CIPHER_HEADER, | |
| 799 IDS_ERRORPAGES_SUGGESTION_UNSUPPORTED_CIPHER_BODY, false); | |
| 800 } | |
| 801 } | |
| 802 | |
| 803 std::string HttpErrorCodeToString(int error) { | |
| 804 return std::string("HTTP ERROR ") + base::IntToString(error); | |
| 805 } | |
| 806 | |
| 542 } // namespace | 807 } // namespace |
| 543 | 808 |
| 544 const char LocalizedError::kHttpErrorDomain[] = "http"; | 809 const char LocalizedError::kHttpErrorDomain[] = "http"; |
| 545 | 810 |
| 546 void LocalizedError::GetStrings(int error_code, | 811 void LocalizedError::GetStrings(int error_code, |
| 547 const std::string& error_domain, | 812 const std::string& error_domain, |
| 548 const GURL& failed_url, | 813 const GURL& failed_url, |
| 549 bool is_post, | 814 bool is_post, |
| 550 bool stale_copy_in_cache, | 815 bool stale_copy_in_cache, |
| 551 bool can_show_network_diagnostics_dialog, | 816 bool can_show_network_diagnostics_dialog, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 base::string16 error_string; | 909 base::string16 error_string; |
| 645 if (error_domain == net::kErrorDomain) { | 910 if (error_domain == net::kErrorDomain) { |
| 646 // Non-internationalized error string, for debugging Chrome itself. | 911 // Non-internationalized error string, for debugging Chrome itself. |
| 647 error_string = base::ASCIIToUTF16(net::ErrorToShortString(error_code)); | 912 error_string = base::ASCIIToUTF16(net::ErrorToShortString(error_code)); |
| 648 } else if (error_domain == error_page::kDnsProbeErrorDomain) { | 913 } else if (error_domain == error_page::kDnsProbeErrorDomain) { |
| 649 std::string ascii_error_string = | 914 std::string ascii_error_string = |
| 650 error_page::DnsProbeStatusToString(error_code); | 915 error_page::DnsProbeStatusToString(error_code); |
| 651 error_string = base::ASCIIToUTF16(ascii_error_string); | 916 error_string = base::ASCIIToUTF16(ascii_error_string); |
| 652 } else { | 917 } else { |
| 653 DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain); | 918 DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain); |
| 654 error_string = base::IntToString16(error_code); | 919 error_string = base::ASCIIToUTF16(HttpErrorCodeToString(error_code)); |
| 655 } | 920 } |
| 656 error_strings->SetString("errorCode", error_string); | 921 error_strings->SetString("errorCode", error_string); |
| 657 | 922 |
| 658 // Platform specific information for diagnosing network issues on OSX and | 923 // Platform specific information for diagnosing network issues on OSX and |
| 659 // Windows. | 924 // Windows. |
| 660 #if (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_WIN) | 925 #if (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_WIN) |
| 661 if (error_domain == net::kErrorDomain && | 926 if (error_domain == net::kErrorDomain && |
| 662 error_code == net::ERR_INTERNET_DISCONNECTED) { | 927 error_code == net::ERR_INTERNET_DISCONNECTED) { |
| 663 int platform_string_id = | 928 int platform_string_id = |
| 664 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_PLATFORM; | 929 IDS_ERRORPAGES_SUMMARY_INTERNET_DISCONNECTED_PLATFORM; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 682 l10n_util::GetStringUTF16(platform_string_id))); | 947 l10n_util::GetStringUTF16(platform_string_id))); |
| 683 } | 948 } |
| 684 #endif // (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_WIN) | 949 #endif // (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_WIN) |
| 685 | 950 |
| 686 // If no parameters were provided, use the defaults. | 951 // If no parameters were provided, use the defaults. |
| 687 if (!params) { | 952 if (!params) { |
| 688 params.reset(new error_page::ErrorPageParams()); | 953 params.reset(new error_page::ErrorPageParams()); |
| 689 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); | 954 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); |
| 690 } | 955 } |
| 691 | 956 |
| 692 base::ListValue* suggestions = NULL; | 957 base::ListValue* suggestions_details = nullptr; |
| 958 base::ListValue* suggestions_summary_list = nullptr; | |
| 959 | |
| 693 bool use_default_suggestions = true; | 960 bool use_default_suggestions = true; |
| 694 if (!params->override_suggestions) { | 961 if (!params->override_suggestions) { |
| 695 suggestions = new base::ListValue(); | 962 suggestions_details = new base::ListValue(); |
| 963 suggestions_summary_list = new base::ListValue(); | |
| 964 // Detailed suggestion information. | |
| 965 error_strings->Set("suggestionsDetails", suggestions_details); | |
| 696 } else { | 966 } else { |
| 697 suggestions = params->override_suggestions.release(); | 967 suggestions_summary_list = params->override_suggestions.release(); |
| 698 use_default_suggestions = false; | 968 use_default_suggestions = false; |
| 699 AddGoogleCachedCopyButton(suggestions, error_strings); | 969 AddGoogleCachedCopyButton(suggestions_summary_list, error_strings); |
| 700 } | 970 } |
| 701 error_strings->Set("suggestions", suggestions); | 971 error_strings->Set("suggestionsSummaryList", suggestions_summary_list); |
| 702 | 972 |
| 703 if (params->search_url.is_valid()) { | 973 if (params->search_url.is_valid()) { |
| 704 error_strings->SetString("searchHeader", | 974 base::DictionaryValue* search_suggestion = new base::DictionaryValue; |
| 705 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); | 975 search_suggestion->SetString("summary",l10n_util::GetStringUTF16( |
| 706 error_strings->SetString("searchUrl", params->search_url.spec()); | 976 IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH_SUMMARY)); |
| 707 error_strings->SetString("searchTerms", params->search_terms); | 977 search_suggestion->SetString("searchUrl", params->search_url.spec() + |
| 708 error_strings->SetInteger("searchTrackingId", params->search_tracking_id); | 978 params->search_terms); |
| 979 search_suggestion->SetString("searchTerms", params->search_terms); | |
| 980 search_suggestion->SetInteger("trackingId", | |
| 981 params->search_tracking_id); | |
| 982 suggestions_summary_list->Append(search_suggestion); | |
| 709 } | 983 } |
| 710 | 984 |
| 711 // Add the reload suggestion, if needed. | 985 // Add the reload suggestion, if needed for pages that didn't come |
| 712 if (params->suggest_reload) { | 986 // from a post. |
| 713 if (!is_post) { | 987 if (params->suggest_reload && !is_post) { |
| 714 base::DictionaryValue* reload_button = new base::DictionaryValue; | 988 base::DictionaryValue* reload_button = new base::DictionaryValue; |
| 715 reload_button->SetString( | 989 reload_button->SetString( |
| 716 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); | 990 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); |
| 717 reload_button->SetString("reloadUrl", failed_url.spec()); | 991 reload_button->SetString("reloadUrl", failed_url.spec()); |
| 718 error_strings->Set("reloadButton", reload_button); | 992 error_strings->Set("reloadButton", reload_button); |
| 719 reload_button->SetInteger("reloadTrackingId", params->reload_tracking_id); | 993 reload_button->SetInteger("reloadTrackingId", params->reload_tracking_id); |
| 720 } else { | |
| 721 // If the page was created by a post, it can't be reloaded in the same | |
| 722 // way, so just add a suggestion instead. | |
| 723 // TODO(mmenke): Make the reload button bring up the repost confirmation | |
| 724 // dialog for pages resulting from posts. | |
| 725 base::DictionaryValue* suggest_reload_repost = new base::DictionaryValue; | |
| 726 suggest_reload_repost->SetString("header", | |
| 727 l10n_util::GetStringUTF16( | |
| 728 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_HEADER)); | |
| 729 suggest_reload_repost->SetString("body", | |
| 730 l10n_util::GetStringUTF16( | |
| 731 IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_BODY)); | |
| 732 // Add at the front, so it appears before other suggestions, in the case | |
| 733 // suggestions are being overridden by |params|. | |
| 734 suggestions->Insert(0, suggest_reload_repost); | |
| 735 } | |
| 736 } | 994 } |
| 737 | 995 |
| 738 // If not using the default suggestions, nothing else to do. | 996 // If not using the default suggestions, nothing else to do. |
| 739 if (!use_default_suggestions) | 997 if (!use_default_suggestions) |
| 740 return; | 998 return; |
| 741 | 999 |
| 1000 // Add default suggestions and any relevant supporting details. | |
| 1001 GetSuggestionsSummaryList(error_code, error_strings, options.suggestions, | |
| 1002 locale, suggestions_summary_list); | |
| 1003 AddSuggestionsDetails(error_code, error_strings, options.suggestions, | |
| 1004 suggestions_details); | |
| 1005 | |
| 1006 // Add action buttons. | |
| 742 const std::string& show_saved_copy_value = | 1007 const std::string& show_saved_copy_value = |
| 743 command_line->GetSwitchValueASCII(error_page::switches::kShowSavedCopy); | 1008 command_line->GetSwitchValueASCII(error_page::switches::kShowSavedCopy); |
| 744 bool show_saved_copy_primary = | 1009 bool show_saved_copy_primary = |
| 745 (show_saved_copy_value == | 1010 (show_saved_copy_value == |
| 746 error_page::switches::kEnableShowSavedCopyPrimary); | 1011 error_page::switches::kEnableShowSavedCopyPrimary); |
| 747 bool show_saved_copy_secondary = | 1012 bool show_saved_copy_secondary = |
| 748 (show_saved_copy_value == | 1013 (show_saved_copy_value == |
| 749 error_page::switches::kEnableShowSavedCopySecondary); | 1014 error_page::switches::kEnableShowSavedCopySecondary); |
| 750 bool show_saved_copy_visible = | 1015 bool show_saved_copy_visible = |
| 751 (stale_copy_in_cache && !is_post && | 1016 (stale_copy_in_cache && !is_post && |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 793 #if defined(OS_CHROMEOS) | 1058 #if defined(OS_CHROMEOS) |
| 794 // ChromeOS has its own diagnostics extension, which doesn't rely on a | 1059 // ChromeOS has its own diagnostics extension, which doesn't rely on a |
| 795 // browser-initiated dialog. | 1060 // browser-initiated dialog. |
| 796 can_show_network_diagnostics_dialog = true; | 1061 can_show_network_diagnostics_dialog = true; |
| 797 #endif | 1062 #endif |
| 798 if (can_show_network_diagnostics_dialog && failed_url.is_valid() && | 1063 if (can_show_network_diagnostics_dialog && failed_url.is_valid() && |
| 799 failed_url.SchemeIsHTTPOrHTTPS()) { | 1064 failed_url.SchemeIsHTTPOrHTTPS()) { |
| 800 error_strings->SetString( | 1065 error_strings->SetString( |
| 801 "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE)); | 1066 "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE)); |
| 802 } | 1067 } |
| 803 | |
| 804 if (options.suggestions & SUGGEST_CHECK_CONNECTION) { | |
| 805 base::DictionaryValue* suggest_check_connection = new base::DictionaryValue; | |
| 806 suggest_check_connection->SetString("header", | |
| 807 l10n_util::GetStringUTF16( | |
| 808 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER)); | |
| 809 suggest_check_connection->SetString("body", | |
| 810 l10n_util::GetStringUTF16( | |
| 811 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_BODY)); | |
| 812 suggestions->Append(suggest_check_connection); | |
| 813 } | |
| 814 | |
| 815 if (options.suggestions & SUGGEST_DNS_CONFIG) { | |
| 816 base::DictionaryValue* suggest_dns_config = new base::DictionaryValue; | |
| 817 suggest_dns_config->SetString("header", | |
| 818 l10n_util::GetStringUTF16( | |
| 819 IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_HEADER)); | |
| 820 suggest_dns_config->SetString("body", | |
| 821 l10n_util::GetStringUTF16( | |
| 822 IDS_ERRORPAGES_SUGGESTION_DNS_CONFIG_BODY)); | |
| 823 suggestions->Append(suggest_dns_config); | |
| 824 | |
| 825 base::DictionaryValue* suggest_network_prediction = | |
| 826 GetStandardMenuItemsText(); | |
| 827 suggest_network_prediction->SetString("header", | |
| 828 l10n_util::GetStringUTF16( | |
| 829 IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_HEADER)); | |
| 830 suggest_network_prediction->SetString("body", | |
| 831 l10n_util::GetStringUTF16( | |
| 832 IDS_ERRORPAGES_SUGGESTION_NETWORK_PREDICTION_BODY)); | |
| 833 suggest_network_prediction->SetString( | |
| 834 "noNetworkPredictionTitle", | |
| 835 l10n_util::GetStringUTF16( | |
| 836 IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION)); | |
| 837 suggestions->Append(suggest_network_prediction); | |
| 838 } | |
| 839 | |
| 840 // TODO(crbug.com/584615): Does it make sense to show all of these | |
| 841 // suggestions on mobile? Several of them seem irrelevant in the mobile | |
| 842 // context. | |
| 843 if (options.suggestions & SUGGEST_FIREWALL_CONFIG) { | |
| 844 base::DictionaryValue* suggest_firewall_config = new base::DictionaryValue; | |
| 845 suggest_firewall_config->SetString("header", | |
| 846 l10n_util::GetStringUTF16( | |
| 847 IDS_ERRORPAGES_SUGGESTION_FIREWALL_CONFIG_HEADER)); | |
| 848 suggest_firewall_config->SetString("body", | |
| 849 l10n_util::GetStringUTF16( | |
| 850 IDS_ERRORPAGES_SUGGESTION_FIREWALL_CONFIG_BODY)); | |
| 851 suggestions->Append(suggest_firewall_config); | |
| 852 } | |
| 853 | |
| 854 if (options.suggestions & SUGGEST_PROXY_CONFIG) { | |
| 855 base::DictionaryValue* suggest_proxy_config = GetStandardMenuItemsText(); | |
| 856 suggest_proxy_config->SetString("header", | |
| 857 l10n_util::GetStringUTF16( | |
| 858 IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_HEADER)); | |
| 859 suggest_proxy_config->SetString("body", | |
| 860 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_SUGGESTION_PROXY_CONFIG_BODY, | |
| 861 l10n_util::GetStringUTF16( | |
| 862 IDS_ERRORPAGES_SUGGESTION_PROXY_DISABLE_PLATFORM))); | |
| 863 suggest_proxy_config->SetString("proxyTitle", | |
| 864 l10n_util::GetStringUTF16(IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON)); | |
| 865 | |
| 866 suggestions->Append(suggest_proxy_config); | |
| 867 } | |
| 868 | |
| 869 if (options.suggestions & SUGGEST_DISABLE_EXTENSION) { | |
| 870 base::DictionaryValue* suggest_disable_extension = | |
| 871 new base::DictionaryValue; | |
| 872 // There's only a header for this suggestion. | |
| 873 suggest_disable_extension->SetString("header", | |
| 874 l10n_util::GetStringUTF16( | |
| 875 IDS_ERRORPAGES_SUGGESTION_DISABLE_EXTENSION_HEADER)); | |
| 876 suggestions->Append(suggest_disable_extension); | |
| 877 } | |
| 878 | |
| 879 if (options.suggestions & SUGGEST_VIEW_POLICIES) { | |
| 880 base::DictionaryValue* suggest_view_policies = new base::DictionaryValue; | |
| 881 suggest_view_policies->SetString( | |
| 882 "header", | |
| 883 l10n_util::GetStringUTF16( | |
| 884 IDS_ERRORPAGES_SUGGESTION_VIEW_POLICIES_HEADER)); | |
| 885 suggest_view_policies->SetString( | |
| 886 "body", | |
| 887 l10n_util::GetStringUTF16( | |
| 888 IDS_ERRORPAGES_SUGGESTION_VIEW_POLICIES_BODY)); | |
| 889 suggestions->Append(suggest_view_policies); | |
| 890 } | |
| 891 | |
| 892 if (options.suggestions & SUGGEST_CONTACT_ADMINISTRATOR) { | |
| 893 base::DictionaryValue* suggest_contant_administrator = | |
| 894 new base::DictionaryValue; | |
| 895 suggest_contant_administrator->SetString( | |
| 896 "body", | |
| 897 l10n_util::GetStringUTF16( | |
| 898 IDS_ERRORPAGES_SUGGESTION_CONTACT_ADMINISTRATOR_BODY)); | |
| 899 suggestions->Append(suggest_contant_administrator); | |
| 900 } | |
| 901 | |
| 902 if (options.suggestions & SUGGEST_LEARNMORE) { | |
| 903 GURL learn_more_url; | |
| 904 switch (options.error_code) { | |
| 905 case net::ERR_TOO_MANY_REDIRECTS: | |
| 906 learn_more_url = GURL(kRedirectLoopLearnMoreUrl); | |
| 907 break; | |
| 908 case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY: | |
| 909 learn_more_url = GURL(kWeakDHKeyLearnMoreUrl); | |
| 910 break; | |
| 911 default: | |
| 912 break; | |
| 913 } | |
| 914 | |
| 915 if (learn_more_url.is_valid()) { | |
| 916 // Add the language parameter to the URL. | |
| 917 std::string query = learn_more_url.query() + "&hl=" + locale; | |
| 918 GURL::Replacements repl; | |
| 919 repl.SetQueryStr(query); | |
| 920 learn_more_url = learn_more_url.ReplaceComponents(repl); | |
| 921 | |
| 922 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue; | |
| 923 // There's only a body for this suggestion. | |
| 924 suggest_learn_more->SetString("body", | |
| 925 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); | |
| 926 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | |
| 927 suggestions->Append(suggest_learn_more); | |
| 928 } | |
| 929 } | |
| 930 | |
| 931 if (options.suggestions & SUGGEST_UNSUPPORTED_CIPHER) { | |
| 932 base::DictionaryValue* suggest_unsupported_cipher = | |
| 933 new base::DictionaryValue; | |
| 934 suggest_unsupported_cipher->SetString( | |
| 935 "body", | |
| 936 l10n_util::GetStringUTF16( | |
| 937 IDS_ERRORPAGES_SUGGESTION_UNSUPPORTED_CIPHER)); | |
| 938 suggestions->Append(suggest_unsupported_cipher); | |
| 939 } | |
| 940 } | 1068 } |
| 941 | 1069 |
| 942 base::string16 LocalizedError::GetErrorDetails(const std::string& error_domain, | 1070 base::string16 LocalizedError::GetErrorDetails(const std::string& error_domain, |
| 943 int error_code, | 1071 int error_code, |
| 944 bool is_post) { | 1072 bool is_post) { |
| 945 const LocalizedErrorMap* error_map = | 1073 const LocalizedErrorMap* error_map = |
| 946 LookupErrorMap(error_domain, error_code, is_post); | 1074 LookupErrorMap(error_domain, error_code, is_post); |
| 947 if (error_map) | 1075 if (error_map) |
| 948 return l10n_util::GetStringUTF16(error_map->details_resource_id); | 1076 return l10n_util::GetStringUTF16(error_map->details_resource_id); |
| 949 else | 1077 else |
| 950 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); | 1078 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); |
| 951 } | 1079 } |
| 952 | 1080 |
| 953 bool LocalizedError::HasStrings(const std::string& error_domain, | 1081 bool LocalizedError::HasStrings(const std::string& error_domain, |
| 954 int error_code) { | 1082 int error_code) { |
| 955 // Whether or not the there are strings for an error does not depend on | 1083 // Whether or not the there are strings for an error does not depend on |
| 956 // whether or not the page was be generated by a POST, so just claim it was | 1084 // whether or not the page was be generated by a POST, so just claim it was |
| 957 // not. | 1085 // not. |
| 958 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL; | 1086 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; |
| 959 } | 1087 } |
| 960 | 1088 |
| 961 } // namespace error_page | 1089 } // namespace error_page |
| OLD | NEW |