| 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/extensions/api/downloads/downloads_api.h" | 5 #include "chrome/browser/extensions/api/downloads/downloads_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.h" | 38 #include "chrome/browser/ui/browser.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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 488 |
| 488 void DownloadsDownloadFunction::BeginDownloadOnIOThread() { | 489 void DownloadsDownloadFunction::BeginDownloadOnIOThread() { |
| 489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 490 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 490 DVLOG(1) << __FUNCTION__ << " " << iodata_->url.spec(); | 491 DVLOG(1) << __FUNCTION__ << " " << iodata_->url.spec(); |
| 491 content::DownloadSaveInfo save_info; | 492 content::DownloadSaveInfo save_info; |
| 492 // TODO(benjhayden) Ensure that this filename is interpreted as a path | 493 // TODO(benjhayden) Ensure that this filename is interpreted as a path |
| 493 // relative to the default downloads directory without allowing '..'. | 494 // relative to the default downloads directory without allowing '..'. |
| 494 save_info.suggested_name = iodata_->filename; | 495 save_info.suggested_name = iodata_->filename; |
| 495 save_info.prompt_for_save_location = iodata_->save_as; | 496 save_info.prompt_for_save_location = iodata_->save_as; |
| 496 | 497 |
| 497 scoped_ptr<net::URLRequest> request(new net::URLRequest(iodata_->url, NULL)); | 498 scoped_ptr<net::URLRequest> request(new net::URLRequest( |
| 499 iodata_->url, |
| 500 NULL, |
| 501 iodata_->resource_context->GetRequestContext())); |
| 498 request->set_method(iodata_->method); | 502 request->set_method(iodata_->method); |
| 499 if (iodata_->extra_headers != NULL) { | 503 if (iodata_->extra_headers != NULL) { |
| 500 for (size_t index = 0; index < iodata_->extra_headers->GetSize(); ++index) { | 504 for (size_t index = 0; index < iodata_->extra_headers->GetSize(); ++index) { |
| 501 base::DictionaryValue* header = NULL; | 505 base::DictionaryValue* header = NULL; |
| 502 std::string name, value; | 506 std::string name, value; |
| 503 CHECK(iodata_->extra_headers->GetDictionary(index, &header)); | 507 CHECK(iodata_->extra_headers->GetDictionary(index, &header)); |
| 504 CHECK(header->GetString(kHeaderNameKey, &name)); | 508 CHECK(header->GetString(kHeaderNameKey, &name)); |
| 505 CHECK(header->GetString(kHeaderValueKey, &value)); | 509 CHECK(header->GetString(kHeaderValueKey, &value)); |
| 506 request->SetExtraRequestHeaderByName(name, value, false/*overwrite*/); | 510 request->SetExtraRequestHeaderByName(name, value, false/*overwrite*/); |
| 507 } | 511 } |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 base::ListValue args; | 1096 base::ListValue args; |
| 1093 args.Append(arg); | 1097 args.Append(arg); |
| 1094 std::string json_args; | 1098 std::string json_args; |
| 1095 base::JSONWriter::Write(&args, &json_args); | 1099 base::JSONWriter::Write(&args, &json_args); |
| 1096 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 1100 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 1097 event_name, | 1101 event_name, |
| 1098 json_args, | 1102 json_args, |
| 1099 profile_, | 1103 profile_, |
| 1100 GURL()); | 1104 GURL()); |
| 1101 } | 1105 } |
| OLD | NEW |