OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include "android_webview/renderer/aw_content_renderer_client.h" | 5 #include "android_webview/renderer/aw_content_renderer_client.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "android_webview/browser/aw_browser_context.h" | |
9 #include "android_webview/common/aw_resource.h" | 10 #include "android_webview/common/aw_resource.h" |
10 #include "android_webview/common/aw_switches.h" | 11 #include "android_webview/common/aw_switches.h" |
11 #include "android_webview/common/render_view_messages.h" | 12 #include "android_webview/common/render_view_messages.h" |
12 #include "android_webview/common/url_constants.h" | 13 #include "android_webview/common/url_constants.h" |
13 #include "android_webview/grit/aw_resources.h" | 14 #include "android_webview/grit/aw_resources.h" |
14 #include "android_webview/grit/aw_strings.h" | 15 #include "android_webview/grit/aw_strings.h" |
15 #include "android_webview/renderer/aw_content_settings_client.h" | 16 #include "android_webview/renderer/aw_content_settings_client.h" |
16 #include "android_webview/renderer/aw_key_systems.h" | 17 #include "android_webview/renderer/aw_key_systems.h" |
17 #include "android_webview/renderer/aw_message_port_client.h" | 18 #include "android_webview/renderer/aw_message_port_client.h" |
18 #include "android_webview/renderer/aw_print_web_view_helper_delegate.h" | 19 #include "android_webview/renderer/aw_print_web_view_helper_delegate.h" |
19 #include "android_webview/renderer/aw_render_frame_ext.h" | 20 #include "android_webview/renderer/aw_render_frame_ext.h" |
20 #include "android_webview/renderer/aw_render_view_ext.h" | 21 #include "android_webview/renderer/aw_render_view_ext.h" |
21 #include "android_webview/renderer/print_render_frame_observer.h" | 22 #include "android_webview/renderer/print_render_frame_observer.h" |
22 #include "base/command_line.h" | 23 #include "base/command_line.h" |
23 #include "base/i18n/rtl.h" | 24 #include "base/i18n/rtl.h" |
24 #include "base/message_loop/message_loop.h" | 25 #include "base/message_loop/message_loop.h" |
25 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
26 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
27 #include "components/autofill/content/renderer/autofill_agent.h" | 28 #include "components/autofill/content/renderer/autofill_agent.h" |
28 #include "components/autofill/content/renderer/password_autofill_agent.h" | 29 #include "components/autofill/content/renderer/password_autofill_agent.h" |
29 #include "components/printing/renderer/print_web_view_helper.h" | 30 #include "components/printing/renderer/print_web_view_helper.h" |
30 #include "components/visitedlink/renderer/visitedlink_slave.h" | 31 #include "components/visitedlink/renderer/visitedlink_slave.h" |
32 #include "components/web_restriction/web_restriction_gin_wrapper.h" | |
33 #include "components/web_restriction/web_restriction_provider.h" | |
31 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
32 #include "content/public/renderer/document_state.h" | 35 #include "content/public/renderer/document_state.h" |
33 #include "content/public/renderer/navigation_state.h" | 36 #include "content/public/renderer/navigation_state.h" |
34 #include "content/public/renderer/render_frame.h" | 37 #include "content/public/renderer/render_frame.h" |
35 #include "content/public/renderer/render_thread.h" | 38 #include "content/public/renderer/render_thread.h" |
36 #include "content/public/renderer/render_view.h" | 39 #include "content/public/renderer/render_view.h" |
37 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
38 #include "net/base/net_errors.h" | 41 #include "net/base/net_errors.h" |
39 #include "third_party/WebKit/public/platform/WebString.h" | 42 #include "third_party/WebKit/public/platform/WebString.h" |
40 #include "third_party/WebKit/public/platform/WebURL.h" | 43 #include "third_party/WebKit/public/platform/WebURL.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 scoped_ptr<printing::PrintWebViewHelper::Delegate>( | 171 scoped_ptr<printing::PrintWebViewHelper::Delegate>( |
169 new AwPrintWebViewHelperDelegate())); | 172 new AwPrintWebViewHelperDelegate())); |
170 } | 173 } |
171 | 174 |
172 bool AwContentRendererClient::HasErrorPage(int http_status_code, | 175 bool AwContentRendererClient::HasErrorPage(int http_status_code, |
173 std::string* error_domain) { | 176 std::string* error_domain) { |
174 return http_status_code >= 400; | 177 return http_status_code >= 400; |
175 } | 178 } |
176 | 179 |
177 void AwContentRendererClient::GetNavigationErrorStrings( | 180 void AwContentRendererClient::GetNavigationErrorStrings( |
178 content::RenderFrame* /* render_frame */, | 181 content::RenderFrame* render_frame, |
179 const blink::WebURLRequest& failed_request, | 182 const blink::WebURLRequest& failed_request, |
180 const blink::WebURLError& error, | 183 const blink::WebURLError& error, |
181 std::string* error_html, | 184 std::string* error_html, |
182 base::string16* error_description) { | 185 base::string16* error_description) { |
183 if (error_html) { | 186 if (error_html) { |
184 std::string url = | 187 GURL gurl(failed_request.url()); |
185 net::EscapeForHTML(GURL(failed_request.url()).possibly_invalid_spec()); | 188 std::string url = net::EscapeForHTML(gurl.possibly_invalid_spec()); |
186 std::string err = | 189 std::string err = |
187 base::UTF16ToUTF8(base::StringPiece16(error.localizedDescription)); | 190 base::UTF16ToUTF8(base::StringPiece16(error.localizedDescription)); |
188 | 191 |
189 std::vector<std::string> replacements; | 192 std::vector<std::string> replacements; |
190 replacements.push_back( | 193 replacements.push_back( |
191 l10n_util::GetStringUTF8(IDS_AW_WEBPAGE_NOT_AVAILABLE)); | 194 l10n_util::GetStringUTF8(IDS_AW_WEBPAGE_NOT_AVAILABLE)); |
192 if (err.empty()) { | 195 if (err.empty()) { |
193 replacements.push_back(l10n_util::GetStringFUTF8( | 196 replacements.push_back(l10n_util::GetStringFUTF8( |
194 IDS_AW_WEBPAGE_TEMPORARILY_DOWN, base::UTF8ToUTF16(url))); | 197 IDS_AW_WEBPAGE_TEMPORARILY_DOWN, base::UTF8ToUTF16(url))); |
195 replacements.push_back(l10n_util::GetStringUTF8( | 198 replacements.push_back(l10n_util::GetStringUTF8( |
196 IDS_AW_WEBPAGE_TEMPORARILY_DOWN_SUGGESTIONS)); | 199 IDS_AW_WEBPAGE_TEMPORARILY_DOWN_SUGGESTIONS)); |
197 } else { | 200 } else { |
198 replacements.push_back(l10n_util::GetStringFUTF8( | 201 replacements.push_back(l10n_util::GetStringFUTF8( |
199 IDS_AW_WEBPAGE_CAN_NOT_BE_LOADED, base::UTF8ToUTF16(url))); | 202 IDS_AW_WEBPAGE_CAN_NOT_BE_LOADED, base::UTF8ToUTF16(url))); |
200 replacements.push_back(err); | 203 replacements.push_back(err); |
201 } | 204 } |
202 if (base::i18n::IsRTL()) | 205 if (base::i18n::IsRTL()) |
203 replacements.push_back("direction: rtl;"); | 206 replacements.push_back("direction: rtl;"); |
204 else | 207 else |
205 replacements.push_back(""); | 208 replacements.push_back(""); |
206 *error_html = base::ReplaceStringPlaceholders( | 209 *error_html = base::ReplaceStringPlaceholders( |
207 ResourceBundle::GetSharedInstance().GetRawDataResource( | 210 ResourceBundle::GetSharedInstance().GetRawDataResource( |
208 IDR_AW_LOAD_ERROR_HTML), | 211 IDR_AW_LOAD_ERROR_HTML), |
209 replacements, nullptr); | 212 replacements, nullptr); |
213 if (error.reason == net::ERR_BLOCKED_BY_ADMINISTRATOR) { | |
214 // Move to aw/common/ if chrome's solution is too complicated | |
215 auto web_restriction_provider = | |
216 AwBrowserContext::GetDefault()->GetWebRestrictionProvider(); | |
217 std::string restricted_page; | |
218 if (web_restriction_provider->GetErrorHtml(gurl, &restricted_page)) | |
219 *error_html = restricted_page; | |
220 if (web_restriction_provider->SupportsRequest()) | |
221 web_restriction::WebRestrictionGinWrapper::Install(render_frame); | |
jochen (gone - plz use gerrit)
2016/02/22 14:24:43
you install the gin wrapper before you actually na
| |
222 } | |
210 } | 223 } |
211 if (error_description) { | 224 if (error_description) { |
212 if (error.localizedDescription.isEmpty()) | 225 if (error.localizedDescription.isEmpty()) |
213 *error_description = base::ASCIIToUTF16(net::ErrorToString(error.reason)); | 226 *error_description = base::ASCIIToUTF16(net::ErrorToString(error.reason)); |
214 else | 227 else |
215 *error_description = error.localizedDescription; | 228 *error_description = error.localizedDescription; |
216 } | 229 } |
217 } | 230 } |
218 | 231 |
219 unsigned long long AwContentRendererClient::VisitedLinkHash( | 232 unsigned long long AwContentRendererClient::VisitedLinkHash( |
(...skipping 16 matching lines...) Expand all Loading... | |
236 blink::WebPageVisibilityState* override_state) { | 249 blink::WebPageVisibilityState* override_state) { |
237 if (disable_page_visibility_) { | 250 if (disable_page_visibility_) { |
238 *override_state = blink::WebPageVisibilityStateVisible; | 251 *override_state = blink::WebPageVisibilityStateVisible; |
239 return true; | 252 return true; |
240 } | 253 } |
241 | 254 |
242 return false; | 255 return false; |
243 } | 256 } |
244 | 257 |
245 } // namespace android_webview | 258 } // namespace android_webview |
OLD | NEW |