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

Unified Diff: content/browser/download/save_file_resource_handler.h

Issue 2075273002: Resource requests from Save-Page-As should go through CanRequestURL checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments + added DCHECK(!is_pending) to MarkAsUnauthorized. Created 4 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
Index: content/browser/download/save_file_resource_handler.h
diff --git a/content/browser/download/save_file_resource_handler.h b/content/browser/download/save_file_resource_handler.h
index 2ab8b2f7f5f54a46b0f2861a44409eca806f12e0..4994dcf6e182c6286c933ff2858c262e4d7acd22 100644
--- a/content/browser/download/save_file_resource_handler.h
+++ b/content/browser/download/save_file_resource_handler.h
@@ -73,6 +73,18 @@ class SaveFileResourceHandler : public ResourceHandler {
content_disposition_ = content_disposition;
}
+ // Marks the request as unauthorized.
+ //
+ // This has to be called before the request has started.
+ // This will cause the request to be cancelled from OnWillStart callback.
+ //
+ // This way of handling unauthorized requests allows unified handling of all
+ // SaveFile requests - communicating the failure to OnResponseCompleted
+ // happens in a generic, typical way, reusing common infrastructure code
+ // (rather than forcing an ad-hoc, Save-File-specific call to
+ // OnResponseCompleted from ResourceDispatcherHostImpl::BeginSaveFile).
+ void MarkAsUnauthorized();
+
private:
SaveItemId save_item_id_;
SavePackageId save_package_id_;
@@ -85,6 +97,8 @@ class SaveFileResourceHandler : public ResourceHandler {
int64_t content_length_;
SaveFileManager* save_manager_;
+ bool is_authorized_;
+
static const int kReadBufSize = 32768; // bytes
DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler);

Powered by Google App Engine
This is Rietveld 408576698