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

Unified Diff: chrome/browser/dom_ui/chrome_url_data_manager.cc

Issue 10941: Add mimetypes on the "chrome-resource://" responses.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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 | « chrome/browser/dom_ui/chrome_url_data_manager.h ('k') | chrome/browser/dom_ui/new_tab_ui.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/chrome_url_data_manager.cc
===================================================================
--- chrome/browser/dom_ui/chrome_url_data_manager.cc (revision 5286)
+++ chrome/browser/dom_ui/chrome_url_data_manager.cc (working copy)
@@ -52,6 +52,10 @@
// for us.
void DataAvailable(RefCountedBytes* bytes);
+ void SetMimeType(const std::string& mime_type) {
+ mime_type_ = mime_type;
+ }
+
private:
// Helper for Start(), to let us start asynchronously.
// (This pattern is shared by most URLRequestJob implementations.)
@@ -71,6 +75,7 @@
// we're reading into.
char* pending_buf_;
int pending_buf_size_;
+ std::string mime_type_;
DISALLOW_EVIL_CONSTRUCTORS(URLRequestChromeJob);
};
@@ -187,6 +192,11 @@
RequestID request_id = next_request_id_++;
pending_requests_.insert(std::make_pair(request_id, job));
+ // TODO(eroman): would be nicer if the mimetype were set at the same time
+ // as the data blob. For now do it here, since NotifyHeadersComplete() is
+ // going to get called once we return.
+ job->SetMimeType(source->GetMimeType(path));
+
// Forward along the request to the data source.
source->message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(source, &DataSource::StartDataRequest,
@@ -258,9 +268,8 @@
}
bool URLRequestChromeJob::GetMimeType(std::string* mime_type) {
- // Rely on MIME sniffing to simplify the logic here.
- *mime_type = "text/html";
- return true;
+ *mime_type = mime_type_;
+ return !mime_type_.empty();
}
void URLRequestChromeJob::DataAvailable(RefCountedBytes* bytes) {
« no previous file with comments | « chrome/browser/dom_ui/chrome_url_data_manager.h ('k') | chrome/browser/dom_ui/new_tab_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698