diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-14 20:18:09 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-14 20:18:09 +0000 |
commit | 6fe0bad0e5215b8837e0673e60afc4b7c73cac21 (patch) | |
tree | 9470d12a86d408e6e6c72631e054616a4531a6d2 /chrome/browser/dom_ui | |
parent | ab8fa0c51059c27a8bd4200899a3688e50a1393c (diff) | |
download | chromium_src-6fe0bad0e5215b8837e0673e60afc4b7c73cac21.zip chromium_src-6fe0bad0e5215b8837e0673e60afc4b7c73cac21.tar.gz chromium_src-6fe0bad0e5215b8837e0673e60afc4b7c73cac21.tar.bz2 |
Add mimetypes on the "chrome-resource://" responses.
This is necessary to get javascript debugger loading CSS, post-webkit-merge.
http://code.google.com/p/chromium/issues/detail?id=4181
Review URL: http://codereview.chromium.org/10941
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5502 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r-- | chrome/browser/dom_ui/chrome_url_data_manager.cc | 15 | ||||
-rw-r--r-- | chrome/browser/dom_ui/chrome_url_data_manager.h | 4 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.h | 18 |
3 files changed, 34 insertions, 3 deletions
diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.cc b/chrome/browser/dom_ui/chrome_url_data_manager.cc index 4eb7b9f..1102b87 100644 --- a/chrome/browser/dom_ui/chrome_url_data_manager.cc +++ b/chrome/browser/dom_ui/chrome_url_data_manager.cc @@ -52,6 +52,10 @@ class URLRequestChromeJob : public URLRequestJob { // 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 @@ class URLRequestChromeJob : public URLRequestJob { // we're reading into. char* pending_buf_; int pending_buf_size_; + std::string mime_type_; DISALLOW_EVIL_CONSTRUCTORS(URLRequestChromeJob); }; @@ -187,6 +192,11 @@ bool ChromeURLDataManager::StartRequest(const GURL& url, 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 @@ void URLRequestChromeJob::Kill() { } 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) { diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.h b/chrome/browser/dom_ui/chrome_url_data_manager.h index a7f07f2..895ff46 100644 --- a/chrome/browser/dom_ui/chrome_url_data_manager.h +++ b/chrome/browser/dom_ui/chrome_url_data_manager.h @@ -48,6 +48,10 @@ class ChromeURLDataManager { // not be satisfied. virtual void StartDataRequest(const std::string& path, int request_id) = 0; + // Return the mimetype that should be sent with this response, or empty + // string to specify no mime type. + virtual std::string GetMimeType(const std::string& path) const = 0; + // Report that a request has resulted in the data |bytes|. // If the request can't be satisfied, pass NULL for |bytes| to indicate // the request is over. diff --git a/chrome/browser/dom_ui/new_tab_ui.h b/chrome/browser/dom_ui/new_tab_ui.h index aab91f2..ed31cde 100644 --- a/chrome/browser/dom_ui/new_tab_ui.h +++ b/chrome/browser/dom_ui/new_tab_ui.h @@ -36,6 +36,10 @@ class NewTabHTMLSource : public ChromeURLDataManager::DataSource { // the path we registered. virtual void StartDataRequest(const std::string& path, int request_id); + virtual std::string GetMimeType(const std::string&) const { + return "text/html"; + } + // Setters and getters for first_view. static void set_first_view(bool first_view) { first_view_ = first_view; } static bool first_view() { return first_view_; } @@ -57,6 +61,10 @@ class IncognitoTabHTMLSource : public ChromeURLDataManager::DataSource { // the path we registered. virtual void StartDataRequest(const std::string& path, int request_id); + virtual std::string GetMimeType(const std::string&) const { + return "text/html"; + } + private: DISALLOW_EVIL_CONSTRUCTORS(IncognitoTabHTMLSource); }; @@ -71,6 +79,11 @@ class ThumbnailSource : public ChromeURLDataManager::DataSource { // the path we registered. virtual void StartDataRequest(const std::string& path, int request_id); + virtual std::string GetMimeType(const std::string&) const { + // Rely on image decoder inferring the correct type. + return std::string(); + } + // Called when thumbnail data is available from the history backend. void OnThumbnailDataAvailable( HistoryService::Handle request_handle, @@ -97,6 +110,11 @@ class FavIconSource : public ChromeURLDataManager::DataSource { // the path we registered. virtual void StartDataRequest(const std::string& path, int request_id); + virtual std::string GetMimeType(const std::string&) const { + // Rely on image decoder inferring the correct type. + return std::string(); + } + // Called when favicon data is available from the history backend. void OnFavIconDataAvailable( HistoryService::Handle request_handle, |