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

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 263453007: Implement "Save image as" for canvas (chromium side). (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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 #include "content/browser/download/download_manager_impl.h" 5 #include "content/browser/download/download_manager_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 void BeginDownload(scoped_ptr<DownloadUrlParameters> params, 51 void BeginDownload(scoped_ptr<DownloadUrlParameters> params,
52 uint32 download_id) { 52 uint32 download_id) {
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
54 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and 54 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and
55 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so 55 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so
56 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. 56 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4.
57 scoped_ptr<net::URLRequest> request( 57 scoped_ptr<net::URLRequest> request(
58 params->resource_context()->GetRequestContext()->CreateRequest( 58 params->resource_context()->GetRequestContext()->CreateRequest(
59 params->url(), net::DEFAULT_PRIORITY, NULL, NULL)); 59 params->url(), net::DEFAULT_PRIORITY, NULL, NULL));
60 request->SetLoadFlags(request->load_flags() | params->load_flags()); 60 //request->SetLoadFlags(request->load_flags() | params->load_flags());
Justin Novosad 2014/04/30 15:07:16 Why was this commented out?
61 request->set_method(params->method()); 61 request->set_method(params->method());
62 if (!params->post_body().empty()) { 62 if (!params->post_body().empty()) {
63 const std::string& body = params->post_body(); 63 const std::string& body = params->post_body();
64 scoped_ptr<net::UploadElementReader> reader( 64 scoped_ptr<net::UploadElementReader> reader(
65 net::UploadOwnedBytesElementReader::CreateWithString(body)); 65 net::UploadOwnedBytesElementReader::CreateWithString(body));
66 request->set_upload(make_scoped_ptr( 66 request->set_upload(make_scoped_ptr(
67 net::UploadDataStream::CreateWithReader(reader.Pass(), 0))); 67 net::UploadDataStream::CreateWithReader(reader.Pass(), 0)));
68 } 68 }
69 if (params->post_id() >= 0) { 69 if (params->post_id() >= 0) {
70 // The POST in this case does not have an actual body, and only works 70 // The POST in this case does not have an actual body, and only works
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 for (DownloadUrlParameters::RequestHeadersType::const_iterator iter 107 for (DownloadUrlParameters::RequestHeadersType::const_iterator iter
108 = params->request_headers_begin(); 108 = params->request_headers_begin();
109 iter != params->request_headers_end(); 109 iter != params->request_headers_end();
110 ++iter) { 110 ++iter) {
111 request->SetExtraRequestHeaderByName( 111 request->SetExtraRequestHeaderByName(
112 iter->first, iter->second, false /*overwrite*/); 112 iter->first, iter->second, false /*overwrite*/);
113 } 113 }
114 114
115 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); 115 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo());
116 save_info->file_path = params->file_path(); 116 save_info->file_path = params->file_path();
117 save_info->suggested_name = params->suggested_name(); 117 save_info->prompt_for_save_location = params->prompt();
118
119 /* save_info->suggested_name = params->suggested_name();
118 save_info->offset = params->offset(); 120 save_info->offset = params->offset();
119 save_info->hash_state = params->hash_state(); 121 save_info->hash_state = params->hash_state();
120 save_info->prompt_for_save_location = params->prompt(); 122 save_info->prompt_for_save_location = params->prompt();
121 save_info->file = params->GetFile(); 123 save_info->file = params->GetFile();*/
Avi (use Gerrit) 2014/04/30 14:52:28 ? We don't commit commented-out code.
122 124
123 ResourceDispatcherHost::Get()->BeginDownload( 125 ResourceDispatcherHost::Get()->BeginDownload(
124 request.Pass(), 126 request.Pass(),
125 params->referrer(), 127 params->referrer(),
126 params->content_initiated(), 128 params->content_initiated(),
127 params->resource_context(), 129 params->resource_context(),
128 params->render_process_host_id(), 130 params->render_process_host_id(),
129 params->render_view_host_routing_id(), 131 params->render_view_host_routing_id(),
130 params->prefer_cache(), 132 params->prefer_cache(),
131 save_info.Pass(), 133 save_info.Pass(),
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 if (delegate_) 710 if (delegate_)
709 delegate_->OpenDownload(download); 711 delegate_->OpenDownload(download);
710 } 712 }
711 713
712 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 714 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
713 if (delegate_) 715 if (delegate_)
714 delegate_->ShowDownloadInShell(download); 716 delegate_->ShowDownloadInShell(download);
715 } 717 }
716 718
717 } // namespace content 719 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698