| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/extensions/extension_event_names.h" | 27 #include "chrome/browser/extensions/extension_event_names.h" |
| 28 #include "chrome/browser/extensions/extension_event_router.h" | 28 #include "chrome/browser/extensions/extension_event_router.h" |
| 29 #include "chrome/browser/icon_loader.h" | 29 #include "chrome/browser/icon_loader.h" |
| 30 #include "chrome/browser/icon_manager.h" | 30 #include "chrome/browser/icon_manager.h" |
| 31 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 31 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 32 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
| 33 #include "content/browser/download/download_file_manager.h" | 33 #include "content/browser/download/download_file_manager.h" |
| 34 #include "content/browser/download/download_item.h" | 34 #include "content/browser/download/download_item.h" |
| 35 #include "content/browser/download/download_types.h" | 35 #include "content/browser/download/download_types.h" |
| 36 #include "content/browser/download/interrupt_reasons.h" | 36 #include "content/browser/download/interrupt_reasons.h" |
| 37 #include "content/browser/renderer_host/render_process_host.h" | |
| 38 #include "content/browser/renderer_host/render_view_host.h" | 37 #include "content/browser/renderer_host/render_view_host.h" |
| 39 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 38 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 39 #include "content/public/browser/render_process_host.h" |
| 40 #include "net/http/http_util.h" | 40 #include "net/http/http_util.h" |
| 41 #include "net/url_request/url_request.h" | 41 #include "net/url_request/url_request.h" |
| 42 | 42 |
| 43 using content::BrowserThread; | 43 using content::BrowserThread; |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 // Error messages | 47 // Error messages |
| 48 const char kNotImplemented[] = "NotImplemented"; | 48 const char kNotImplemented[] = "NotImplemented"; |
| 49 const char kGenericError[] = "I'm afraid I can't do that."; | 49 const char kGenericError[] = "I'm afraid I can't do that."; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 EXTENSION_FUNCTION_VALIDATE(header->GetString( | 209 EXTENSION_FUNCTION_VALIDATE(header->GetString( |
| 210 kHeaderValueKey, &value)); | 210 kHeaderValueKey, &value)); |
| 211 if (!net::HttpUtil::IsSafeHeader(name)) { | 211 if (!net::HttpUtil::IsSafeHeader(name)) { |
| 212 error_ = kGenericError; | 212 error_ = kGenericError; |
| 213 return false; | 213 return false; |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 iodata_->rdh = g_browser_process->resource_dispatcher_host(); | 217 iodata_->rdh = g_browser_process->resource_dispatcher_host(); |
| 218 iodata_->resource_context = &profile()->GetResourceContext(); | 218 iodata_->resource_context = &profile()->GetResourceContext(); |
| 219 iodata_->render_process_host_id = render_view_host()->process()->id(); | 219 iodata_->render_process_host_id = render_view_host()->process()->GetID(); |
| 220 iodata_->render_view_host_routing_id = render_view_host()->routing_id(); | 220 iodata_->render_view_host_routing_id = render_view_host()->routing_id(); |
| 221 return true; | 221 return true; |
| 222 } | 222 } |
| 223 | 223 |
| 224 void DownloadsDownloadFunction::RunInternal() { | 224 void DownloadsDownloadFunction::RunInternal() { |
| 225 VLOG(1) << __FUNCTION__ << " " << iodata_->url.spec(); | 225 VLOG(1) << __FUNCTION__ << " " << iodata_->url.spec(); |
| 226 if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | 226 if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( |
| 227 &DownloadsDownloadFunction::BeginDownloadOnIOThread, this))) { | 227 &DownloadsDownloadFunction::BeginDownloadOnIOThread, this))) { |
| 228 error_ = kGenericError; | 228 error_ = kGenericError; |
| 229 SendResponse(error_.empty()); | 229 SendResponse(error_.empty()); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 ListValue args; | 542 ListValue args; |
| 543 args.Append(arg); | 543 args.Append(arg); |
| 544 std::string json_args; | 544 std::string json_args; |
| 545 base::JSONWriter::Write(&args, false, &json_args); | 545 base::JSONWriter::Write(&args, false, &json_args); |
| 546 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 546 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 547 event_name, | 547 event_name, |
| 548 json_args, | 548 json_args, |
| 549 profile_, | 549 profile_, |
| 550 GURL()); | 550 GURL()); |
| 551 } | 551 } |
| OLD | NEW |