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

Side by Side Diff: Source/core/inspector/InjectedScriptBase.cpp

Issue 293963003: Remove ScriptObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 months 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 | Annotate | Revision Log
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 using WebCore::TypeBuilder::Runtime::RemoteObject; 42 using WebCore::TypeBuilder::Runtime::RemoteObject;
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 InjectedScriptBase::InjectedScriptBase(const String& name) 46 InjectedScriptBase::InjectedScriptBase(const String& name)
47 : m_name(name) 47 : m_name(name)
48 , m_inspectedStateAccessCheck(0) 48 , m_inspectedStateAccessCheck(0)
49 { 49 {
50 } 50 }
51 51
52 InjectedScriptBase::InjectedScriptBase(const String& name, ScriptObject injected ScriptObject, InspectedStateAccessCheck accessCheck) 52 InjectedScriptBase::InjectedScriptBase(const String& name, ScriptValue injectedS criptValue, InspectedStateAccessCheck accessCheck)
53 : m_name(name) 53 : m_name(name)
54 , m_injectedScriptObject(injectedScriptObject) 54 , m_injectedScriptValue(injectedScriptValue)
55 , m_inspectedStateAccessCheck(accessCheck) 55 , m_inspectedStateAccessCheck(accessCheck)
56 { 56 {
57 } 57 }
58 58
59 void InjectedScriptBase::initialize(ScriptObject injectedScriptObject, Inspected StateAccessCheck accessCheck) 59 void InjectedScriptBase::initialize(ScriptValue injectedScriptValue, InspectedSt ateAccessCheck accessCheck)
60 { 60 {
61 m_injectedScriptObject = injectedScriptObject; 61 m_injectedScriptValue = injectedScriptValue;
62 m_inspectedStateAccessCheck = accessCheck; 62 m_inspectedStateAccessCheck = accessCheck;
63 } 63 }
64 64
65 bool InjectedScriptBase::canAccessInspectedWindow() const 65 bool InjectedScriptBase::canAccessInspectedWindow() const
66 { 66 {
67 return m_inspectedStateAccessCheck(m_injectedScriptObject.scriptState()); 67 return m_inspectedStateAccessCheck(m_injectedScriptValue.scriptState());
68 } 68 }
69 69
70 const ScriptObject& InjectedScriptBase::injectedScriptObject() const 70 const ScriptValue& InjectedScriptBase::injectedScriptValue() const
71 { 71 {
72 return m_injectedScriptObject; 72 return m_injectedScriptValue;
73 } 73 }
74 74
75 ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const 75 ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const
76 { 76 {
77 ExecutionContext* executionContext = m_injectedScriptObject.scriptState()->e xecutionContext(); 77 ExecutionContext* executionContext = m_injectedScriptValue.scriptState()->ex ecutionContext();
78 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", InspectorFunctionCallEvent::data(executionContext, 0, name(), 1)); 78 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", InspectorFunctionCallEvent::data(executionContext, 0, name(), 1));
79 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 79 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack());
80 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 80 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
81 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFu nction(executionContext, 0, name(), 1); 81 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFu nction(executionContext, 0, name(), 1);
82 82
83 ScriptState* scriptState = m_injectedScriptObject.scriptState(); 83 ScriptState* scriptState = m_injectedScriptValue.scriptState();
84 bool evalIsDisabled = false; 84 bool evalIsDisabled = false;
85 if (scriptState) { 85 if (scriptState) {
86 evalIsDisabled = !scriptState->evalEnabled(); 86 evalIsDisabled = !scriptState->evalEnabled();
87 // Temporarily enable allow evals for inspector. 87 // Temporarily enable allow evals for inspector.
88 if (evalIsDisabled) 88 if (evalIsDisabled)
89 scriptState->setEvalEnabled(true); 89 scriptState->setEvalEnabled(true);
90 } 90 }
91 91
92 ScriptValue resultValue = function.call(hadException); 92 ScriptValue resultValue = function.call(hadException);
93 93
(...skipping 10 matching lines...) Expand all
104 if (isEmpty() || !canAccessInspectedWindow()) { 104 if (isEmpty() || !canAccessInspectedWindow()) {
105 *result = JSONValue::null(); 105 *result = JSONValue::null();
106 return; 106 return;
107 } 107 }
108 108
109 bool hadException = false; 109 bool hadException = false;
110 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException ); 110 ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException );
111 111
112 ASSERT(!hadException); 112 ASSERT(!hadException);
113 if (!hadException) { 113 if (!hadException) {
114 *result = resultValue.toJSONValue(m_injectedScriptObject.scriptState()); 114 *result = resultValue.toJSONValue(m_injectedScriptValue.scriptState());
115 if (!*result) 115 if (!*result)
116 *result = JSONString::create(String::format("Object has too long ref erence chain(must not be longer than %d)", JSONValue::maxDepth)); 116 *result = JSONString::create(String::format("Object has too long ref erence chain(must not be longer than %d)", JSONValue::maxDepth));
117 } else { 117 } else {
118 *result = JSONString::create("Exception while making a call."); 118 *result = JSONString::create("Exception while making a call.");
119 } 119 }
120 } 120 }
121 121
122 void InjectedScriptBase::makeEvalCall(ErrorString* errorString, ScriptFunctionCa ll& function, RefPtr<TypeBuilder::Runtime::RemoteObject>* objectResult, TypeBuil der::OptOutput<bool>* wasThrown) 122 void InjectedScriptBase::makeEvalCall(ErrorString* errorString, ScriptFunctionCa ll& function, RefPtr<TypeBuilder::Runtime::RemoteObject>* objectResult, TypeBuil der::OptOutput<bool>* wasThrown)
123 { 123 {
124 RefPtr<JSONValue> result; 124 RefPtr<JSONValue> result;
(...skipping 17 matching lines...) Expand all
142 if (!resultObj || !resultPair->getBoolean("wasThrown", &wasThrownVal)) { 142 if (!resultObj || !resultPair->getBoolean("wasThrown", &wasThrownVal)) {
143 *errorString = "Internal error: result is not a pair of value and wasThr own flag"; 143 *errorString = "Internal error: result is not a pair of value and wasThr own flag";
144 return; 144 return;
145 } 145 }
146 *objectResult = TypeBuilder::Runtime::RemoteObject::runtimeCast(resultObj); 146 *objectResult = TypeBuilder::Runtime::RemoteObject::runtimeCast(resultObj);
147 *wasThrown = wasThrownVal; 147 *wasThrown = wasThrownVal;
148 } 148 }
149 149
150 } // namespace WebCore 150 } // namespace WebCore
151 151
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698