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

Unified Diff: chrome/browser/renderer_host/buffered_resource_handler.cc

Issue 115704: Change URL back to the previous one if the typed URL causes file download.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 7 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
Index: chrome/browser/renderer_host/buffered_resource_handler.cc
===================================================================
--- chrome/browser/renderer_host/buffered_resource_handler.cc (revision 16844)
+++ chrome/browser/renderer_host/buffered_resource_handler.cc (working copy)
@@ -5,10 +5,14 @@
#include "chrome/browser/renderer_host/buffered_resource_handler.h"
#include "base/histogram.h"
+#include "base/message_loop.h"
#include "base/string_util.h"
+#include "base/task.h"
#include "net/base/mime_sniffer.h"
#include "chrome/browser/renderer_host/download_throttling_resource_handler.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/url_constants.h"
#include "net/base/mime_sniffer.h"
#include "net/base/io_buffer.h"
@@ -40,10 +44,14 @@
BufferedResourceHandler::BufferedResourceHandler(ResourceHandler* handler,
ResourceDispatcherHost* host,
- URLRequest* request)
+ URLRequest* request,
+ int render_process_host_id,
+ int render_view_id)
: real_handler_(handler),
host_(host),
request_(request),
+ render_process_host_id_(render_process_host_id),
+ render_view_id_(render_view_id),
bytes_read_(0),
sniff_content_(false),
should_buffer_(false),
@@ -250,6 +258,9 @@
info->is_download = true;
+ host_->ui_loop()->PostTask(FROM_HERE, NewRunnableMethod(
+ this, &BufferedResourceHandler::NotifyDownload));
+
scoped_refptr<DownloadThrottlingResourceHandler> download_handler =
new DownloadThrottlingResourceHandler(host_,
request_,
@@ -282,6 +293,12 @@
return real_handler_->OnResponseStarted(request_id, response_);
}
+void BufferedResourceHandler::NotifyDownload() {
+ TabContents* tab_contents =
+ tab_util::GetTabContentsByID(render_process_host_id_, render_view_id_);
+ tab_contents->MarkAsDownload();
+}
+
bool BufferedResourceHandler::DidBufferEnough(int bytes_read) {
const int kRequiredLength = 256;
« no previous file with comments | « chrome/browser/renderer_host/buffered_resource_handler.h ('k') | chrome/browser/renderer_host/resource_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698