OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 class LocalDOMWindow; | 41 class LocalDOMWindow; |
42 class InjectedScript; | 42 class InjectedScript; |
43 class InjectedScriptHost; | 43 class InjectedScriptHost; |
44 class ScriptValue; | 44 class ScriptValue; |
45 | 45 |
46 class InjectedScriptManager : public NoBaseWillBeGarbageCollectedFinalized<Injec
tedScriptManager> { | 46 class InjectedScriptManager : public NoBaseWillBeGarbageCollectedFinalized<Injec
tedScriptManager> { |
47 WTF_MAKE_NONCOPYABLE(InjectedScriptManager); | 47 WTF_MAKE_NONCOPYABLE(InjectedScriptManager); |
48 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 48 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
49 public: | 49 public: |
| 50 struct CallbackData { |
| 51 ScopedPersistent<v8::Object> handle; |
| 52 RefPtrWillBePersistent<InjectedScriptHost> host; |
| 53 InjectedScriptManager* injectedScriptManager; |
| 54 }; |
| 55 |
50 static PassOwnPtrWillBeRawPtr<InjectedScriptManager> createForPage(); | 56 static PassOwnPtrWillBeRawPtr<InjectedScriptManager> createForPage(); |
51 static PassOwnPtrWillBeRawPtr<InjectedScriptManager> createForWorker(); | 57 static PassOwnPtrWillBeRawPtr<InjectedScriptManager> createForWorker(); |
52 ~InjectedScriptManager(); | 58 ~InjectedScriptManager(); |
53 void trace(Visitor*); | 59 void trace(Visitor*); |
54 | 60 |
55 void disconnect(); | 61 void disconnect(); |
56 | 62 |
57 InjectedScriptHost* injectedScriptHost(); | 63 InjectedScriptHost* injectedScriptHost(); |
58 | 64 |
59 InjectedScript injectedScriptFor(ScriptState*); | 65 InjectedScript injectedScriptFor(ScriptState*); |
60 InjectedScript injectedScriptForId(int); | 66 InjectedScript injectedScriptForId(int); |
61 int injectedScriptIdFor(ScriptState*); | 67 int injectedScriptIdFor(ScriptState*); |
62 InjectedScript injectedScriptForObjectId(const String& objectId); | 68 InjectedScript injectedScriptForObjectId(const String& objectId); |
63 void discardInjectedScripts(); | 69 void discardInjectedScripts(); |
64 void discardInjectedScriptsFor(LocalDOMWindow*); | 70 void discardInjectedScriptsFor(LocalDOMWindow*); |
65 void releaseObjectGroup(const String& objectGroup); | 71 void releaseObjectGroup(const String& objectGroup); |
66 | 72 |
67 typedef bool (*InspectedStateAccessCheck)(ScriptState*); | 73 typedef bool (*InspectedStateAccessCheck)(ScriptState*); |
68 InspectedStateAccessCheck inspectedStateAccessCheck() const { return m_inspe
ctedStateAccessCheck; } | 74 InspectedStateAccessCheck inspectedStateAccessCheck() const { return m_inspe
ctedStateAccessCheck; } |
69 | 75 |
70 struct CallbackData; | |
71 static void setWeakCallback(const v8::WeakCallbackData<v8::Object, CallbackD
ata>&); | 76 static void setWeakCallback(const v8::WeakCallbackData<v8::Object, CallbackD
ata>&); |
| 77 CallbackData* createCallbackData(InjectedScriptManager*); |
| 78 void removeCallbackData(CallbackData*); |
| 79 |
72 private: | 80 private: |
73 explicit InjectedScriptManager(InspectedStateAccessCheck); | 81 explicit InjectedScriptManager(InspectedStateAccessCheck); |
74 | 82 |
75 String injectedScriptSource(); | 83 String injectedScriptSource(); |
76 ScriptValue createInjectedScript(const String& source, ScriptState*, int id)
; | 84 ScriptValue createInjectedScript(const String& source, ScriptState*, int id)
; |
77 | 85 |
78 static bool canAccessInspectedWindow(ScriptState*); | 86 static bool canAccessInspectedWindow(ScriptState*); |
79 static bool canAccessInspectedWorkerGlobalScope(ScriptState*); | 87 static bool canAccessInspectedWorkerGlobalScope(ScriptState*); |
80 | 88 |
81 int m_nextInjectedScriptId; | 89 int m_nextInjectedScriptId; |
82 typedef HashMap<int, InjectedScript> IdToInjectedScriptMap; | 90 typedef HashMap<int, InjectedScript> IdToInjectedScriptMap; |
83 IdToInjectedScriptMap m_idToInjectedScript; | 91 IdToInjectedScriptMap m_idToInjectedScript; |
84 RefPtrWillBeMember<InjectedScriptHost> m_injectedScriptHost; | 92 RefPtrWillBeMember<InjectedScriptHost> m_injectedScriptHost; |
85 InspectedStateAccessCheck m_inspectedStateAccessCheck; | 93 InspectedStateAccessCheck m_inspectedStateAccessCheck; |
86 typedef HashMap<RefPtr<ScriptState>, int> ScriptStateToId; | 94 typedef HashMap<RefPtr<ScriptState>, int> ScriptStateToId; |
87 ScriptStateToId m_scriptStateToId; | 95 ScriptStateToId m_scriptStateToId; |
| 96 HashSet<OwnPtr<CallbackData> > m_callbackDataSet; |
88 }; | 97 }; |
89 | 98 |
90 } // namespace blink | 99 } // namespace blink |
91 | 100 |
92 #endif // !defined(InjectedScriptManager_h) | 101 #endif // !defined(InjectedScriptManager_h) |
OLD | NEW |