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

Unified Diff: chrome/browser/chromeos/gdata/gdata_protocol_handler.cc

Issue 10559086: Fixing mime type so that MHTML files can be opened directly from Google Drive. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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/chromeos/gdata/gdata_protocol_handler.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_protocol_handler.cc b/chrome/browser/chromeos/gdata/gdata_protocol_handler.cc
index 271f8bc6d82f20301ef07eb294b8cdfb5ceb2c9a..a53496f2560e2fc527c85073da2026cc38f5e3a0 100644
--- a/chrome/browser/chromeos/gdata/gdata_protocol_handler.cc
+++ b/chrome/browser/chromeos/gdata/gdata_protocol_handler.cc
@@ -59,6 +59,23 @@ const char kHTTPInternalErrorText[] = "Internal Error";
// Initial size of download buffer, same as kBufferSize used for URLFetcherCore.
const int kInitialDownloadBufferSizeInBytes = 4096;
+struct MimeTypeReplacement {
+ const char* original_type;
+ const char* new_type;
+};
+
+const MimeTypeReplacement kMimeTypeReplacements[] = {
+ {"message/rfc822","multipart/related"} // Fixes MHTML
+};
+
+std::string FixupMimeType(const std::string& type) {
+ for (size_t i = 0; i < arraysize(kMimeTypeReplacements); i++) {
+ if (type == kMimeTypeReplacements[i].original_type)
+ return kMimeTypeReplacements[i].new_type;
+ }
+ return type;
+}
+
// Empty callback for net::FileStream::Close().
void EmptyCompletionCallback(int) {
}
@@ -325,7 +342,7 @@ void GDataURLRequestJob::Kill() {
bool GDataURLRequestJob::GetMimeType(std::string* mime_type) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- mime_type->assign(mime_type_);
+ mime_type->assign(FixupMimeType(mime_type_));
return !mime_type->empty();
}
« 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