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
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_LOCALIZED_ERROR_H_
6 #define CHROME_COMMON_LOCALIZED_ERROR_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
16 class DictionaryValue;
20 namespace extensions {
28 class LocalizedError {
30 // Optional parameters that affect the display of an error page.
31 struct ErrorPageParams {
35 // Overrides whether reloading is suggested.
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;
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
46 // Default search terms. Ignored if |search_url| is invalid.
47 std::string search_terms;
50 // Fills |error_strings| with values to be used to build an error page used
51 // on HTTP errors, like 404 or connection reset.
52 static void GetStrings(int error_code,
53 const std::string& error_domain,
54 const GURL& failed_url,
56 bool stale_copy_in_cache,
57 const std::string& locale,
58 const std::string& accept_languages,
59 scoped_ptr<ErrorPageParams> params,
60 base::DictionaryValue* strings);
62 // Returns a description of the encountered error.
63 static base::string16 GetErrorDetails(const blink::WebURLError& error,
66 // Returns true if an error page exists for the specified parameters.
67 static bool HasStrings(const std::string& error_domain, int error_code);
69 // 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
71 // the associated |app| in order to make the error page look like it's more
73 static void GetAppErrorStrings(const GURL& display_url,
74 const extensions::Extension* app,
75 base::DictionaryValue* error_strings);
77 static const char kHttpErrorDomain[];
80 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError);
83 #endif // CHROME_COMMON_LOCALIZED_ERROR_H_