| 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 #include "chrome/browser/download/download_extension_api.h" | 5 #include "chrome/browser/download/download_extension_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cctype> | 8 #include <cctype> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "chrome/browser/icon_loader.h" | 35 #include "chrome/browser/icon_loader.h" |
| 36 #include "chrome/browser/icon_manager.h" | 36 #include "chrome/browser/icon_manager.h" |
| 37 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 37 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 38 #include "chrome/browser/ui/browser_list.h" | 38 #include "chrome/browser/ui/browser_list.h" |
| 39 #include "chrome/browser/ui/webui/web_ui_util.h" | 39 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 40 #include "content/public/browser/download_interrupt_reasons.h" | 40 #include "content/public/browser/download_interrupt_reasons.h" |
| 41 #include "content/public/browser/download_item.h" | 41 #include "content/public/browser/download_item.h" |
| 42 #include "content/public/browser/download_save_info.h" | 42 #include "content/public/browser/download_save_info.h" |
| 43 #include "content/public/browser/render_process_host.h" | 43 #include "content/public/browser/render_process_host.h" |
| 44 #include "content/public/browser/render_view_host.h" | 44 #include "content/public/browser/render_view_host.h" |
| 45 #include "content/public/browser/resource_context.h" |
| 45 #include "content/public/browser/resource_dispatcher_host.h" | 46 #include "content/public/browser/resource_dispatcher_host.h" |
| 46 #include "net/base/load_flags.h" | 47 #include "net/base/load_flags.h" |
| 47 #include "net/http/http_util.h" | 48 #include "net/http/http_util.h" |
| 48 #include "net/url_request/url_request.h" | 49 #include "net/url_request/url_request.h" |
| 49 | 50 |
| 50 using content::BrowserContext; | 51 using content::BrowserContext; |
| 51 using content::BrowserThread; | 52 using content::BrowserThread; |
| 52 using content::DownloadId; | 53 using content::DownloadId; |
| 53 using content::DownloadItem; | 54 using content::DownloadItem; |
| 54 using content::DownloadManager; | 55 using content::DownloadManager; |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 503 |
| 503 void DownloadsDownloadFunction::BeginDownloadOnIOThread() { | 504 void DownloadsDownloadFunction::BeginDownloadOnIOThread() { |
| 504 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 505 DVLOG(1) << __FUNCTION__ << " " << iodata_->url.spec(); | 506 DVLOG(1) << __FUNCTION__ << " " << iodata_->url.spec(); |
| 506 content::DownloadSaveInfo save_info; | 507 content::DownloadSaveInfo save_info; |
| 507 // TODO(benjhayden) Ensure that this filename is interpreted as a path | 508 // TODO(benjhayden) Ensure that this filename is interpreted as a path |
| 508 // relative to the default downloads directory without allowing '..'. | 509 // relative to the default downloads directory without allowing '..'. |
| 509 save_info.suggested_name = iodata_->filename; | 510 save_info.suggested_name = iodata_->filename; |
| 510 save_info.prompt_for_save_location = iodata_->save_as; | 511 save_info.prompt_for_save_location = iodata_->save_as; |
| 511 | 512 |
| 512 scoped_ptr<net::URLRequest> request(new net::URLRequest(iodata_->url, NULL)); | 513 scoped_ptr<net::URLRequest> request(new net::URLRequest( |
| 514 iodata_->url, |
| 515 NULL, |
| 516 iodata_->resource_context->GetRequestContext())); |
| 513 request->set_method(iodata_->method); | 517 request->set_method(iodata_->method); |
| 514 if (iodata_->extra_headers != NULL) { | 518 if (iodata_->extra_headers != NULL) { |
| 515 for (size_t index = 0; index < iodata_->extra_headers->GetSize(); ++index) { | 519 for (size_t index = 0; index < iodata_->extra_headers->GetSize(); ++index) { |
| 516 base::DictionaryValue* header = NULL; | 520 base::DictionaryValue* header = NULL; |
| 517 std::string name, value; | 521 std::string name, value; |
| 518 CHECK(iodata_->extra_headers->GetDictionary(index, &header)); | 522 CHECK(iodata_->extra_headers->GetDictionary(index, &header)); |
| 519 CHECK(header->GetString(kHeaderNameKey, &name)); | 523 CHECK(header->GetString(kHeaderNameKey, &name)); |
| 520 if (header->HasKey(kHeaderBinaryValueKey)) { | 524 if (header->HasKey(kHeaderBinaryValueKey)) { |
| 521 base::ListValue* binary_value = NULL; | 525 base::ListValue* binary_value = NULL; |
| 522 CHECK(header->GetList(kHeaderBinaryValueKey, &binary_value)); | 526 CHECK(header->GetList(kHeaderBinaryValueKey, &binary_value)); |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 ListValue args; | 1117 ListValue args; |
| 1114 args.Append(arg); | 1118 args.Append(arg); |
| 1115 std::string json_args; | 1119 std::string json_args; |
| 1116 base::JSONWriter::Write(&args, &json_args); | 1120 base::JSONWriter::Write(&args, &json_args); |
| 1117 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 1121 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 1118 event_name, | 1122 event_name, |
| 1119 json_args, | 1123 json_args, |
| 1120 profile_, | 1124 profile_, |
| 1121 GURL()); | 1125 GURL()); |
| 1122 } | 1126 } |
| OLD | NEW |