Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / common / localized_error.h
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.
4
5 #ifndef CHROME_COMMON_LOCALIZED_ERROR_H_
6 #define CHROME_COMMON_LOCALIZED_ERROR_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12
13 class GURL;
14
15 namespace base {
16 class DictionaryValue;
17 }
18
19 namespace extensions {
20 class Extension;
21 }
22
23 namespace blink {
24 struct WebURLError;
25 }
26
27 class LocalizedError {
28  public:
29   // Fills |error_strings| with values to be used to build an error page used
30   // on HTTP errors, like 404 or connection reset.
31   static void GetStrings(int error_code,
32                          const std::string& error_domain,
33                          const GURL& failed_url,
34                          bool is_post,
35                          bool stale_copy_in_cache,
36                          const std::string& locale,
37                          const std::string& accept_languages,
38                          base::DictionaryValue* strings);
39
40   // Returns a description of the encountered error.
41   static base::string16 GetErrorDetails(const blink::WebURLError& error,
42                                         bool is_post);
43
44   // Returns true if an error page exists for the specified parameters.
45   static bool HasStrings(const std::string& error_domain, int error_code);
46
47   // Fills |error_strings| with values to be used to build an error page used
48   // on HTTP errors, like 404 or connection reset, but using information from
49   // the associated |app| in order to make the error page look like it's more
50   // part of the app.
51   static void GetAppErrorStrings(const GURL& display_url,
52                                  const extensions::Extension* app,
53                                  base::DictionaryValue* error_strings);
54
55   static const char kHttpErrorDomain[];
56
57  private:
58   DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError);
59 };
60
61 #endif  // CHROME_COMMON_LOCALIZED_ERROR_H_