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

Unified Diff: chrome/browser/translate/translate_manager.cc

Issue 19857005: Do not show translate bar for MHTML files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add and use GURL::ExtractFileExtension() Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | url/gurl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/translate/translate_manager.cc
diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc
index a9979ed6cb47e6b5753a91aba73f14faf2aae3e8..201f7e88f793d066b0b3caeda184e47a6dc14ea1 100644
--- a/chrome/browser/translate/translate_manager.cc
+++ b/chrome/browser/translate/translate_manager.cc
@@ -81,6 +81,10 @@ const int kTranslateLoadCheckDelayMs = 150;
// loading before giving up the translation
const int kMaxTranslateLoadCheckAttempts = 20;
+// file extensions tested for in IsTranslatableURL()
+const char kFileExtMHTMLShort[] = "mht";
+const char kFileExtMHTMLLong[] = "mhtml";
+
} // namespace
TranslateManager::~TranslateManager() {
@@ -101,6 +105,12 @@ bool TranslateManager::IsTranslatableURL(const GURL& url) {
// - Chrome OS file manager extension
// - an FTP page (as FTP pages tend to have long lists of filenames that may
// confuse the CLD)
+ // - an MHTML page (Chrome does not load external resources when displaying
+ // MHTML pages, see bug 262953)
+
+ // extract file extension (empty if URL does not reference a file)
+ std::string file_extension = url.ExtractFileExtension();
+
return !url.is_empty() &&
!url.SchemeIs(chrome::kChromeUIScheme) &&
!url.SchemeIs(chrome::kChromeDevToolsScheme) &&
@@ -108,7 +118,9 @@ bool TranslateManager::IsTranslatableURL(const GURL& url) {
!(url.SchemeIs(extensions::kExtensionScheme) &&
url.DomainIs(kFileBrowserDomain)) &&
#endif
- !url.SchemeIs(chrome::kFtpScheme);
+ !url.SchemeIs(chrome::kFtpScheme) &&
+ !(file_extension.compare(kFileExtMHTMLShort) == 0 ||
MAD 2013/07/29 20:39:17 Shouldn't we do a case insensitive compare?
+ file_extension.compare(kFileExtMHTMLLong) == 0);
}
// static
« no previous file with comments | « no previous file | url/gurl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698