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

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: 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 | no next file » | 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..5b4bbc14c6ec1d3effecf51c9f5545e5b61472db 100644
--- a/chrome/browser/translate/translate_manager.cc
+++ b/chrome/browser/translate/translate_manager.cc
@@ -101,6 +101,20 @@ 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)
+
+ // get file extension (empty if URL does not reference a file)
Miguel Garcia 2013/07/22 17:42:00 I'd move this to a method and add a unittest for i
+ std::string file_name, file_extension;
+ size_t path_delim = url.path().rfind('/');
+ if (path_delim != std::string::npos) {
+ file_name = url.path().substr(path_delim+1);
+ size_t file_delim = file_name.rfind('.');
+ if (file_delim != std::string::npos) {
+ file_extension = file_name.substr(file_delim+1);
+ }
+ }
+
return !url.is_empty() &&
!url.SchemeIs(chrome::kChromeUIScheme) &&
!url.SchemeIs(chrome::kChromeDevToolsScheme) &&
@@ -108,7 +122,8 @@ bool TranslateManager::IsTranslatableURL(const GURL& url) {
!(url.SchemeIs(extensions::kExtensionScheme) &&
url.DomainIs(kFileBrowserDomain)) &&
#endif
- !url.SchemeIs(chrome::kFtpScheme);
+ !url.SchemeIs(chrome::kFtpScheme) &&
+ !(file_extension == "mht" || file_extension == "mhtml");
Miguel Garcia 2013/07/22 17:42:00 create constants perhaps?
}
// static
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698