Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/download/download_extension_api.cc

Issue 8468020: Propagate the SafeBrowsing download protection verdict to the DownloadItem. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Merge Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 14 matching lines...) Expand all
25 #include "chrome/browser/download/download_service_factory.h" 25 #include "chrome/browser/download/download_service_factory.h"
26 #include "chrome/browser/download/download_util.h" 26 #include "chrome/browser/download/download_util.h"
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_state_info.h"
35 #include "content/browser/download/download_types.h" 36 #include "content/browser/download/download_types.h"
36 #include "content/browser/download/interrupt_reasons.h" 37 #include "content/browser/download/interrupt_reasons.h"
37 #include "content/browser/renderer_host/render_process_host.h" 38 #include "content/browser/renderer_host/render_process_host.h"
38 #include "content/browser/renderer_host/render_view_host.h" 39 #include "content/browser/renderer_host/render_view_host.h"
39 #include "content/browser/renderer_host/resource_dispatcher_host.h" 40 #include "content/browser/renderer_host/resource_dispatcher_host.h"
40 #include "net/http/http_util.h" 41 #include "net/http/http_util.h"
41 #include "net/url_request/url_request.h" 42 #include "net/url_request/url_request.h"
42 43
43 using content::BrowserThread; 44 using content::BrowserThread;
44 45
45 namespace { 46 namespace {
46 47
47 // Error messages 48 // Error messages
48 const char kNotImplemented[] = "NotImplemented"; 49 const char kNotImplemented[] = "NotImplemented";
49 const char kGenericError[] = "I'm afraid I can't do that."; 50 const char kGenericError[] = "I'm afraid I can't do that.";
50 const char kInvalidURL[] = "Invalid URL"; 51 const char kInvalidURL[] = "Invalid URL";
51 52
52 // Parameter keys 53 // Parameter keys
53 const char kBodyKey[] = "body"; 54 const char kBodyKey[] = "body";
54 const char kBytesReceivedKey[] = "bytesReceived"; 55 const char kBytesReceivedKey[] = "bytesReceived";
55 const char kDangerAcceptedKey[] = "dangerAccepted"; 56 const char kDangerAcceptedKey[] = "dangerAccepted";
57 const char kDangerContent[] = "content";
56 const char kDangerFile[] = "file"; 58 const char kDangerFile[] = "file";
57 const char kDangerKey[] = "danger"; 59 const char kDangerKey[] = "danger";
58 const char kDangerSafe[] = "safe"; 60 const char kDangerSafe[] = "safe";
59 const char kDangerUrl[] = "url"; 61 const char kDangerUrl[] = "url";
60 const char kEndTimeKey[] = "endTime"; 62 const char kEndTimeKey[] = "endTime";
61 const char kErrorKey[] = "error"; 63 const char kErrorKey[] = "error";
62 const char kFileSizeKey[] = "fileSize"; 64 const char kFileSizeKey[] = "fileSize";
63 const char kFilenameKey[] = "filename"; 65 const char kFilenameKey[] = "filename";
64 const char kHeaderNameKey[] = "name"; 66 const char kHeaderNameKey[] = "name";
65 const char kHeaderValueKey[] = "value"; 67 const char kHeaderValueKey[] = "value";
66 const char kHeadersKey[] = "headers"; 68 const char kHeadersKey[] = "headers";
67 const char kIdKey[] = "id"; 69 const char kIdKey[] = "id";
68 const char kMethodKey[] = "method"; 70 const char kMethodKey[] = "method";
69 const char kMimeKey[] = "mime"; 71 const char kMimeKey[] = "mime";
70 const char kPausedKey[] = "paused"; 72 const char kPausedKey[] = "paused";
71 const char kSaveAsKey[] = "saveAs"; 73 const char kSaveAsKey[] = "saveAs";
72 const char kStartTimeKey[] = "startTime"; 74 const char kStartTimeKey[] = "startTime";
73 const char kStateComplete[] = "complete"; 75 const char kStateComplete[] = "complete";
74 const char kStateInProgress[] = "in_progress"; 76 const char kStateInProgress[] = "in_progress";
75 const char kStateInterrupted[] = "interrupted"; 77 const char kStateInterrupted[] = "interrupted";
76 const char kStateKey[] = "state"; 78 const char kStateKey[] = "state";
77 const char kTotalBytesKey[] = "totalBytes"; 79 const char kTotalBytesKey[] = "totalBytes";
78 const char kUrlKey[] = "url"; 80 const char kUrlKey[] = "url";
79 81
80 const char* DangerString(DownloadItem::DangerType danger) { 82 const char* DangerString(DownloadStateInfo::DangerType danger) {
81 switch (danger) { 83 switch (danger) {
82 case DownloadItem::NOT_DANGEROUS: return kDangerSafe; 84 case DownloadStateInfo::MAYBE_DANGEROUS_CONTENT:
83 case DownloadItem::DANGEROUS_FILE: return kDangerFile; 85 case DownloadStateInfo::NOT_DANGEROUS: return kDangerSafe;
84 case DownloadItem::DANGEROUS_URL: return kDangerUrl; 86 case DownloadStateInfo::DANGEROUS_FILE: return kDangerFile;
87 case DownloadStateInfo::DANGEROUS_URL: return kDangerUrl;
88 case DownloadStateInfo::DANGEROUS_CONTENT: return kDangerContent;
85 default: 89 default:
86 NOTREACHED(); 90 NOTREACHED();
87 return ""; 91 return "";
88 } 92 }
89 } 93 }
90 94
91 const char* StateString(DownloadItem::DownloadState state) { 95 const char* StateString(DownloadItem::DownloadState state) {
92 switch (state) { 96 switch (state) {
93 case DownloadItem::IN_PROGRESS: return kStateInProgress; 97 case DownloadItem::IN_PROGRESS: return kStateInProgress;
94 case DownloadItem::COMPLETE: return kStateComplete; 98 case DownloadItem::COMPLETE: return kStateComplete;
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 ListValue args; 546 ListValue args;
543 args.Append(arg); 547 args.Append(arg);
544 std::string json_args; 548 std::string json_args;
545 base::JSONWriter::Write(&args, false, &json_args); 549 base::JSONWriter::Write(&args, false, &json_args);
546 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( 550 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
547 event_name, 551 event_name,
548 json_args, 552 json_args,
549 profile_, 553 profile_,
550 GURL()); 554 GURL());
551 } 555 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698