OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 bool ChromeContentRendererClient::ShouldSuppressErrorPage( | 1007 bool ChromeContentRendererClient::ShouldSuppressErrorPage( |
1008 content::RenderFrame* render_frame, | 1008 content::RenderFrame* render_frame, |
1009 const GURL& url) { | 1009 const GURL& url) { |
1010 // Unit tests for ChromeContentRendererClient pass a NULL RenderFrame here. | 1010 // Unit tests for ChromeContentRendererClient pass a NULL RenderFrame here. |
1011 // Unfortunately it's very difficult to construct a mock RenderView, so skip | 1011 // Unfortunately it's very difficult to construct a mock RenderView, so skip |
1012 // this functionality in this case. | 1012 // this functionality in this case. |
1013 if (render_frame && | 1013 if (render_frame && |
1014 NetErrorHelper::Get(render_frame)->ShouldSuppressErrorPage(url)) { | 1014 NetErrorHelper::Get(render_frame)->ShouldSuppressErrorPage(url)) { |
1015 return true; | 1015 return true; |
1016 } | 1016 } |
| 1017 |
| 1018 #if defined(ENABLE_EXTENSIONS) |
| 1019 // Suppress error pages for the webstore when it's loaded in a frame. This |
| 1020 // mitigates confusion which could arise from the fact that error pages commit |
| 1021 // with the same URL as the failed load. Since pieces of the browser sometimes |
| 1022 // rely on the last-committed URL as a permission check of sorts, and the |
| 1023 // webstore is a special flower, this can cause problems that we can avoid by |
| 1024 // simply suppressing the error page (see https://crbug.com/622385, for |
| 1025 // example). |
| 1026 GURL webstore_url(extension_urls::GetWebstoreLaunchURL()); |
| 1027 if (!render_frame->IsMainFrame() && url.SchemeIsHTTPOrHTTPS() && |
| 1028 url.DomainIs(webstore_url.host().c_str())) { |
| 1029 return true; |
| 1030 } |
| 1031 #endif |
| 1032 |
1017 // Do not flash an error page if the Instant new tab page fails to load. | 1033 // Do not flash an error page if the Instant new tab page fails to load. |
1018 return SearchBouncer::GetInstance()->IsNewTabPage(url); | 1034 return SearchBouncer::GetInstance()->IsNewTabPage(url); |
1019 } | 1035 } |
1020 | 1036 |
1021 void ChromeContentRendererClient::GetNavigationErrorStrings( | 1037 void ChromeContentRendererClient::GetNavigationErrorStrings( |
1022 content::RenderFrame* render_frame, | 1038 content::RenderFrame* render_frame, |
1023 const WebURLRequest& failed_request, | 1039 const WebURLRequest& failed_request, |
1024 const WebURLError& error, | 1040 const WebURLError& error, |
1025 std::string* error_html, | 1041 std::string* error_html, |
1026 base::string16* error_description) { | 1042 base::string16* error_description) { |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 | 1499 |
1484 url::Replacements<char> r; | 1500 url::Replacements<char> r; |
1485 r.SetPath(path.c_str(), url::Component(0, path.length())); | 1501 r.SetPath(path.c_str(), url::Component(0, path.length())); |
1486 | 1502 |
1487 if (result == internal::NUM_PLUGIN_ERROR) | 1503 if (result == internal::NUM_PLUGIN_ERROR) |
1488 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS; | 1504 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS; |
1489 | 1505 |
1490 RecordYouTubeRewriteUMA(result); | 1506 RecordYouTubeRewriteUMA(result); |
1491 return corrected_url.ReplaceComponents(r); | 1507 return corrected_url.ReplaceComponents(r); |
1492 } | 1508 } |
OLD | NEW |