OLD | NEW |
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> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 // If the content-length header is not present (or contains something other | 67 // If the content-length header is not present (or contains something other |
68 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and | 68 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and |
69 // is handled correctly by the SaveManager. | 69 // is handled correctly by the SaveManager. |
70 void set_content_length(const std::string& content_length); | 70 void set_content_length(const std::string& content_length); |
71 | 71 |
72 void set_content_disposition(const std::string& content_disposition) { | 72 void set_content_disposition(const std::string& content_disposition) { |
73 content_disposition_ = content_disposition; | 73 content_disposition_ = content_disposition; |
74 } | 74 } |
75 | 75 |
| 76 // Marks the request as unauthorized. |
| 77 // |
| 78 // This has to be called before the request has started. |
| 79 // This will cause the request to be cancelled from OnWillStart callback. |
| 80 // |
| 81 // This way of handling unauthorized requests allows unified handling of all |
| 82 // SaveFile requests - communicating the failure to OnResponseCompleted |
| 83 // happens in a generic, typical way, reusing common infrastructure code |
| 84 // (rather than forcing an ad-hoc, Save-File-specific call to |
| 85 // OnResponseCompleted from ResourceDispatcherHostImpl::BeginSaveFile). |
| 86 void MarkAsUnauthorized(); |
| 87 |
76 private: | 88 private: |
77 SaveItemId save_item_id_; | 89 SaveItemId save_item_id_; |
78 SavePackageId save_package_id_; | 90 SavePackageId save_package_id_; |
79 int render_process_id_; | 91 int render_process_id_; |
80 int render_frame_routing_id_; | 92 int render_frame_routing_id_; |
81 scoped_refptr<net::IOBuffer> read_buffer_; | 93 scoped_refptr<net::IOBuffer> read_buffer_; |
82 std::string content_disposition_; | 94 std::string content_disposition_; |
83 GURL url_; | 95 GURL url_; |
84 GURL final_url_; | 96 GURL final_url_; |
85 int64_t content_length_; | 97 int64_t content_length_; |
86 SaveFileManager* save_manager_; | 98 SaveFileManager* save_manager_; |
87 | 99 |
| 100 bool is_authorized_; |
| 101 |
88 static const int kReadBufSize = 32768; // bytes | 102 static const int kReadBufSize = 32768; // bytes |
89 | 103 |
90 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); | 104 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); |
91 }; | 105 }; |
92 | 106 |
93 } // namespace content | 107 } // namespace content |
94 | 108 |
95 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ | 109 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ |
OLD | NEW |