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

Side by Side Diff: content/browser/download/save_file_resource_handler.h

Issue 2187353004: Resource requests from Save-Page-As should go through CanRequestURL checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "content/browser/download/save_types.h" 14 #include "content/browser/download/save_types.h"
15 #include "content/browser/loader/resource_handler.h" 15 #include "content/browser/loader/resource_handler.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace net { 18 namespace net {
19 class URLRequest; 19 class URLRequest;
20 } 20 }
21 21
22 namespace content { 22 namespace content {
23 class SaveFileManager; 23 class SaveFileManager;
24 24
25 // Forwards data to the save thread. 25 // Forwards data to the save thread.
26 class SaveFileResourceHandler : public ResourceHandler { 26 class SaveFileResourceHandler : public ResourceHandler {
27 public: 27 public:
28 // Unauthorized requests are cancelled from OnWillStart callback.
29 //
30 // This way of handling unauthorized requests allows unified handling of all
31 // SaveFile requests - communicating the failure to OnResponseCompleted
32 // happens in a generic, typical way, reusing common infrastructure code
33 // (rather than forcing an ad-hoc, Save-File-specific call to
34 // OnResponseCompleted from ResourceDispatcherHostImpl::BeginSaveFile).
35 enum class AuthorizationState {
36 AUTHORIZED,
37 NOT_AUTHORIZED,
38 };
39
28 SaveFileResourceHandler(net::URLRequest* request, 40 SaveFileResourceHandler(net::URLRequest* request,
29 SaveItemId save_item_id, 41 SaveItemId save_item_id,
30 SavePackageId save_package_id, 42 SavePackageId save_package_id,
31 int render_process_host_id, 43 int render_process_host_id,
32 int render_frame_routing_id, 44 int render_frame_routing_id,
33 const GURL& url, 45 const GURL& url,
34 SaveFileManager* manager); 46 SaveFileManager* manager,
47 AuthorizationState authorization_state);
35 ~SaveFileResourceHandler() override; 48 ~SaveFileResourceHandler() override;
36 49
37 // ResourceHandler Implementation: 50 // ResourceHandler Implementation:
38 51
39 // Saves the redirected URL to final_url_, we need to use the original 52 // Saves the redirected URL to final_url_, we need to use the original
40 // URL to match original request. 53 // URL to match original request.
41 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, 54 bool OnRequestRedirected(const net::RedirectInfo& redirect_info,
42 ResourceResponse* response, 55 ResourceResponse* response,
43 bool* defer) override; 56 bool* defer) override;
44 57
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 SavePackageId save_package_id_; 94 SavePackageId save_package_id_;
82 int render_process_id_; 95 int render_process_id_;
83 int render_frame_routing_id_; 96 int render_frame_routing_id_;
84 scoped_refptr<net::IOBuffer> read_buffer_; 97 scoped_refptr<net::IOBuffer> read_buffer_;
85 std::string content_disposition_; 98 std::string content_disposition_;
86 GURL url_; 99 GURL url_;
87 GURL final_url_; 100 GURL final_url_;
88 int64_t content_length_; 101 int64_t content_length_;
89 SaveFileManager* save_manager_; 102 SaveFileManager* save_manager_;
90 103
104 AuthorizationState authorization_state_;
105
91 static const int kReadBufSize = 32768; // bytes 106 static const int kReadBufSize = 32768; // bytes
92 107
93 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); 108 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler);
94 }; 109 };
95 110
96 } // namespace content 111 } // namespace content
97 112
98 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ 113 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/download/save_file_manager.cc ('k') | content/browser/download/save_file_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698