OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/v8_inspector/InspectedContext.h" | 5 #include "platform/v8_inspector/InspectedContext.h" |
6 | 6 |
7 #include "platform/v8_inspector/InjectedScript.h" | 7 #include "platform/v8_inspector/InjectedScript.h" |
| 8 #include "platform/v8_inspector/V8Console.h" |
8 #include "platform/v8_inspector/V8DebuggerImpl.h" | 9 #include "platform/v8_inspector/V8DebuggerImpl.h" |
| 10 #include "platform/v8_inspector/V8StringUtil.h" |
9 #include "platform/v8_inspector/public/V8ContextInfo.h" | 11 #include "platform/v8_inspector/public/V8ContextInfo.h" |
10 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 12 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
11 | 13 |
12 namespace blink { | 14 namespace blink { |
13 | 15 |
14 void InspectedContext::weakCallback(const v8::WeakCallbackInfo<InspectedContext>
& data) | 16 void InspectedContext::weakCallback(const v8::WeakCallbackInfo<InspectedContext>
& data) |
15 { | 17 { |
16 data.GetParameter()->m_debugger->discardInspectedContext(data.GetParameter()
->m_contextGroupId, data.GetParameter()->m_contextId); | 18 data.GetParameter()->m_debugger->discardInspectedContext(data.GetParameter()
->m_contextGroupId, data.GetParameter()->m_contextId); |
17 } | 19 } |
18 | 20 |
19 InspectedContext::InspectedContext(V8DebuggerImpl* debugger, const V8ContextInfo
& info, int contextId) | 21 InspectedContext::InspectedContext(V8DebuggerImpl* debugger, const V8ContextInfo
& info, int contextId) |
20 : m_debugger(debugger) | 22 : m_debugger(debugger) |
21 , m_context(info.context->GetIsolate(), info.context) | 23 , m_context(info.context->GetIsolate(), info.context) |
22 , m_contextId(contextId) | 24 , m_contextId(contextId) |
23 , m_contextGroupId(info.contextGroupId) | 25 , m_contextGroupId(info.contextGroupId) |
24 , m_isDefault(info.isDefault) | 26 , m_isDefault(info.isDefault) |
25 , m_origin(info.origin) | 27 , m_origin(info.origin) |
26 , m_humanReadableName(info.humanReadableName) | 28 , m_humanReadableName(info.humanReadableName) |
27 , m_frameId(info.frameId) | 29 , m_frameId(info.frameId) |
28 , m_reported(false) | 30 , m_reported(false) |
29 { | 31 { |
30 m_context.SetWeak(this, &InspectedContext::weakCallback, v8::WeakCallbackTyp
e::kParameter); | 32 m_context.SetWeak(this, &InspectedContext::weakCallback, v8::WeakCallbackTyp
e::kParameter); |
| 33 |
| 34 v8::Isolate* isolate = m_debugger->isolate(); |
| 35 v8::Local<v8::Object> global = info.context->Global(); |
| 36 v8::Local<v8::Object> console; |
| 37 if (!V8Console::create(info.context, this, info.hasMemoryOnConsole).ToLocal(
&console)) |
| 38 return; |
| 39 if (!global->Set(info.context, toV8StringInternalized(isolate, "console"), c
onsole).FromMaybe(false)) |
| 40 return; |
31 } | 41 } |
32 | 42 |
33 InspectedContext::~InspectedContext() | 43 InspectedContext::~InspectedContext() |
34 { | 44 { |
35 } | 45 } |
36 | 46 |
37 v8::Local<v8::Context> InspectedContext::context() const | 47 v8::Local<v8::Context> InspectedContext::context() const |
38 { | 48 { |
39 return m_context.Get(isolate()); | 49 return m_context.Get(isolate()); |
40 } | 50 } |
(...skipping 13 matching lines...) Expand all Loading... |
54 return; | 64 return; |
55 m_injectedScript = InjectedScript::create(this, injectedScriptHost); | 65 m_injectedScript = InjectedScript::create(this, injectedScriptHost); |
56 } | 66 } |
57 | 67 |
58 void InspectedContext::discardInjectedScript() | 68 void InspectedContext::discardInjectedScript() |
59 { | 69 { |
60 m_injectedScript.clear(); | 70 m_injectedScript.clear(); |
61 } | 71 } |
62 | 72 |
63 } // namespace blink | 73 } // namespace blink |
OLD | NEW |