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/strings/string16.h" | 12 #include "base/strings/string16.h" |
12 | 13 #include "url/gurl.h" |
13 class GURL; | |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class DictionaryValue; | 16 class DictionaryValue; |
| 17 class ListValue; |
17 } | 18 } |
18 | 19 |
19 namespace extensions { | 20 namespace extensions { |
20 class Extension; | 21 class Extension; |
21 } | 22 } |
22 | 23 |
23 namespace blink { | 24 namespace blink { |
24 struct WebURLError; | 25 struct WebURLError; |
25 } | 26 } |
26 | 27 |
27 class LocalizedError { | 28 class LocalizedError { |
28 public: | 29 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. |
| 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. Currently only Google searches are supported (Must use |
| 44 // GET with a query parameter named "q"). |
| 45 GURL search_url; |
| 46 // Default search terms. Ignored if |search_prefix| is invalid. |
| 47 std::string search_terms; |
| 48 }; |
| 49 |
29 // Fills |error_strings| with values to be used to build an error page used | 50 // Fills |error_strings| with values to be used to build an error page used |
30 // on HTTP errors, like 404 or connection reset. | 51 // on HTTP errors, like 404 or connection reset. |
31 static void GetStrings(int error_code, | 52 static void GetStrings(int error_code, |
32 const std::string& error_domain, | 53 const std::string& error_domain, |
33 const GURL& failed_url, | 54 const GURL& failed_url, |
34 bool is_post, | 55 bool is_post, |
35 const std::string& locale, | 56 const std::string& locale, |
36 const std::string& accept_languages, | 57 const std::string& accept_languages, |
| 58 scoped_ptr<ErrorPageParams> params, |
37 base::DictionaryValue* strings); | 59 base::DictionaryValue* strings); |
38 | 60 |
39 // Returns a description of the encountered error. | 61 // Returns a description of the encountered error. |
40 static base::string16 GetErrorDetails(const blink::WebURLError& error, | 62 static base::string16 GetErrorDetails(const blink::WebURLError& error, |
41 bool is_post); | 63 bool is_post); |
42 | 64 |
43 // Returns true if an error page exists for the specified parameters. | 65 // Returns true if an error page exists for the specified parameters. |
44 static bool HasStrings(const std::string& error_domain, int error_code); | 66 static bool HasStrings(const std::string& error_domain, int error_code); |
45 | 67 |
46 // Fills |error_strings| with values to be used to build an error page used | 68 // Fills |error_strings| with values to be used to build an error page used |
47 // on HTTP errors, like 404 or connection reset, but using information from | 69 // on HTTP errors, like 404 or connection reset, but using information from |
48 // the associated |app| in order to make the error page look like it's more | 70 // the associated |app| in order to make the error page look like it's more |
49 // part of the app. | 71 // part of the app. |
50 static void GetAppErrorStrings(const GURL& display_url, | 72 static void GetAppErrorStrings(const GURL& display_url, |
51 const extensions::Extension* app, | 73 const extensions::Extension* app, |
52 base::DictionaryValue* error_strings); | 74 base::DictionaryValue* error_strings); |
53 | 75 |
54 static const char kHttpErrorDomain[]; | 76 static const char kHttpErrorDomain[]; |
55 | 77 |
56 private: | 78 private: |
57 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError); | 79 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError); |
58 }; | 80 }; |
59 | 81 |
60 #endif // CHROME_COMMON_LOCALIZED_ERROR_H_ | 82 #endif // CHROME_COMMON_LOCALIZED_ERROR_H_ |
OLD | NEW |