Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/common/localized_error.h

Issue 570253002: Componentize NetErrorHelperCore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/common/localized_error.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/scoped_ptr.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 namespace base { 15 namespace base {
16 class DictionaryValue; 16 class DictionaryValue;
17 class ListValue; 17 class ListValue;
18 } 18 }
19 19
20 namespace extensions { 20 namespace extensions {
21 class Extension; 21 class Extension;
22 } 22 }
23 23
24 namespace blink { 24 namespace blink {
25 struct WebURLError; 25 struct WebURLError;
26 } 26 }
27 27
28 namespace error_page {
29 struct ErrorPageParams;
30 }
31
28 class LocalizedError { 32 class LocalizedError {
29 public: 33 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 int reload_tracking_id;
38
39 // Overrides default suggestions. Each entry must contain a header and may
40 // optionally contain a body as well. Must not be NULL.
41 scoped_ptr<base::ListValue> override_suggestions;
42
43 // Prefix to prepend to search terms. Search box is only shown if this is
44 // a valid url. The search terms will be appended to the end of this URL to
45 // conduct a search.
46 GURL search_url;
47 // Default search terms. Ignored if |search_url| is invalid.
48 std::string search_terms;
49 int search_tracking_id;
50 };
51
52 // Fills |error_strings| with values to be used to build an error page used 34 // Fills |error_strings| with values to be used to build an error page used
53 // on HTTP errors, like 404 or connection reset. 35 // on HTTP errors, like 404 or connection reset.
54 static void GetStrings(int error_code, 36 static void GetStrings(int error_code,
55 const std::string& error_domain, 37 const std::string& error_domain,
56 const GURL& failed_url, 38 const GURL& failed_url,
57 bool is_post, 39 bool is_post,
58 bool show_stale_load_button, 40 bool show_stale_load_button,
59 const std::string& locale, 41 const std::string& locale,
60 const std::string& accept_languages, 42 const std::string& accept_languages,
61 scoped_ptr<ErrorPageParams> params, 43 scoped_ptr<error_page::ErrorPageParams> params,
62 base::DictionaryValue* strings); 44 base::DictionaryValue* strings);
63 45
64 // Returns a description of the encountered error. 46 // Returns a description of the encountered error.
65 static base::string16 GetErrorDetails(const blink::WebURLError& error, 47 static base::string16 GetErrorDetails(const blink::WebURLError& error,
66 bool is_post); 48 bool is_post);
67 49
68 // Returns true if an error page exists for the specified parameters. 50 // Returns true if an error page exists for the specified parameters.
69 static bool HasStrings(const std::string& error_domain, int error_code); 51 static bool HasStrings(const std::string& error_domain, int error_code);
70 52
71 // Fills |error_strings| with values to be used to build an error page used 53 // Fills |error_strings| with values to be used to build an error page used
72 // on HTTP errors, like 404 or connection reset, but using information from 54 // on HTTP errors, like 404 or connection reset, but using information from
73 // the associated |app| in order to make the error page look like it's more 55 // the associated |app| in order to make the error page look like it's more
74 // part of the app. 56 // part of the app.
75 static void GetAppErrorStrings(const GURL& display_url, 57 static void GetAppErrorStrings(const GURL& display_url,
76 const extensions::Extension* app, 58 const extensions::Extension* app,
77 base::DictionaryValue* error_strings); 59 base::DictionaryValue* error_strings);
78 60
79 static const char kHttpErrorDomain[]; 61 static const char kHttpErrorDomain[];
80 62
81 private: 63 private:
82 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError); 64 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalizedError);
83 }; 65 };
84 66
85 #endif // CHROME_COMMON_LOCALIZED_ERROR_H_ 67 #endif // CHROME_COMMON_LOCALIZED_ERROR_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/common/localized_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698