| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_COMMON_LOCALIZED_ERROR_H_ | 5 #ifndef CHROME_COMMON_LOCALIZED_ERROR_H_ |
| 6 #define CHROME_COMMON_LOCALIZED_ERROR_H_ | 6 #define CHROME_COMMON_LOCALIZED_ERROR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class DictionaryValue; | 16 class DictionaryValue; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 struct WebURLError; | 20 struct WebURLError; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace error_page { | 23 namespace error_page { |
| 24 struct ErrorPageParams; | 24 struct ErrorPageParams; |
| 25 } | 25 } |
| 26 | 26 |
| 27 enum class OfflinePageStatus { |
| 28 // No offline page exists. |
| 29 NONE, |
| 30 // The offline copy of this page exists. |
| 31 HAS_PAGE_COPY, |
| 32 // The offline copy of this page does not exist, but the offline copies of |
| 33 // other pages exist. |
| 34 HAS_OTHER_COPIES, |
| 35 }; |
| 36 |
| 27 class LocalizedError { | 37 class LocalizedError { |
| 28 public: | 38 public: |
| 39 |
| 29 // Fills |error_strings| with values to be used to build an error page used | 40 // Fills |error_strings| with values to be used to build an error page used |
| 30 // on HTTP errors, like 404 or connection reset. | 41 // on HTTP errors, like 404 or connection reset. |
| 31 static void GetStrings(int error_code, | 42 static void GetStrings(int error_code, |
| 32 const std::string& error_domain, | 43 const std::string& error_domain, |
| 33 const GURL& failed_url, | 44 const GURL& failed_url, |
| 34 bool is_post, | 45 bool is_post, |
| 35 bool stale_copy_in_cache, | 46 bool stale_copy_in_cache, |
| 36 bool can_show_network_diagnostics_dialog, | 47 bool can_show_network_diagnostics_dialog, |
| 37 bool has_offline_pages, | 48 OfflinePageStatus offline_page_status, |
| 38 const std::string& locale, | 49 const std::string& locale, |
| 39 const std::string& accept_languages, | 50 const std::string& accept_languages, |
| 40 scoped_ptr<error_page::ErrorPageParams> params, | 51 scoped_ptr<error_page::ErrorPageParams> params, |
| 41 base::DictionaryValue* strings); | 52 base::DictionaryValue* strings); |
| 42 | 53 |
| 43 // Returns a description of the encountered error. | 54 // Returns a description of the encountered error. |
| 44 static base::string16 GetErrorDetails(const blink::WebURLError& error, | 55 static base::string16 GetErrorDetails(const blink::WebURLError& error, |
| 45 bool is_post); | 56 bool is_post); |
| 46 | 57 |
| 47 // Returns true if an error page exists for the specified parameters. | 58 // Returns true if an error page exists for the specified parameters. |
| 48 static bool HasStrings(const std::string& error_domain, int error_code); | 59 static bool HasStrings(const std::string& error_domain, int error_code); |
| 49 | 60 |
| 50 static const char kHttpErrorDomain[]; | 61 static const char kHttpErrorDomain[]; |
| 51 | 62 |
| 52 private: | 63 private: |
| 53 | 64 |
| 54 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError); | 65 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError); |
| 55 }; | 66 }; |
| 56 | 67 |
| 57 #endif // CHROME_COMMON_LOCALIZED_ERROR_H_ | 68 #endif // CHROME_COMMON_LOCALIZED_ERROR_H_ |
| OLD | NEW |