Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/api/downloads_internal/downloads_internal_ap i.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 #include <cctype> | |
| 9 #include <iterator> | |
| 10 #include <set> | |
| 11 #include <string> | |
| 12 | |
| 13 #include "base/basictypes.h" | |
| 14 #include "base/bind.h" | |
| 15 #include "base/bind_helpers.h" | |
| 16 #include "base/callback.h" | |
| 17 #include "base/json/json_writer.h" | |
| 18 #include "base/lazy_instance.h" | |
| 19 #include "base/logging.h" | |
| 20 #include "base/metrics/histogram.h" | |
| 21 #include "base/stl_util.h" | |
| 22 #include "base/string16.h" | |
| 23 #include "base/string_split.h" | |
| 24 #include "base/string_util.h" | |
| 25 #include "base/stringprintf.h" | |
| 26 #include "base/values.h" | |
| 27 #include "chrome/browser/browser_process.h" | |
| 28 #include "chrome/browser/download/download_file_icon_extractor.h" | |
| 29 #include "chrome/browser/download/download_query.h" | |
| 30 #include "chrome/browser/download/download_service.h" | |
| 31 #include "chrome/browser/download/download_service_factory.h" | |
| 32 #include "chrome/browser/download/download_util.h" | |
| 33 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | |
| 34 #include "chrome/browser/extensions/event_names.h" | |
| 35 #include "chrome/browser/extensions/event_router.h" | |
| 36 #include "chrome/browser/extensions/extension_function_dispatcher.h" | |
| 37 #include "chrome/browser/extensions/extension_system.h" | |
| 38 #include "chrome/browser/icon_loader.h" | |
| 39 #include "chrome/browser/icon_manager.h" | |
| 40 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | |
| 41 #include "chrome/browser/ui/browser.h" | |
| 42 #include "chrome/browser/ui/webui/web_ui_util.h" | |
| 43 #include "chrome/common/cancelable_task_tracker.h" | |
| 44 #include "chrome/common/chrome_notification_types.h" | |
| 45 #include "chrome/common/extensions/api/downloads_internal.h" | |
| 46 #include "content/public/browser/download_interrupt_reasons.h" | |
| 47 #include "content/public/browser/download_item.h" | |
| 48 #include "content/public/browser/download_save_info.h" | |
| 49 #include "content/public/browser/download_url_parameters.h" | |
| 50 #include "content/public/browser/notification_service.h" | |
| 51 #include "content/public/browser/render_process_host.h" | |
| 52 #include "content/public/browser/render_view_host.h" | |
| 53 #include "content/public/browser/resource_context.h" | |
| 54 #include "content/public/browser/resource_dispatcher_host.h" | |
| 55 #include "content/public/browser/web_contents.h" | |
| 56 #include "net/base/load_flags.h" | |
| 57 #include "net/http/http_util.h" | |
| 58 | |
| 59 using content::DownloadItem; | |
| 60 using content::DownloadManager; | |
| 61 | |
| 62 DownloadsInternalAddFilenameDeterminerFunction:: | |
| 63 DownloadsInternalAddFilenameDeterminerFunction() {} | |
| 64 DownloadsInternalAddFilenameDeterminerFunction:: | |
| 65 ~DownloadsInternalAddFilenameDeterminerFunction() {} | |
| 66 | |
| 67 typedef extensions::api::downloads_internal::AddFilenameDeterminer::Params | |
| 68 AddFilenameDeterminerParams; | |
| 69 | |
| 70 bool DownloadsInternalAddFilenameDeterminerFunction::RunImpl() { | |
| 71 scoped_ptr<AddFilenameDeterminerParams> params( | |
| 72 AddFilenameDeterminerParams::Create(*args_)); | |
| 73 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
| 74 return ExtensionDownloadsEventRouter::AddFilenameDeterminer( | |
| 75 profile(), | |
| 76 include_incognito(), | |
| 77 GetExtension()->id(), | |
| 78 params->determiner_id); | |
| 79 } | |
| 80 | |
| 81 DownloadsInternalRemoveFilenameDeterminerFunction:: | |
| 82 DownloadsInternalRemoveFilenameDeterminerFunction() {} | |
| 83 DownloadsInternalRemoveFilenameDeterminerFunction:: | |
| 84 ~DownloadsInternalRemoveFilenameDeterminerFunction() {} | |
| 85 | |
| 86 typedef extensions::api::downloads_internal::RemoveFilenameDeterminer::Params | |
| 87 RemoveFilenameDeterminerParams; | |
| 88 | |
| 89 bool DownloadsInternalRemoveFilenameDeterminerFunction::RunImpl() { | |
| 90 scoped_ptr<RemoveFilenameDeterminerParams> params( | |
| 91 RemoveFilenameDeterminerParams::Create(*args_)); | |
| 92 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
| 93 return ExtensionDownloadsEventRouter::RemoveFilenameDeterminer( | |
| 94 profile(), | |
| 95 include_incognito(), | |
| 96 GetExtension()->id(), | |
| 97 params->determiner_id); | |
| 98 } | |
| 99 | |
| 100 DownloadsInternalDetermineFilenameFunction:: | |
| 101 DownloadsInternalDetermineFilenameFunction() {} | |
| 102 DownloadsInternalDetermineFilenameFunction:: | |
|
vabr (Chromium)
2013/01/11 12:43:40
nit: Insert a blank line before the c-tor and d-to
benjhayden
2013/01/11 21:21:27
Done.
| |
| 103 ~DownloadsInternalDetermineFilenameFunction() {} | |
| 104 | |
| 105 typedef extensions::api::downloads_internal::DetermineFilename::Params | |
| 106 DetermineFilenameParams; | |
|
battre
2013/01/11 14:29:37
nit: whitespaces
benjhayden
2013/01/11 21:21:27
Done.
| |
| 107 | |
| 108 bool DownloadsInternalDetermineFilenameFunction::RunImpl() { | |
| 109 scoped_ptr<DetermineFilenameParams> params( | |
| 110 DetermineFilenameParams::Create(*args_)); | |
| 111 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
| 112 FilePath::StringType filename; | |
| 113 if (params->filename.get()) { | |
| 114 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &filename)); | |
| 115 } | |
| 116 return ExtensionDownloadsEventRouter::DetermineFilename( | |
|
battre
2013/01/11 14:29:37
Why is this called "DetermineFilename" instead of
benjhayden
2013/01/11 21:21:27
Actually, there's still most of the filename deter
| |
| 117 profile(), | |
| 118 include_incognito(), | |
| 119 GetExtension()->id(), | |
| 120 params->determiner_id, | |
| 121 params->download_id, | |
| 122 FilePath(filename), | |
| 123 params->overwrite); | |
| 124 } | |
| OLD | NEW |