| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #ifndef DOMException_h | 29 #ifndef DOMException_h |
| 30 #define DOMException_h | 30 #define DOMException_h |
| 31 | 31 |
| 32 #include "bindings/core/v8/ScriptWrappable.h" | 32 #include "bindings/core/v8/ScriptWrappable.h" |
| 33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
| 34 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
| 35 #include "wtf/PassRefPtr.h" | 35 #include "wtf/Forward.h" |
| 36 #include "wtf/RefCounted.h" | |
| 37 #include "wtf/text/WTFString.h" | |
| 38 | 36 |
| 39 namespace blink { | 37 namespace blink { |
| 40 | 38 |
| 41 typedef int ExceptionCode; | 39 typedef int ExceptionCode; |
| 42 | 40 |
| 43 class CORE_EXPORT DOMException final : public RefCountedWillBeGarbageCollectedFi
nalized<DOMException>, public ScriptWrappable { | 41 class CORE_EXPORT DOMException final : public GarbageCollectedFinalized<DOMExcep
tion>, public ScriptWrappable { |
| 44 DEFINE_WRAPPERTYPEINFO(); | 42 DEFINE_WRAPPERTYPEINFO(); |
| 45 public: | 43 public: |
| 46 static PassRefPtrWillBeRawPtr<DOMException> create(ExceptionCode, const Stri
ng& sanitizedMessage = String(), const String& unsanitizedMessage = String()); | 44 static DOMException* create(ExceptionCode, const String& sanitizedMessage =
String(), const String& unsanitizedMessage = String()); |
| 47 | 45 |
| 48 unsigned short code() const { return m_code; } | 46 unsigned short code() const { return m_code; } |
| 49 String name() const { return m_name; } | 47 String name() const { return m_name; } |
| 50 | 48 |
| 51 // This is the message that's exposed to JavaScript: never return unsanitize
d data. | 49 // This is the message that's exposed to JavaScript: never return unsanitize
d data. |
| 52 String message() const { return m_sanitizedMessage; } | 50 String message() const { return m_sanitizedMessage; } |
| 53 String toString() const; | 51 String toString() const; |
| 54 | 52 |
| 55 // This is the message that's exposed to the console: if an unsanitized mess
age is present, we prefer it. | 53 // This is the message that's exposed to the console: if an unsanitized mess
age is present, we prefer it. |
| 56 String messageForConsole() const { return !m_unsanitizedMessage.isEmpty() ?
m_unsanitizedMessage : m_sanitizedMessage; } | 54 String messageForConsole() const { return !m_unsanitizedMessage.isEmpty() ?
m_unsanitizedMessage : m_sanitizedMessage; } |
| 57 String toStringForConsole() const; | 55 String toStringForConsole() const; |
| 58 | 56 |
| 59 static String getErrorName(ExceptionCode); | 57 static String getErrorName(ExceptionCode); |
| 60 static String getErrorMessage(ExceptionCode); | 58 static String getErrorMessage(ExceptionCode); |
| 61 | 59 |
| 62 DEFINE_INLINE_TRACE() { } | 60 DEFINE_INLINE_TRACE() { } |
| 63 | 61 |
| 64 private: | 62 private: |
| 65 DOMException(unsigned short m_code, const String& name, const String& saniti
zedMessage, const String& unsanitizedMessage); | 63 DOMException(unsigned short m_code, const String& name, const String& saniti
zedMessage, const String& unsanitizedMessage); |
| 66 | 64 |
| 67 unsigned short m_code; | 65 unsigned short m_code; |
| 68 String m_name; | 66 String m_name; |
| 69 String m_sanitizedMessage; | 67 String m_sanitizedMessage; |
| 70 String m_unsanitizedMessage; | 68 String m_unsanitizedMessage; |
| 71 }; | 69 }; |
| 72 | 70 |
| 73 } // namespace blink | 71 } // namespace blink |
| 74 | 72 |
| 75 #endif // DOMException_h | 73 #endif // DOMException_h |
| OLD | NEW |