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

Unified Diff: Source/bindings/v8/ExceptionState.cpp

Issue 96203003: Switch HTMLCanvasElement over to new-style ExceptionState. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Capitalize the 'tainted' error messages Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/ExceptionState.h ('k') | Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ExceptionState.cpp
diff --git a/Source/bindings/v8/ExceptionState.cpp b/Source/bindings/v8/ExceptionState.cpp
index 16f0c45b3a34dfbc0f6014b42b8dc260c1e7d1d1..10223be501609f4e46f82c060cf93c30a25b5395 100644
--- a/Source/bindings/v8/ExceptionState.cpp
+++ b/Source/bindings/v8/ExceptionState.cpp
@@ -51,21 +51,8 @@ void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& me
// SecurityError is thrown via ::throwSecurityError, and _careful_ consideration must be given to the data exposed to JavaScript via the 'sanitizedMessage'.
ASSERT(ec != SecurityError);
- String processedMessage = message;
- if (propertyName() && interfaceName() && m_context != UnknownContext) {
- if (m_context == DeletionContext)
- processedMessage = ExceptionMessages::failedToDelete(propertyName(), interfaceName(), message);
- else if (m_context == ExecutionContext)
- processedMessage = ExceptionMessages::failedToExecute(propertyName(), interfaceName(), message);
- else if (m_context == GetterContext)
- processedMessage = ExceptionMessages::failedToGet(propertyName(), interfaceName(), message);
- else if (m_context == SetterContext)
- processedMessage = ExceptionMessages::failedToSet(propertyName(), interfaceName(), message);
- } else if (!propertyName() && interfaceName() && m_context == ConstructionContext) {
- processedMessage = ExceptionMessages::failedToConstruct(interfaceName(), message);
- }
-
m_code = ec;
+ String processedMessage = addExceptionContext(message);
setException(V8ThrowException::createDOMException(ec, processedMessage, m_creationContext, m_isolate));
}
@@ -73,7 +60,9 @@ void ExceptionState::throwSecurityError(const String& sanitizedMessage, const St
{
ASSERT(m_isolate);
m_code = SecurityError;
- setException(V8ThrowException::createDOMException(SecurityError, sanitizedMessage, unsanitizedMessage, m_creationContext, m_isolate));
+ String finalSanitized = addExceptionContext(sanitizedMessage);
+ String finalUnsanitized = addExceptionContext(unsanitizedMessage);
+ setException(V8ThrowException::createDOMException(SecurityError, finalSanitized, finalUnsanitized, m_creationContext, m_isolate));
}
void ExceptionState::setException(v8::Handle<v8::Value> exception)
@@ -109,4 +98,25 @@ void TrackExceptionState::throwSecurityError(const String&, const String&)
m_code = SecurityError;
}
+String ExceptionState::addExceptionContext(const String& message) const
+{
+ if (message.isEmpty())
+ return message;
+
+ String processedMessage = message;
+ if (propertyName() && interfaceName() && m_context != UnknownContext) {
+ if (m_context == DeletionContext)
+ processedMessage = ExceptionMessages::failedToDelete(propertyName(), interfaceName(), message);
+ else if (m_context == ExecutionContext)
+ processedMessage = ExceptionMessages::failedToExecute(propertyName(), interfaceName(), message);
+ else if (m_context == GetterContext)
+ processedMessage = ExceptionMessages::failedToGet(propertyName(), interfaceName(), message);
+ else if (m_context == SetterContext)
+ processedMessage = ExceptionMessages::failedToSet(propertyName(), interfaceName(), message);
+ } else if (!propertyName() && interfaceName() && m_context == ConstructionContext) {
+ processedMessage = ExceptionMessages::failedToConstruct(interfaceName(), message);
+ }
+ return processedMessage;
+}
+
} // namespace WebCore
« no previous file with comments | « Source/bindings/v8/ExceptionState.h ('k') | Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698