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

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, 10 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 m_windowProxyManager->mainWorldProxy()->updateSecurityOrigin(origin); 145 m_windowProxyManager->mainWorldProxy()->updateSecurityOrigin(origin);
146 Vector<std::pair<ScriptState*, SecurityOrigin*>> isolatedContexts; 146 Vector<std::pair<ScriptState*, SecurityOrigin*>> isolatedContexts;
147 m_windowProxyManager->collectIsolatedContexts(isolatedContexts); 147 m_windowProxyManager->collectIsolatedContexts(isolatedContexts);
148 for (auto isolatedContext : isolatedContexts) 148 for (auto isolatedContext : isolatedContexts)
149 m_windowProxyManager->windowProxy(isolatedContext.first->world())->updat eSecurityOrigin(isolatedContext.second); 149 m_windowProxyManager->windowProxy(isolatedContext.first->world())->updat eSecurityOrigin(isolatedContext.second);
150 } 150 }
151 151
152 v8::MaybeLocal<v8::Value> ScriptController::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) 152 v8::MaybeLocal<v8::Value> ScriptController::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[])
153 { 153 {
154 // Keep LocalFrame (and therefore ScriptController) alive. 154 // Keep LocalFrame (and therefore ScriptController) alive.
155 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 155 RawPtr<LocalFrame> protect(frame());
156 return ScriptController::callFunction(frame()->document(), function, receive r, argc, info, isolate()); 156 return ScriptController::callFunction(frame()->document(), function, receive r, argc, info, isolate());
157 } 157 }
158 158
159 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) 159 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)
160 { 160 {
161 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callFunction(function, co ntext, receiver, argc, info, isolate); 161 v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callFunction(function, co ntext, receiver, argc, info, isolate);
162 return result; 162 return result;
163 } 163 }
164 164
165 v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Local<v8: :Context> context, const ScriptSourceCode& source, AccessControlStatus accessCon trolStatus, double* compilationFinishTime) 165 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
181 tryCatch.SetVerbose(true); 181 tryCatch.SetVerbose(true);
182 182
183 v8::Local<v8::Script> script; 183 v8::Local<v8::Script> script;
184 if (!v8Call(V8ScriptRunner::compileScript(source, isolate(), accessContr olStatus, v8CacheOptions), script, tryCatch)) 184 if (!v8Call(V8ScriptRunner::compileScript(source, isolate(), accessContr olStatus, v8CacheOptions), script, tryCatch))
185 return result; 185 return result;
186 186
187 if (compilationFinishTime) { 187 if (compilationFinishTime) {
188 *compilationFinishTime = WTF::monotonicallyIncreasingTime(); 188 *compilationFinishTime = WTF::monotonicallyIncreasingTime();
189 } 189 }
190 // Keep LocalFrame (and therefore ScriptController) alive. 190 // Keep LocalFrame (and therefore ScriptController) alive.
191 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 191 RawPtr<LocalFrame> protect(frame());
192 if (!v8Call(V8ScriptRunner::runCompiledScript(isolate(), script, frame() ->document()), result, tryCatch)) 192 if (!v8Call(V8ScriptRunner::runCompiledScript(isolate(), script, frame() ->document()), result, tryCatch))
193 return result; 193 return result;
194 } 194 }
195 195
196 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( )); 196 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( ));
197 197
198 return result; 198 return result;
199 } 199 }
200 200
201 bool ScriptController::initializeMainWorld() 201 bool ScriptController::initializeMainWorld()
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 if (!frame()->page() 493 if (!frame()->page()
494 || (!shouldBypassMainWorldContentSecurityPolicy && !frame()->document()- >contentSecurityPolicy()->allowJavaScriptURLs(frame()->document()->url(), eventH andlerPosition().m_line))) 494 || (!shouldBypassMainWorldContentSecurityPolicy && !frame()->document()- >contentSecurityPolicy()->allowJavaScriptURLs(frame()->document()->url(), eventH andlerPosition().m_line)))
495 return true; 495 return true;
496 496
497 bool progressNotificationsNeeded = frame()->loader().stateMachine()->isDispl ayingInitialEmptyDocument() && !frame()->isLoading(); 497 bool progressNotificationsNeeded = frame()->loader().stateMachine()->isDispl ayingInitialEmptyDocument() && !frame()->isLoading();
498 if (progressNotificationsNeeded) 498 if (progressNotificationsNeeded)
499 frame()->loader().progress().progressStarted(); 499 frame()->loader().progress().progressStarted();
500 500
501 // We need to hold onto the LocalFrame here because executing script can 501 // We need to hold onto the LocalFrame here because executing script can
502 // destroy the frame. 502 // destroy the frame.
503 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 503 RawPtr<LocalFrame> protect(frame());
504 RefPtrWillBeRawPtr<Document> ownerDocument(frame()->document()); 504 RawPtr<Document> ownerDocument(frame()->document());
505 505
506 const int javascriptSchemeLength = sizeof("javascript:") - 1; 506 const int javascriptSchemeLength = sizeof("javascript:") - 1;
507 507
508 bool locationChangeBefore = frame()->navigationScheduler().locationChangePen ding(); 508 bool locationChangeBefore = frame()->navigationScheduler().locationChangePen ding();
509 509
510 String decodedURL = decodeURLEscapeSequences(url.string()); 510 String decodedURL = decodeURLEscapeSequences(url.string());
511 v8::HandleScope handleScope(isolate()); 511 v8::HandleScope handleScope(isolate());
512 v8::Local<v8::Value> result = evaluateScriptInMainWorld(ScriptSourceCode(dec odedURL.substring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecute ScriptWhenScriptsDisabled); 512 v8::Local<v8::Value> result = evaluateScriptInMainWorld(ScriptSourceCode(dec odedURL.substring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecute ScriptWhenScriptsDisabled);
513 513
514 // If executing script caused this frame to be removed from the page, we 514 // 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
557 String sourceURL = sourceCode.url(); 557 String sourceURL = sourceCode.url();
558 const String* savedSourceURL = m_sourceURL; 558 const String* savedSourceURL = m_sourceURL;
559 m_sourceURL = &sourceURL; 559 m_sourceURL = &sourceURL;
560 560
561 ScriptState* scriptState = ScriptState::forMainWorld(frame()); 561 ScriptState* scriptState = ScriptState::forMainWorld(frame());
562 if (!scriptState) 562 if (!scriptState)
563 return v8::Local<v8::Value>(); 563 return v8::Local<v8::Value>();
564 v8::EscapableHandleScope handleScope(isolate()); 564 v8::EscapableHandleScope handleScope(isolate());
565 ScriptState::Scope scope(scriptState); 565 ScriptState::Scope scope(scriptState);
566 566
567 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 567 RawPtr<LocalFrame> protect(frame());
568 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument()) 568 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument())
569 frame()->loader().didAccessInitialDocument(); 569 frame()->loader().didAccessInitialDocument();
570 570
571 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCode, accessControlStatus, compilationFinishTime); 571 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCode, accessControlStatus, compilationFinishTime);
572 m_sourceURL = savedSourceURL; 572 m_sourceURL = savedSourceURL;
573 573
574 if (object.IsEmpty()) 574 if (object.IsEmpty())
575 return v8::Local<v8::Value>(); 575 return v8::Local<v8::Value>();
576 576
577 return handleScope.Escape(object); 577 return handleScope.Escape(object);
578 } 578 }
579 579
580 void ScriptController::executeScriptInIsolatedWorld(int worldID, const WillBeHea pVector<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Val ue>>* results) 580 void ScriptController::executeScriptInIsolatedWorld(int worldID, const HeapVecto r<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Value>>* results)
581 { 581 {
582 ASSERT(worldID > 0); 582 ASSERT(worldID > 0);
583 583
584 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate (), worldID, extensionGroup); 584 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate (), worldID, extensionGroup);
585 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); 585 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world);
586 if (!isolatedWorldWindowProxy->isContextInitialized()) 586 if (!isolatedWorldWindowProxy->isContextInitialized())
587 return; 587 return;
588 588
589 ScriptState* scriptState = isolatedWorldWindowProxy->scriptState(); 589 ScriptState* scriptState = isolatedWorldWindowProxy->scriptState();
590 v8::Context::Scope scope(scriptState->context()); 590 v8::Context::Scope scope(scriptState->context());
(...skipping 11 matching lines...) Expand all
602 for (size_t i = 0; i < resultArray->Length(); ++i) { 602 for (size_t i = 0; i < resultArray->Length(); ++i) {
603 v8::Local<v8::Value> value; 603 v8::Local<v8::Value> value;
604 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) 604 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value))
605 return; 605 return;
606 results->append(value); 606 results->append(value);
607 } 607 }
608 } 608 }
609 } 609 }
610 610
611 } // namespace blink 611 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698