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

Side by Side Diff: Source/bindings/v8/ExceptionState.h

Issue 68563003: Create DOM exceptions in the correct context. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased onto df9a982fbe97 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 unified diff | Download patch
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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
38 #include <v8.h> 38 #include <v8.h>
39 39
40 namespace WebCore { 40 namespace WebCore {
41 41
42 typedef int ExceptionCode; 42 typedef int ExceptionCode;
43 43
44 class ExceptionState { 44 class ExceptionState {
45 WTF_MAKE_NONCOPYABLE(ExceptionState); 45 WTF_MAKE_NONCOPYABLE(ExceptionState);
46 public: 46 public:
47 explicit ExceptionState(v8::Isolate* isolate) 47 explicit ExceptionState(const v8::Handle<v8::Object>& creationContext, v8::I solate* isolate)
48 : m_code(0) 48 : m_code(0)
49 , m_creationContext(creationContext)
49 , m_isolate(isolate) { } 50 , m_isolate(isolate) { }
50 51
51 virtual void throwDOMException(const ExceptionCode&, const String& message) ; 52 virtual void throwDOMException(const ExceptionCode&, const String& message);
52 virtual void throwTypeError(const String& message); 53 virtual void throwTypeError(const String& message);
53 virtual void throwSecurityError(const String& sanitizedMessage, const String & unsanitizedMessage = String()); 54 virtual void throwSecurityError(const String& sanitizedMessage, const String & unsanitizedMessage = String());
54 55
55 // Please don't use these methods. Use ::throwDOMException and ::throwTypeEr ror, and pass in a useful exception message. 56 // Please don't use these methods. Use ::throwDOMException and ::throwTypeEr ror, and pass in a useful exception message.
56 virtual void throwUninformativeAndGenericDOMException(const ExceptionCode& e c) { throwDOMException(ec, String()); } 57 virtual void throwUninformativeAndGenericDOMException(const ExceptionCode& e c) { throwDOMException(ec, String()); }
57 virtual void throwUninformativeAndGenericTypeError() { throwTypeError(String ()); } 58 virtual void throwUninformativeAndGenericTypeError() { throwTypeError(String ()); }
58 59
59 bool hadException() const { return !m_exception.isEmpty() || m_code; } 60 bool hadException() const { return !m_exception.isEmpty() || m_code; }
60 void clearException(); 61 void clearException();
61 62
(...skipping 11 matching lines...) Expand all
73 return true; 74 return true;
74 } 75 }
75 76
76 protected: 77 protected:
77 ExceptionCode m_code; 78 ExceptionCode m_code;
78 79
79 private: 80 private:
80 void setException(v8::Handle<v8::Value>); 81 void setException(v8::Handle<v8::Value>);
81 82
82 ScopedPersistent<v8::Value> m_exception; 83 ScopedPersistent<v8::Value> m_exception;
84 v8::Handle<v8::Object> m_creationContext;
83 v8::Isolate* m_isolate; 85 v8::Isolate* m_isolate;
84 }; 86 };
85 87
86 class TrackExceptionState : public ExceptionState { 88 class TrackExceptionState : public ExceptionState {
87 public: 89 public:
88 TrackExceptionState(): ExceptionState(0) { } 90 TrackExceptionState(): ExceptionState(v8::Handle<v8::Object>(), 0) { }
89 virtual void throwDOMException(const ExceptionCode&, const String& message) OVERRIDE FINAL; 91 virtual void throwDOMException(const ExceptionCode&, const String& message) OVERRIDE FINAL;
90 virtual void throwTypeError(const String& message = String()) OVERRIDE FINAL ; 92 virtual void throwTypeError(const String& message = String()) OVERRIDE FINAL ;
91 virtual void throwSecurityError(const String& sanitizedMessage, const String & unsanitizedMessage = String()) OVERRIDE FINAL; 93 virtual void throwSecurityError(const String& sanitizedMessage, const String & unsanitizedMessage = String()) OVERRIDE FINAL;
92 }; 94 };
93 95
94 } // namespace WebCore 96 } // namespace WebCore
95 97
96 #endif // ExceptionState_h 98 #endif // ExceptionState_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/CustomElementConstructorBuilder.cpp ('k') | Source/bindings/v8/ExceptionState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698