OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 21 matching lines...) Expand all Loading... |
32 #include "core/inspector/InjectedScriptModule.h" | 32 #include "core/inspector/InjectedScriptModule.h" |
33 | 33 |
34 #include "bindings/v8/ScriptFunctionCall.h" | 34 #include "bindings/v8/ScriptFunctionCall.h" |
35 #include "bindings/v8/ScriptObject.h" | 35 #include "bindings/v8/ScriptObject.h" |
36 #include "core/inspector/InjectedScript.h" | 36 #include "core/inspector/InjectedScript.h" |
37 #include "core/inspector/InjectedScriptManager.h" | 37 #include "core/inspector/InjectedScriptManager.h" |
38 | 38 |
39 namespace WebCore { | 39 namespace WebCore { |
40 | 40 |
41 InjectedScriptModule::InjectedScriptModule(const String& name) | 41 InjectedScriptModule::InjectedScriptModule(const String& name) |
42 : InjectedScriptBase(name) | 42 : V8InjectedScriptBase(name) |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptM
anager, ScriptState* scriptState) | 46 void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptM
anager, ScriptState* scriptState) |
47 { | 47 { |
48 InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(scr
iptState); | 48 InjectedScript& injectedScriptRaw = injectedScriptManager->injectedScriptFor
(scriptState); |
49 ASSERT(!injectedScript.isEmpty()); | 49 ASSERT(!injectedScriptRaw.isEmpty()); |
50 if (injectedScript.isEmpty()) | 50 if (injectedScriptRaw.isEmpty()) |
51 return; | 51 return; |
52 | 52 |
53 // FIXME: Make the InjectedScript a module itself. | 53 ASSERT(injectedScriptRaw.isJavaScript()); |
| 54 if (!injectedScriptRaw.isJavaScript()) |
| 55 return; |
| 56 V8InjectedScript& injectedScript = static_cast<V8InjectedScript&>(injectedSc
riptRaw); |
| 57 |
| 58 // FIXME: Make the V8InjectedScript a module itself. |
54 ScriptFunctionCall function(injectedScript.injectedScriptObject(), "module")
; | 59 ScriptFunctionCall function(injectedScript.injectedScriptObject(), "module")
; |
55 function.appendArgument(name()); | 60 function.appendArgument(name()); |
56 bool hadException = false; | 61 bool hadException = false; |
57 ScriptValue resultValue = injectedScript.callFunctionWithEvalEnabled(functio
n, hadException); | 62 ScriptValue resultValue = injectedScript.callFunctionWithEvalEnabled(functio
n, hadException); |
58 ASSERT(!hadException); | 63 ASSERT(!hadException); |
59 V8ScriptState::Scope scope(scriptState->v8ScriptState()); | 64 V8ScriptState::Scope scope(scriptState->v8ScriptState()); |
60 if (hadException || resultValue.isEmpty() || !resultValue.isObject()) { | 65 if (hadException || resultValue.isEmpty() || !resultValue.isObject()) { |
61 ScriptFunctionCall function(injectedScript.injectedScriptObject(), "inje
ctModule"); | 66 ScriptFunctionCall function(injectedScript.injectedScriptObject(), "inje
ctModule"); |
62 function.appendArgument(name()); | 67 function.appendArgument(name()); |
63 function.appendArgument(source()); | 68 function.appendArgument(source()); |
64 resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadEx
ception); | 69 resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadEx
ception); |
65 if (hadException || resultValue.isEmpty() || !resultValue.isObject()) { | 70 if (hadException || resultValue.isEmpty() || !resultValue.isObject()) { |
66 ASSERT_NOT_REACHED(); | 71 ASSERT_NOT_REACHED(); |
67 return; | 72 return; |
68 } | 73 } |
69 } | 74 } |
70 | 75 |
71 ScriptObject moduleObject(scriptState, resultValue); | 76 ScriptObject moduleObject(scriptState, resultValue); |
72 initialize(moduleObject, injectedScriptManager->inspectedStateAccessCheck())
; | 77 initialize(moduleObject, injectedScriptManager->inspectedStateAccessCheck())
; |
73 } | 78 } |
74 | 79 |
75 } // namespace WebCore | 80 } // namespace WebCore |
OLD | NEW |