Upstream version 11.40.277.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/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "url/gurl.h"
14
15 namespace base {
16 class DictionaryValue;
17 class ListValue;
18 }
19
20 namespace extensions {
21 class Extension;
22 }
23
24 namespace blink {
25 struct WebURLError;
26 }
27
28 namespace error_page {
29 struct ErrorPageParams;
30 }
31
32 class LocalizedError {
33  public:
34   // Fills |error_strings| with values to be used to build an error page used
35   // on HTTP errors, like 404 or connection reset.
36   static void GetStrings(int error_code,
37                          const std::string& error_domain,
38                          const GURL& failed_url,
39                          bool is_post,
40                          bool show_stale_load_button,
41                          const std::string& locale,
42                          const std::string& accept_languages,
43                          scoped_ptr<error_page::ErrorPageParams> params,
44                          base::DictionaryValue* strings);
45
46   // Returns a description of the encountered error.
47   static base::string16 GetErrorDetails(const blink::WebURLError& error,
48                                         bool is_post);
49
50   // Returns true if an error page exists for the specified parameters.
51   static bool HasStrings(const std::string& error_domain, int error_code);
52
53 #if defined(ENABLE_EXTENSIONS)
54   // Fills |error_strings| with values to be used to build an error page used
55   // on HTTP errors, like 404 or connection reset, but using information from
56   // the associated |app| in order to make the error page look like it's more
57   // part of the app.
58   static void GetAppErrorStrings(const GURL& display_url,
59                                  const extensions::Extension* app,
60                                  base::DictionaryValue* error_strings);
61 #endif
62
63   static const char kHttpErrorDomain[];
64
65  private:
66   DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError);
67 };
68
69 #endif  // CHROME_COMMON_LOCALIZED_ERROR_H_