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" | |
12 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
13 #include "url/gurl.h" | 12 |
| 13 class GURL; |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class DictionaryValue; | 16 class DictionaryValue; |
17 class ListValue; | |
18 } | 17 } |
19 | 18 |
20 namespace extensions { | 19 namespace extensions { |
21 class Extension; | 20 class Extension; |
22 } | 21 } |
23 | 22 |
24 namespace blink { | 23 namespace blink { |
25 struct WebURLError; | 24 struct WebURLError; |
26 } | 25 } |
27 | 26 |
28 class LocalizedError { | 27 class LocalizedError { |
29 public: | 28 public: |
30 // Optional parameters that affect the display of an error page. | |
31 struct ErrorPageParams { | |
32 ErrorPageParams(); | |
33 ~ErrorPageParams(); | |
34 | |
35 // Overrides whether reloading is suggested. | |
36 bool suggest_reload; | |
37 | |
38 // Overrides default suggestions. Each entry must contain a header and may | |
39 // optionally contain a body as well. Must not be NULL. | |
40 scoped_ptr<base::ListValue> override_suggestions; | |
41 | |
42 // Prefix to prepend to search terms. Search box is only shown if this is | |
43 // a valid url. The search terms will be appended to the end of this URL to | |
44 // conduct a search. | |
45 GURL search_url; | |
46 // Default search terms. Ignored if |search_url| is invalid. | |
47 std::string search_terms; | |
48 }; | |
49 | |
50 // Fills |error_strings| with values to be used to build an error page used | 29 // Fills |error_strings| with values to be used to build an error page used |
51 // on HTTP errors, like 404 or connection reset. | 30 // on HTTP errors, like 404 or connection reset. |
52 static void GetStrings(int error_code, | 31 static void GetStrings(int error_code, |
53 const std::string& error_domain, | 32 const std::string& error_domain, |
54 const GURL& failed_url, | 33 const GURL& failed_url, |
55 bool is_post, | 34 bool is_post, |
56 bool stale_copy_in_cache, | 35 bool stale_copy_in_cache, |
57 const std::string& locale, | 36 const std::string& locale, |
58 const std::string& accept_languages, | 37 const std::string& accept_languages, |
59 scoped_ptr<ErrorPageParams> params, | |
60 base::DictionaryValue* strings); | 38 base::DictionaryValue* strings); |
61 | 39 |
62 // Returns a description of the encountered error. | 40 // Returns a description of the encountered error. |
63 static base::string16 GetErrorDetails(const blink::WebURLError& error, | 41 static base::string16 GetErrorDetails(const blink::WebURLError& error, |
64 bool is_post); | 42 bool is_post); |
65 | 43 |
66 // Returns true if an error page exists for the specified parameters. | 44 // Returns true if an error page exists for the specified parameters. |
67 static bool HasStrings(const std::string& error_domain, int error_code); | 45 static bool HasStrings(const std::string& error_domain, int error_code); |
68 | 46 |
69 // Fills |error_strings| with values to be used to build an error page used | 47 // Fills |error_strings| with values to be used to build an error page used |
70 // on HTTP errors, like 404 or connection reset, but using information from | 48 // on HTTP errors, like 404 or connection reset, but using information from |
71 // the associated |app| in order to make the error page look like it's more | 49 // the associated |app| in order to make the error page look like it's more |
72 // part of the app. | 50 // part of the app. |
73 static void GetAppErrorStrings(const GURL& display_url, | 51 static void GetAppErrorStrings(const GURL& display_url, |
74 const extensions::Extension* app, | 52 const extensions::Extension* app, |
75 base::DictionaryValue* error_strings); | 53 base::DictionaryValue* error_strings); |
76 | 54 |
77 static const char kHttpErrorDomain[]; | 55 static const char kHttpErrorDomain[]; |
78 | 56 |
79 private: | 57 private: |
80 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError); | 58 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError); |
81 }; | 59 }; |
82 | 60 |
83 #endif // CHROME_COMMON_LOCALIZED_ERROR_H_ | 61 #endif // CHROME_COMMON_LOCALIZED_ERROR_H_ |
OLD | NEW |