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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 4 * Copyright (C) 2014 Opera Software ASA. 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 are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 m_windowProxyManager->mainWorldProxy()->updateSecurityOrigin(origin); 143 m_windowProxyManager->mainWorldProxy()->updateSecurityOrigin(origin);
144 Vector<std::pair<ScriptState*, SecurityOrigin*>> isolatedContexts; 144 Vector<std::pair<ScriptState*, SecurityOrigin*>> isolatedContexts;
145 m_windowProxyManager->collectIsolatedContexts(isolatedContexts); 145 m_windowProxyManager->collectIsolatedContexts(isolatedContexts);
146 for (auto isolatedContext : isolatedContexts) 146 for (auto isolatedContext : isolatedContexts)
147 m_windowProxyManager->windowProxy(isolatedContext.first->world())->updat eSecurityOrigin(isolatedContext.second); 147 m_windowProxyManager->windowProxy(isolatedContext.first->world())->updat eSecurityOrigin(isolatedContext.second);
148 } 148 }
149 149
150 v8::MaybeLocal<v8::Value> ScriptController::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) 150 v8::MaybeLocal<v8::Value> ScriptController::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[])
151 { 151 {
152 // Keep LocalFrame (and therefore ScriptController) alive. 152 // Keep LocalFrame (and therefore ScriptController) alive.
153 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 153 RawPtr<LocalFrame> protect(frame());
154 return ScriptController::callFunction(frame()->document(), function, receive r, argc, info, isolate()); 154 return ScriptController::callFunction(frame()->document(), function, receive r, argc, info, isolate());
155 } 155 }
156 156
157 v8::MaybeLocal<v8::Value> ScriptController::callFunction(ExecutionContext* conte xt, v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v 8::Local<v8::Value> info[], v8::Isolate* isolate) 157 v8::MaybeLocal<v8::Value> ScriptController::callFunction(ExecutionContext* conte xt, v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v 8::Local<v8::Value> info[], v8::Isolate* isolate)
158 { 158 {
159 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callFunction(function, co ntext, receiver, argc, info, isolate); 159 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callFunction(function, co ntext, receiver, argc, info, isolate);
160 return result; 160 return result;
161 } 161 }
162 162
163 v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Local<v8: :Context> context, const ScriptSourceCode& source, AccessControlStatus accessCon trolStatus, double* compilationFinishTime) 163 v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Local<v8: :Context> context, const ScriptSourceCode& source, AccessControlStatus accessCon trolStatus, double* compilationFinishTime)
(...skipping 15 matching lines...) Expand all
179 tryCatch.SetVerbose(true); 179 tryCatch.SetVerbose(true);
180 180
181 v8::Local<v8::Script> script; 181 v8::Local<v8::Script> script;
182 if (!v8Call(V8ScriptRunner::compileScript(source, isolate(), accessContr olStatus, v8CacheOptions), script, tryCatch)) 182 if (!v8Call(V8ScriptRunner::compileScript(source, isolate(), accessContr olStatus, v8CacheOptions), script, tryCatch))
183 return result; 183 return result;
184 184
185 if (compilationFinishTime) { 185 if (compilationFinishTime) {
186 *compilationFinishTime = WTF::monotonicallyIncreasingTime(); 186 *compilationFinishTime = WTF::monotonicallyIncreasingTime();
187 } 187 }
188 // Keep LocalFrame (and therefore ScriptController) alive. 188 // Keep LocalFrame (and therefore ScriptController) alive.
189 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 189 RawPtr<LocalFrame> protect(frame());
190 if (!v8Call(V8ScriptRunner::runCompiledScript(isolate(), script, frame() ->document()), result, tryCatch)) 190 if (!v8Call(V8ScriptRunner::runCompiledScript(isolate(), script, frame() ->document()), result, tryCatch))
191 return result; 191 return result;
192 } 192 }
193 193
194 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( )); 194 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( ));
195 195
196 return result; 196 return result;
197 } 197 }
198 198
199 bool ScriptController::initializeMainWorld() 199 bool ScriptController::initializeMainWorld()
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 if (!frame()->page() 491 if (!frame()->page()
492 || (!shouldBypassMainWorldContentSecurityPolicy && !frame()->document()- >contentSecurityPolicy()->allowJavaScriptURLs(frame()->document()->url(), eventH andlerPosition().m_line))) 492 || (!shouldBypassMainWorldContentSecurityPolicy && !frame()->document()- >contentSecurityPolicy()->allowJavaScriptURLs(frame()->document()->url(), eventH andlerPosition().m_line)))
493 return true; 493 return true;
494 494
495 bool progressNotificationsNeeded = frame()->loader().stateMachine()->isDispl ayingInitialEmptyDocument() && !frame()->isLoading(); 495 bool progressNotificationsNeeded = frame()->loader().stateMachine()->isDispl ayingInitialEmptyDocument() && !frame()->isLoading();
496 if (progressNotificationsNeeded) 496 if (progressNotificationsNeeded)
497 frame()->loader().progress().progressStarted(); 497 frame()->loader().progress().progressStarted();
498 498
499 // We need to hold onto the LocalFrame here because executing script can 499 // We need to hold onto the LocalFrame here because executing script can
500 // destroy the frame. 500 // destroy the frame.
501 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 501 RawPtr<LocalFrame> protect(frame());
502 RefPtrWillBeRawPtr<Document> ownerDocument(frame()->document()); 502 RawPtr<Document> ownerDocument(frame()->document());
503 503
504 const int javascriptSchemeLength = sizeof("javascript:") - 1; 504 const int javascriptSchemeLength = sizeof("javascript:") - 1;
505 505
506 bool locationChangeBefore = frame()->navigationScheduler().locationChangePen ding(); 506 bool locationChangeBefore = frame()->navigationScheduler().locationChangePen ding();
507 507
508 String decodedURL = decodeURLEscapeSequences(url.getString()); 508 String decodedURL = decodeURLEscapeSequences(url.getString());
509 v8::HandleScope handleScope(isolate()); 509 v8::HandleScope handleScope(isolate());
510 v8::Local<v8::Value> result = evaluateScriptInMainWorld(ScriptSourceCode(dec odedURL.substring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecute ScriptWhenScriptsDisabled); 510 v8::Local<v8::Value> result = evaluateScriptInMainWorld(ScriptSourceCode(dec odedURL.substring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecute ScriptWhenScriptsDisabled);
511 511
512 // If executing script caused this frame to be removed from the page, we 512 // If executing script caused this frame to be removed from the page, we
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 String sourceURL = sourceCode.url(); 555 String sourceURL = sourceCode.url();
556 const String* savedSourceURL = m_sourceURL; 556 const String* savedSourceURL = m_sourceURL;
557 m_sourceURL = &sourceURL; 557 m_sourceURL = &sourceURL;
558 558
559 ScriptState* scriptState = ScriptState::forMainWorld(frame()); 559 ScriptState* scriptState = ScriptState::forMainWorld(frame());
560 if (!scriptState) 560 if (!scriptState)
561 return v8::Local<v8::Value>(); 561 return v8::Local<v8::Value>();
562 v8::EscapableHandleScope handleScope(isolate()); 562 v8::EscapableHandleScope handleScope(isolate());
563 ScriptState::Scope scope(scriptState); 563 ScriptState::Scope scope(scriptState);
564 564
565 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 565 RawPtr<LocalFrame> protect(frame());
566 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument()) 566 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument())
567 frame()->loader().didAccessInitialDocument(); 567 frame()->loader().didAccessInitialDocument();
568 568
569 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCode, accessControlStatus, compilationFinishTime); 569 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCode, accessControlStatus, compilationFinishTime);
570 m_sourceURL = savedSourceURL; 570 m_sourceURL = savedSourceURL;
571 571
572 if (object.IsEmpty()) 572 if (object.IsEmpty())
573 return v8::Local<v8::Value>(); 573 return v8::Local<v8::Value>();
574 574
575 return handleScope.Escape(object); 575 return handleScope.Escape(object);
576 } 576 }
577 577
578 void ScriptController::executeScriptInIsolatedWorld(int worldID, const WillBeHea pVector<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Val ue>>* results) 578 void ScriptController::executeScriptInIsolatedWorld(int worldID, const HeapVecto r<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Value>>* results)
579 { 579 {
580 ASSERT(worldID > 0); 580 ASSERT(worldID > 0);
581 581
582 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate (), worldID, extensionGroup); 582 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate (), worldID, extensionGroup);
583 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); 583 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world);
584 if (!isolatedWorldWindowProxy->isContextInitialized()) 584 if (!isolatedWorldWindowProxy->isContextInitialized())
585 return; 585 return;
586 586
587 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState(); 587 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState();
588 v8::Context::Scope scope(scriptState->context()); 588 v8::Context::Scope scope(scriptState->context());
(...skipping 11 matching lines...) Expand all
600 for (size_t i = 0; i < resultArray->Length(); ++i) { 600 for (size_t i = 0; i < resultArray->Length(); ++i) {
601 v8::Local<v8::Value> value; 601 v8::Local<v8::Value> value;
602 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) 602 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value))
603 return; 603 return;
604 results->append(value); 604 results->append(value);
605 } 605 }
606 } 606 }
607 } 607 }
608 608
609 } // namespace blink 609 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698