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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp

Issue 1767883002: DevTools: generate string16-based handlers for v8_inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing 2 Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 int contextId = V8Debugger::contextId(context); 88 int contextId = V8Debugger::contextId(context);
89 discardInjectedScript(contextId); 89 discardInjectedScript(contextId);
90 return contextId; 90 return contextId;
91 } 91 }
92 92
93 void InjectedScriptManager::discardInjectedScript(int contextId) 93 void InjectedScriptManager::discardInjectedScript(int contextId)
94 { 94 {
95 m_idToInjectedScript.remove(contextId); 95 m_idToInjectedScript.remove(contextId);
96 } 96 }
97 97
98 void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) 98 void InjectedScriptManager::releaseObjectGroup(const String16& objectGroup)
99 { 99 {
100 protocol::Vector<int> keys; 100 protocol::Vector<int> keys;
101 for (auto& it : m_idToInjectedScript) 101 for (auto& it : m_idToInjectedScript)
102 keys.append(it.first); 102 keys.append(it.first);
103 for (auto& key : keys) { 103 for (auto& key : keys) {
104 if (m_idToInjectedScript.contains(key)) // m_idToInjectedScript may chan ge here. 104 if (m_idToInjectedScript.contains(key)) // m_idToInjectedScript may chan ge here.
105 m_idToInjectedScript.get(key)->releaseObjectGroup(objectGroup); 105 m_idToInjectedScript.get(key)->releaseObjectGroup(objectGroup);
106 } 106 }
107 } 107 }
108 108
(...skipping 13 matching lines...) Expand all
122 122
123 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); 123 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId);
124 if (it != m_idToInjectedScript.end()) 124 if (it != m_idToInjectedScript.end())
125 return it->second; 125 return it->second;
126 126
127 v8::Local<v8::Context> callingContext = context->GetIsolate()->GetCallingCon text(); 127 v8::Local<v8::Context> callingContext = context->GetIsolate()->GetCallingCon text();
128 if (!callingContext.IsEmpty() && !m_client->callingContextCanAccessContext(c allingContext, context)) 128 if (!callingContext.IsEmpty() && !m_client->callingContextCanAccessContext(c allingContext, context))
129 return nullptr; 129 return nullptr;
130 130
131 OwnPtr<InjectedScriptNative> injectedScriptNative = adoptPtr(new InjectedScr iptNative(context->GetIsolate())); 131 OwnPtr<InjectedScriptNative> injectedScriptNative = adoptPtr(new InjectedScr iptNative(context->GetIsolate()));
132 String injectedScriptSource(reinterpret_cast<const char*>(InjectedScriptSour ce_js), sizeof(InjectedScriptSource_js)); 132 String16 injectedScriptSource(reinterpret_cast<const char*>(InjectedScriptSo urce_js), sizeof(InjectedScriptSource_js));
133 133
134 v8::Local<v8::Object> object = createInjectedScript(injectedScriptSource, co ntext, contextId, injectedScriptNative.get()); 134 v8::Local<v8::Object> object = createInjectedScript(injectedScriptSource, co ntext, contextId, injectedScriptNative.get());
135 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, o bject, m_client, injectedScriptNative.release(), contextId)); 135 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, o bject, m_client, injectedScriptNative.release(), contextId));
136 InjectedScript* resultPtr = result.get(); 136 InjectedScript* resultPtr = result.get();
137 if (m_customObjectFormatterEnabled) 137 if (m_customObjectFormatterEnabled)
138 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); 138 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled);
139 m_idToInjectedScript.set(contextId, result.release()); 139 m_idToInjectedScript.set(contextId, result.release());
140 140
141 return resultPtr; 141 return resultPtr;
142 } 142 }
143 143
144 v8::Local<v8::Object> InjectedScriptManager::createInjectedScript(const String& source, v8::Local<v8::Context> context, int id, InjectedScriptNative* injectedSc riptNative) 144 v8::Local<v8::Object> InjectedScriptManager::createInjectedScript(const String16 & source, v8::Local<v8::Context> context, int id, InjectedScriptNative* injected ScriptNative)
145 { 145 {
146 v8::Isolate* isolate = context->GetIsolate(); 146 v8::Isolate* isolate = context->GetIsolate();
147 v8::Context::Scope scope(context); 147 v8::Context::Scope scope(context);
148 148
149 v8::Local<v8::FunctionTemplate> wrapperTemplate = m_injectedScriptHost->wrap perTemplate(isolate); 149 v8::Local<v8::FunctionTemplate> wrapperTemplate = m_injectedScriptHost->wrap perTemplate(isolate);
150 if (wrapperTemplate.IsEmpty()) { 150 if (wrapperTemplate.IsEmpty()) {
151 wrapperTemplate = V8InjectedScriptHost::createWrapperTemplate(isolate); 151 wrapperTemplate = V8InjectedScriptHost::createWrapperTemplate(isolate);
152 m_injectedScriptHost->setWrapperTemplate(wrapperTemplate, isolate); 152 m_injectedScriptHost->setWrapperTemplate(wrapperTemplate, isolate);
153 } 153 }
154 154
(...skipping 17 matching lines...) Expand all
172 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number: :New(context->GetIsolate(), id) }; 172 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number: :New(context->GetIsolate(), id) };
173 v8::Local<v8::Value> injectedScriptValue; 173 v8::Local<v8::Value> injectedScriptValue;
174 if (!m_client->callInternalFunction(v8::Local<v8::Function>::Cast(value), wi ndowGlobal, WTF_ARRAY_LENGTH(info), info).ToLocal(&injectedScriptValue)) 174 if (!m_client->callInternalFunction(v8::Local<v8::Function>::Cast(value), wi ndowGlobal, WTF_ARRAY_LENGTH(info), info).ToLocal(&injectedScriptValue))
175 return v8::Local<v8::Object>(); 175 return v8::Local<v8::Object>();
176 if (!injectedScriptValue->IsObject()) 176 if (!injectedScriptValue->IsObject())
177 return v8::Local<v8::Object>(); 177 return v8::Local<v8::Object>();
178 return injectedScriptValue.As<v8::Object>(); 178 return injectedScriptValue.As<v8::Object>();
179 } 179 }
180 180
181 } // namespace blink 181 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698