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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1012 bool ChromeContentRendererClient::ShouldSuppressErrorPage( | 1012 bool ChromeContentRendererClient::ShouldSuppressErrorPage( |
1013 content::RenderFrame* render_frame, | 1013 content::RenderFrame* render_frame, |
1014 const GURL& url) { | 1014 const GURL& url) { |
1015 // Unit tests for ChromeContentRendererClient pass a NULL RenderFrame here. | 1015 // Unit tests for ChromeContentRendererClient pass a NULL RenderFrame here. |
1016 // Unfortunately it's very difficult to construct a mock RenderView, so skip | 1016 // Unfortunately it's very difficult to construct a mock RenderView, so skip |
1017 // this functionality in this case. | 1017 // this functionality in this case. |
1018 if (render_frame && | 1018 if (render_frame && |
1019 NetErrorHelper::Get(render_frame)->ShouldSuppressErrorPage(url)) { | 1019 NetErrorHelper::Get(render_frame)->ShouldSuppressErrorPage(url)) { |
1020 return true; | 1020 return true; |
1021 } | 1021 } |
1022 | |
1023 #if defined(ENABLE_EXTENSIONS) | |
1024 // Suppress error pages for the webstore when it's loaded in a frame. This | |
1025 // mitigates confusion which could arise from the fact that error pages commit | |
1026 // with the same URL as the failed load. Since pieces of the browser sometimes | |
1027 // rely on the last-committed URL as a permission check of sorts, and the | |
1028 // webstore is a special flower, this can cause problems that we can avoid by | |
1029 // simply suppressing the error page (see https://crbug.com/622385, for | |
1030 // example). | |
1031 GURL webstore_url(extension_urls::GetWebstoreLaunchURL()); | |
1032 if (!render_frame->IsMainFrame() && | |
1033 url.SchemeIsHTTPOrHTTPS() && | |
1034 url.DomainIs(webstore_url.host().c_str())) { | |
1035 return true; | |
1036 } | |
1037 #endif | |
1038 | |
Mike West
2016/09/14 09:21:24
This is ugly. But without some ~large refactoring
alexmos
2016/09/14 20:25:10
Yeah, a bit unfortunate that we have to do this, b
Charlie Reis
2016/09/14 21:39:05
Hmm, I'm not ok with this change. This check isn'
alexmos
2016/09/17 01:43:16
Given Charlie's comments, and as a way to make pro
| |
1022 // Do not flash an error page if the Instant new tab page fails to load. | 1039 // Do not flash an error page if the Instant new tab page fails to load. |
1023 return SearchBouncer::GetInstance()->IsNewTabPage(url); | 1040 return SearchBouncer::GetInstance()->IsNewTabPage(url); |
1024 } | 1041 } |
1025 | 1042 |
1026 void ChromeContentRendererClient::GetNavigationErrorStrings( | 1043 void ChromeContentRendererClient::GetNavigationErrorStrings( |
1027 content::RenderFrame* render_frame, | 1044 content::RenderFrame* render_frame, |
1028 const WebURLRequest& failed_request, | 1045 const WebURLRequest& failed_request, |
1029 const WebURLError& error, | 1046 const WebURLError& error, |
1030 std::string* error_html, | 1047 std::string* error_html, |
1031 base::string16* error_description) { | 1048 base::string16* error_description) { |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1473 | 1490 |
1474 url::Replacements<char> r; | 1491 url::Replacements<char> r; |
1475 r.SetPath(path.c_str(), url::Component(0, path.length())); | 1492 r.SetPath(path.c_str(), url::Component(0, path.length())); |
1476 | 1493 |
1477 if (result == internal::NUM_PLUGIN_ERROR) | 1494 if (result == internal::NUM_PLUGIN_ERROR) |
1478 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS; | 1495 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS; |
1479 | 1496 |
1480 RecordYouTubeRewriteUMA(result); | 1497 RecordYouTubeRewriteUMA(result); |
1481 return corrected_url.ReplaceComponents(r); | 1498 return corrected_url.ReplaceComponents(r); |
1482 } | 1499 } |
OLD | NEW |