| 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 29 matching lines...) Expand all Loading... |
| 40 #include "chrome/browser/extensions/extension_prefs.h" | 40 #include "chrome/browser/extensions/extension_prefs.h" |
| 41 #include "chrome/browser/extensions/extension_service.h" | 41 #include "chrome/browser/extensions/extension_service.h" |
| 42 #include "chrome/browser/extensions/extension_system.h" | 42 #include "chrome/browser/extensions/extension_system.h" |
| 43 #include "chrome/browser/icon_loader.h" | 43 #include "chrome/browser/icon_loader.h" |
| 44 #include "chrome/browser/icon_manager.h" | 44 #include "chrome/browser/icon_manager.h" |
| 45 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 45 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 46 #include "chrome/browser/ui/browser.h" | 46 #include "chrome/browser/ui/browser.h" |
| 47 #include "chrome/common/cancelable_task_tracker.h" | 47 #include "chrome/common/cancelable_task_tracker.h" |
| 48 #include "chrome/common/chrome_notification_types.h" | 48 #include "chrome/common/chrome_notification_types.h" |
| 49 #include "chrome/common/extensions/api/downloads.h" | 49 #include "chrome/common/extensions/api/downloads.h" |
| 50 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 50 #include "content/public/browser/download_interrupt_reasons.h" | 51 #include "content/public/browser/download_interrupt_reasons.h" |
| 51 #include "content/public/browser/download_item.h" | 52 #include "content/public/browser/download_item.h" |
| 52 #include "content/public/browser/download_save_info.h" | 53 #include "content/public/browser/download_save_info.h" |
| 53 #include "content/public/browser/download_url_parameters.h" | 54 #include "content/public/browser/download_url_parameters.h" |
| 54 #include "content/public/browser/notification_service.h" | 55 #include "content/public/browser/notification_service.h" |
| 55 #include "content/public/browser/render_process_host.h" | 56 #include "content/public/browser/render_process_host.h" |
| 56 #include "content/public/browser/render_view_host.h" | 57 #include "content/public/browser/render_view_host.h" |
| 57 #include "content/public/browser/resource_context.h" | 58 #include "content/public/browser/resource_context.h" |
| 58 #include "content/public/browser/resource_dispatcher_host.h" | 59 #include "content/public/browser/resource_dispatcher_host.h" |
| 59 #include "content/public/browser/web_contents.h" | 60 #include "content/public/browser/web_contents.h" |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 | 800 |
| 800 bool DownloadsDownloadFunction::RunImpl() { | 801 bool DownloadsDownloadFunction::RunImpl() { |
| 801 scoped_ptr<extensions::api::downloads::Download::Params> params( | 802 scoped_ptr<extensions::api::downloads::Download::Params> params( |
| 802 extensions::api::downloads::Download::Params::Create(*args_)); | 803 extensions::api::downloads::Download::Params::Create(*args_)); |
| 803 EXTENSION_FUNCTION_VALIDATE(params.get()); | 804 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 804 const extensions::api::downloads::DownloadOptions& options = params->options; | 805 const extensions::api::downloads::DownloadOptions& options = params->options; |
| 805 GURL download_url(options.url); | 806 GURL download_url(options.url); |
| 806 if (!download_url.is_valid() || | 807 if (!download_url.is_valid() || |
| 807 (!download_url.SchemeIs("data") && | 808 (!download_url.SchemeIs("data") && |
| 808 download_url.GetOrigin() != GetExtension()->url().GetOrigin() && | 809 download_url.GetOrigin() != GetExtension()->url().GetOrigin() && |
| 809 !GetExtension()->HasHostPermission(download_url))) { | 810 !extensions::PermissionsData::HasHostPermission(GetExtension(), |
| 811 download_url))) { |
| 810 error_ = download_extension_errors::kInvalidURLError; | 812 error_ = download_extension_errors::kInvalidURLError; |
| 811 return false; | 813 return false; |
| 812 } | 814 } |
| 813 | 815 |
| 814 Profile* current_profile = profile(); | 816 Profile* current_profile = profile(); |
| 815 if (include_incognito() && profile()->HasOffTheRecordProfile()) | 817 if (include_incognito() && profile()->HasOffTheRecordProfile()) |
| 816 current_profile = profile()->GetOffTheRecordProfile(); | 818 current_profile = profile()->GetOffTheRecordProfile(); |
| 817 | 819 |
| 818 scoped_ptr<content::DownloadUrlParameters> download_params( | 820 scoped_ptr<content::DownloadUrlParameters> download_params( |
| 819 new content::DownloadUrlParameters( | 821 new content::DownloadUrlParameters( |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 DownloadsNotificationSource notification_source; | 1498 DownloadsNotificationSource notification_source; |
| 1497 notification_source.event_name = event_name; | 1499 notification_source.event_name = event_name; |
| 1498 notification_source.profile = profile_; | 1500 notification_source.profile = profile_; |
| 1499 content::Source<DownloadsNotificationSource> content_source( | 1501 content::Source<DownloadsNotificationSource> content_source( |
| 1500 ¬ification_source); | 1502 ¬ification_source); |
| 1501 content::NotificationService::current()->Notify( | 1503 content::NotificationService::current()->Notify( |
| 1502 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, | 1504 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, |
| 1503 content_source, | 1505 content_source, |
| 1504 content::Details<std::string>(&json_args)); | 1506 content::Details<std::string>(&json_args)); |
| 1505 } | 1507 } |
| OLD | NEW |