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

Side by Side Diff: Source/core/html/parser/XSSAuditorDelegate.cpp

Issue 1311923004: Rename FormData/FormDataBuilder to EncodedFormData/FormDataEncoder respectively. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: update comments Created 5 years, 3 months 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
« no previous file with comments | « Source/core/html/parser/XSSAuditorDelegate.h ('k') | Source/core/inspector/AsyncCallTracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 17 matching lines...) Expand all
28 28
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/frame/LocalFrame.h" 30 #include "core/frame/LocalFrame.h"
31 #include "core/inspector/ConsoleMessage.h" 31 #include "core/inspector/ConsoleMessage.h"
32 #include "core/loader/DocumentLoader.h" 32 #include "core/loader/DocumentLoader.h"
33 #include "core/loader/FrameLoader.h" 33 #include "core/loader/FrameLoader.h"
34 #include "core/loader/FrameLoaderClient.h" 34 #include "core/loader/FrameLoaderClient.h"
35 #include "core/loader/NavigationScheduler.h" 35 #include "core/loader/NavigationScheduler.h"
36 #include "core/loader/PingLoader.h" 36 #include "core/loader/PingLoader.h"
37 #include "platform/JSONValues.h" 37 #include "platform/JSONValues.h"
38 #include "platform/network/FormData.h" 38 #include "platform/network/EncodedFormData.h"
39 #include "platform/weborigin/SecurityOrigin.h" 39 #include "platform/weborigin/SecurityOrigin.h"
40 #include "wtf/text/StringBuilder.h" 40 #include "wtf/text/StringBuilder.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 String XSSInfo::buildConsoleError() const 44 String XSSInfo::buildConsoleError() const
45 { 45 {
46 StringBuilder message; 46 StringBuilder message;
47 message.appendLiteral("The XSS Auditor "); 47 message.appendLiteral("The XSS Auditor ");
48 message.append(m_didBlockEntirePage ? "blocked access to" : "refused to exec ute a script in"); 48 message.append(m_didBlockEntirePage ? "blocked access to" : "refused to exec ute a script in");
(...skipping 24 matching lines...) Expand all
73 { 73 {
74 ASSERT(isMainThread()); 74 ASSERT(isMainThread());
75 ASSERT(m_document); 75 ASSERT(m_document);
76 } 76 }
77 77
78 DEFINE_TRACE(XSSAuditorDelegate) 78 DEFINE_TRACE(XSSAuditorDelegate)
79 { 79 {
80 visitor->trace(m_document); 80 visitor->trace(m_document);
81 } 81 }
82 82
83 PassRefPtr<FormData> XSSAuditorDelegate::generateViolationReport(const XSSInfo& xssInfo) 83 PassRefPtr<EncodedFormData> XSSAuditorDelegate::generateViolationReport(const XS SInfo& xssInfo)
84 { 84 {
85 ASSERT(isMainThread()); 85 ASSERT(isMainThread());
86 86
87 FrameLoader& frameLoader = m_document->frame()->loader(); 87 FrameLoader& frameLoader = m_document->frame()->loader();
88 String httpBody; 88 String httpBody;
89 if (frameLoader.documentLoader()) { 89 if (frameLoader.documentLoader()) {
90 if (FormData* formData = frameLoader.documentLoader()->originalRequest() .httpBody()) 90 if (EncodedFormData* formData = frameLoader.documentLoader()->originalRe quest().httpBody())
91 httpBody = formData->flattenToString(); 91 httpBody = formData->flattenToString();
92 } 92 }
93 93
94 RefPtr<JSONObject> reportDetails = JSONObject::create(); 94 RefPtr<JSONObject> reportDetails = JSONObject::create();
95 reportDetails->setString("request-url", xssInfo.m_originalURL); 95 reportDetails->setString("request-url", xssInfo.m_originalURL);
96 reportDetails->setString("request-body", httpBody); 96 reportDetails->setString("request-body", httpBody);
97 97
98 RefPtr<JSONObject> reportObject = JSONObject::create(); 98 RefPtr<JSONObject> reportObject = JSONObject::create();
99 reportObject->setObject("xss-report", reportDetails.release()); 99 reportObject->setObject("xss-report", reportDetails.release());
100 100
101 return FormData::create(reportObject->toJSONString().utf8().data()); 101 return EncodedFormData::create(reportObject->toJSONString().utf8().data());
102 } 102 }
103 103
104 void XSSAuditorDelegate::didBlockScript(const XSSInfo& xssInfo) 104 void XSSAuditorDelegate::didBlockScript(const XSSInfo& xssInfo)
105 { 105 {
106 ASSERT(isMainThread()); 106 ASSERT(isMainThread());
107 107
108 m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorM essageLevel, xssInfo.buildConsoleError())); 108 m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorM essageLevel, xssInfo.buildConsoleError()));
109 109
110 // stopAllLoaders can detach the LocalFrame, so protect it. 110 // stopAllLoaders can detach the LocalFrame, so protect it.
111 RefPtrWillBeRawPtr<LocalFrame> protect(m_document->frame()); 111 RefPtrWillBeRawPtr<LocalFrame> protect(m_document->frame());
112 FrameLoader& frameLoader = m_document->frame()->loader(); 112 FrameLoader& frameLoader = m_document->frame()->loader();
113 if (xssInfo.m_didBlockEntirePage) 113 if (xssInfo.m_didBlockEntirePage)
114 frameLoader.stopAllLoaders(); 114 frameLoader.stopAllLoaders();
115 115
116 if (!m_didSendNotifications) { 116 if (!m_didSendNotifications) {
117 m_didSendNotifications = true; 117 m_didSendNotifications = true;
118 118
119 frameLoader.client()->didDetectXSS(m_document->url(), xssInfo.m_didBlock EntirePage); 119 frameLoader.client()->didDetectXSS(m_document->url(), xssInfo.m_didBlock EntirePage);
120 120
121 if (!m_reportURL.isEmpty()) 121 if (!m_reportURL.isEmpty())
122 PingLoader::sendViolationReport(m_document->frame(), m_reportURL, ge nerateViolationReport(xssInfo), PingLoader::XSSAuditorViolationReport); 122 PingLoader::sendViolationReport(m_document->frame(), m_reportURL, ge nerateViolationReport(xssInfo), PingLoader::XSSAuditorViolationReport);
123 } 123 }
124 124
125 if (xssInfo.m_didBlockEntirePage) 125 if (xssInfo.m_didBlockEntirePage)
126 m_document->frame()->navigationScheduler().schedulePageBlock(m_document) ; 126 m_document->frame()->navigationScheduler().schedulePageBlock(m_document) ;
127 } 127 }
128 128
129 } // namespace blink 129 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/parser/XSSAuditorDelegate.h ('k') | Source/core/inspector/AsyncCallTracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698