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

Side by Side Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 1865813002: Remove RawPtr from Source/web/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return frameForContext(context); 536 return frameForContext(context);
537 } 537 }
538 538
539 WebLocalFrame* WebLocalFrame::frameForContext(v8::Local<v8::Context> context) 539 WebLocalFrame* WebLocalFrame::frameForContext(v8::Local<v8::Context> context)
540 { 540 {
541 return WebLocalFrameImpl::fromFrame(toLocalFrame(toFrameIfNotDetached(contex t))); 541 return WebLocalFrameImpl::fromFrame(toLocalFrame(toFrameIfNotDetached(contex t)));
542 } 542 }
543 543
544 WebLocalFrame* WebLocalFrame::fromFrameOwnerElement(const WebElement& element) 544 WebLocalFrame* WebLocalFrame::fromFrameOwnerElement(const WebElement& element)
545 { 545 {
546 return WebLocalFrameImpl::fromFrameOwnerElement(RawPtr<Element>(element).get ()); 546 return WebLocalFrameImpl::fromFrameOwnerElement(element);
547 } 547 }
548 548
549 bool WebLocalFrameImpl::isWebLocalFrame() const 549 bool WebLocalFrameImpl::isWebLocalFrame() const
550 { 550 {
551 return true; 551 return true;
552 } 552 }
553 553
554 WebLocalFrame* WebLocalFrameImpl::toWebLocalFrame() 554 WebLocalFrame* WebLocalFrameImpl::toWebLocalFrame()
555 { 555 {
556 return this; 556 return this;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 frame()->inputMethodController().cancelComposition(); 988 frame()->inputMethodController().cancelComposition();
989 } 989 }
990 990
991 bool WebLocalFrameImpl::hasMarkedText() const 991 bool WebLocalFrameImpl::hasMarkedText() const
992 { 992 {
993 return frame()->inputMethodController().hasComposition(); 993 return frame()->inputMethodController().hasComposition();
994 } 994 }
995 995
996 WebRange WebLocalFrameImpl::markedRange() const 996 WebRange WebLocalFrameImpl::markedRange() const
997 { 997 {
998 return frame()->inputMethodController().compositionRange(); 998 return frame()->inputMethodController().compositionRange().get();
999 } 999 }
1000 1000
1001 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l ength, WebRect& rectInViewport) const 1001 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l ength, WebRect& rectInViewport) const
1002 { 1002 {
1003 if ((location + length < location) && (location + length)) 1003 if ((location + length < location) && (location + length))
1004 length = 0; 1004 length = 0;
1005 1005
1006 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen t(); 1006 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen t();
1007 if (!editable) 1007 if (!editable)
1008 return false; 1008 return false;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); 1109 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
1110 if (pluginContainer) 1110 if (pluginContainer)
1111 return pluginContainer->plugin()->hasSelection(); 1111 return pluginContainer->plugin()->hasSelection();
1112 1112
1113 // frame()->selection()->isNone() never returns true. 1113 // frame()->selection()->isNone() never returns true.
1114 return frame()->selection().start() != frame()->selection().end(); 1114 return frame()->selection().start() != frame()->selection().end();
1115 } 1115 }
1116 1116
1117 WebRange WebLocalFrameImpl::selectionRange() const 1117 WebRange WebLocalFrameImpl::selectionRange() const
1118 { 1118 {
1119 return createRange(frame()->selection().selection().toNormalizedEphemeralRan ge()); 1119 return createRange(frame()->selection().selection().toNormalizedEphemeralRan ge()).get();
1120 } 1120 }
1121 1121
1122 WebString WebLocalFrameImpl::selectionAsText() const 1122 WebString WebLocalFrameImpl::selectionAsText() const
1123 { 1123 {
1124 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); 1124 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
1125 if (pluginContainer) 1125 if (pluginContainer)
1126 return pluginContainer->plugin()->selectionAsText(); 1126 return pluginContainer->plugin()->selectionAsText();
1127 1127
1128 String text = frame()->selection().selectedText(TextIteratorEmitsObjectRepla cementCharacter); 1128 String text = frame()->selection().selectedText(TextIteratorEmitsObjectRepla cementCharacter);
1129 #if OS(WIN) 1129 #if OS(WIN)
(...skipping 28 matching lines...) Expand all
1158 } 1158 }
1159 1159
1160 void WebLocalFrameImpl::selectRange(const WebPoint& baseInViewport, const WebPoi nt& extentInViewport) 1160 void WebLocalFrameImpl::selectRange(const WebPoint& baseInViewport, const WebPoi nt& extentInViewport)
1161 { 1161 {
1162 moveRangeSelection(baseInViewport, extentInViewport); 1162 moveRangeSelection(baseInViewport, extentInViewport);
1163 } 1163 }
1164 1164
1165 void WebLocalFrameImpl::selectRange(const WebRange& webRange) 1165 void WebLocalFrameImpl::selectRange(const WebRange& webRange)
1166 { 1166 {
1167 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectRange"); 1167 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectRange");
1168 if (RawPtr<Range> range = static_cast<RawPtr<Range>>(webRange)) 1168 if (Range* range = static_cast<Range*>(webRange))
1169 frame()->selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY, SelectionDirectionalMode::NonDirectional, NotUserTriggered); 1169 frame()->selection().setSelectedRange(range, VP_DEFAULT_AFFINITY, Select ionDirectionalMode::NonDirectional, NotUserTriggered);
1170 } 1170 }
1171 1171
1172 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point) 1172 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point)
1173 { 1173 {
1174 TRACE_EVENT0("blink", "WebLocalFrameImpl::moveRangeSelectionExtent"); 1174 TRACE_EVENT0("blink", "WebLocalFrameImpl::moveRangeSelectionExtent");
1175 frame()->selection().moveRangeSelectionExtent(frame()->view()->viewportToCon tents(point)); 1175 frame()->selection().moveRangeSelectionExtent(frame()->view()->viewportToCon tents(point));
1176 } 1176 }
1177 1177
1178 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const WebPoint& extentInViewport, WebFrame::TextGranularity granularity) 1178 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const WebPoint& extentInViewport, WebFrame::TextGranularity granularity)
1179 { 1179 {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 frame->setOpener(opener); 1410 frame->setOpener(opener);
1411 #if ENABLE(OILPAN) 1411 #if ENABLE(OILPAN)
1412 return frame; 1412 return frame;
1413 #else 1413 #else
1414 return adoptRef(frame).leakRef(); 1414 return adoptRef(frame).leakRef();
1415 #endif 1415 #endif
1416 } 1416 }
1417 1417
1418 WebLocalFrameImpl* WebLocalFrameImpl::createProvisional(WebFrameClient* client, WebRemoteFrame* oldWebFrame, WebSandboxFlags flags, const WebFrameOwnerPropertie s& frameOwnerProperties) 1418 WebLocalFrameImpl* WebLocalFrameImpl::createProvisional(WebFrameClient* client, WebRemoteFrame* oldWebFrame, WebSandboxFlags flags, const WebFrameOwnerPropertie s& frameOwnerProperties)
1419 { 1419 {
1420 RawPtr<WebLocalFrameImpl> webFrame = new WebLocalFrameImpl(oldWebFrame, clie nt); 1420 WebLocalFrameImpl* webFrame = new WebLocalFrameImpl(oldWebFrame, client);
1421 Frame* oldFrame = oldWebFrame->toImplBase()->frame(); 1421 Frame* oldFrame = oldWebFrame->toImplBase()->frame();
1422 webFrame->setParent(oldWebFrame->parent()); 1422 webFrame->setParent(oldWebFrame->parent());
1423 webFrame->setOpener(oldWebFrame->opener()); 1423 webFrame->setOpener(oldWebFrame->opener());
1424 // Note: this *always* temporarily sets a frame owner, even for main frames! 1424 // Note: this *always* temporarily sets a frame owner, even for main frames!
1425 // When a core Frame is created with no owner, it attempts to set itself as 1425 // When a core Frame is created with no owner, it attempts to set itself as
1426 // the main frame of the Page. However, this is a provisional frame, and may 1426 // the main frame of the Page. However, this is a provisional frame, and may
1427 // disappear, so Page::m_mainFrame can't be updated just yet. 1427 // disappear, so Page::m_mainFrame can't be updated just yet.
1428 RawPtr<FrameOwner> tempOwner = DummyFrameOwner::create(); 1428 FrameOwner* tempOwner = DummyFrameOwner::create();
1429 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to r euse it here. 1429 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to r euse it here.
1430 RawPtr<LocalFrame> frame = LocalFrame::create(webFrame->m_frameLoaderClientI mpl.get(), oldFrame->host(), tempOwner.get(), client ? client->serviceRegistry() : nullptr); 1430 LocalFrame* frame = LocalFrame::create(webFrame->m_frameLoaderClientImpl.get (), oldFrame->host(), tempOwner, client ? client->serviceRegistry() : nullptr);
1431 // Set the name and unique name directly, bypassing any of the normal logic 1431 // Set the name and unique name directly, bypassing any of the normal logic
1432 // to calculate unique name. 1432 // to calculate unique name.
1433 frame->tree().setPrecalculatedName(toWebRemoteFrameImpl(oldWebFrame)->frame( )->tree().name(), toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().uniqueName( )); 1433 frame->tree().setPrecalculatedName(toWebRemoteFrameImpl(oldWebFrame)->frame( )->tree().name(), toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().uniqueName( ));
1434 webFrame->setCoreFrame(frame); 1434 webFrame->setCoreFrame(frame);
1435 1435
1436 frame->setOwner(oldFrame->owner()); 1436 frame->setOwner(oldFrame->owner());
1437 1437
1438 if (frame->owner() && frame->owner()->isRemote()) { 1438 if (frame->owner() && frame->owner()->isRemote()) {
1439 toRemoteFrameOwner(frame->owner())->setSandboxFlags(static_cast<SandboxF lags>(flags)); 1439 toRemoteFrameOwner(frame->owner())->setSandboxFlags(static_cast<SandboxF lags>(flags));
1440 // Since a remote frame doesn't get the notifications about frame owner 1440 // Since a remote frame doesn't get the notifications about frame owner
1441 // property modifications, we need to sync up those properties here. 1441 // property modifications, we need to sync up those properties here.
1442 webFrame->setFrameOwnerProperties(frameOwnerProperties); 1442 webFrame->setFrameOwnerProperties(frameOwnerProperties);
1443 } 1443 }
1444 1444
1445 // We must call init() after m_frame is assigned because it is referenced 1445 // We must call init() after m_frame is assigned because it is referenced
1446 // during init(). Note that this may dispatch JS events; the frame may be 1446 // during init(). Note that this may dispatch JS events; the frame may be
1447 // detached after init() returns. 1447 // detached after init() returns.
1448 frame->init(); 1448 frame->init();
1449 #if ENABLE(OILPAN) 1449 return webFrame;
1450 return webFrame.get();
1451 #else
1452 return webFrame.release().leakRef();
1453 #endif
1454 } 1450 }
1455 1451
1456 1452
1457 WebLocalFrameImpl::WebLocalFrameImpl(WebTreeScopeType scope, WebFrameClient* cli ent) 1453 WebLocalFrameImpl::WebLocalFrameImpl(WebTreeScopeType scope, WebFrameClient* cli ent)
1458 : WebLocalFrame(scope) 1454 : WebLocalFrame(scope)
1459 , m_frameLoaderClientImpl(FrameLoaderClientImpl::create(this)) 1455 , m_frameLoaderClientImpl(FrameLoaderClientImpl::create(this))
1460 , m_frameWidget(0) 1456 , m_frameWidget(0)
1461 , m_client(client) 1457 , m_client(client)
1462 , m_autofillClient(0) 1458 , m_autofillClient(0)
1463 , m_contentSettingsClient(0) 1459 , m_contentSettingsClient(0)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 visitor->trace(m_devToolsAgent); 1493 visitor->trace(m_devToolsAgent);
1498 visitor->trace(m_textFinder); 1494 visitor->trace(m_textFinder);
1499 visitor->trace(m_printContext); 1495 visitor->trace(m_printContext);
1500 visitor->trace(m_geolocationClientProxy); 1496 visitor->trace(m_geolocationClientProxy);
1501 visitor->template registerWeakMembers<WebFrame, &WebFrame::clearWeakFrames>( this); 1497 visitor->template registerWeakMembers<WebFrame, &WebFrame::clearWeakFrames>( this);
1502 WebFrame::traceFrames(visitor, this); 1498 WebFrame::traceFrames(visitor, this);
1503 WebFrameImplBase::trace(visitor); 1499 WebFrameImplBase::trace(visitor);
1504 } 1500 }
1505 #endif 1501 #endif
1506 1502
1507 void WebLocalFrameImpl::setCoreFrame(RawPtr<LocalFrame> frame) 1503 void WebLocalFrameImpl::setCoreFrame(LocalFrame* frame)
1508 { 1504 {
1509 m_frame = frame; 1505 m_frame = frame;
1510 1506
1511 // FIXME: we shouldn't add overhead to every frame by registering these obje cts when they're not used. 1507 // FIXME: we shouldn't add overhead to every frame by registering these obje cts when they're not used.
1512 if (!m_frame) 1508 if (!m_frame)
1513 return; 1509 return;
1514 1510
1515 if (m_client) 1511 if (m_client)
1516 providePushControllerTo(*m_frame, m_client->pushClient()); 1512 providePushControllerTo(*m_frame, m_client->pushClient());
1517 1513
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 setCoreFrame(LocalFrame::create(m_frameLoaderClientImpl.get(), host, owner, client() ? client()->serviceRegistry() : nullptr)); 1550 setCoreFrame(LocalFrame::create(m_frameLoaderClientImpl.get(), host, owner, client() ? client()->serviceRegistry() : nullptr));
1555 frame()->tree().setPrecalculatedName(name, uniqueName); 1551 frame()->tree().setPrecalculatedName(name, uniqueName);
1556 // We must call init() after m_frame is assigned because it is referenced 1552 // We must call init() after m_frame is assigned because it is referenced
1557 // during init(). Note that this may dispatch JS events; the frame may be 1553 // during init(). Note that this may dispatch JS events; the frame may be
1558 // detached after init() returns. 1554 // detached after init() returns.
1559 frame()->init(); 1555 frame()->init();
1560 if (frame() && frame()->loader().stateMachine()->isDisplayingInitialEmptyDoc ument() && !parent() && !opener() && frame()->settings()->shouldReuseGlobalForUn ownedMainFrame()) 1556 if (frame() && frame()->loader().stateMachine()->isDisplayingInitialEmptyDoc ument() && !parent() && !opener() && frame()->settings()->shouldReuseGlobalForUn ownedMainFrame())
1561 frame()->document()->getSecurityOrigin()->grantUniversalAccess(); 1557 frame()->document()->getSecurityOrigin()->grantUniversalAccess();
1562 } 1558 }
1563 1559
1564 RawPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const FrameLoadRequest& r equest, 1560 LocalFrame* WebLocalFrameImpl::createChildFrame(const FrameLoadRequest& request,
1565 const AtomicString& name, HTMLFrameOwnerElement* ownerElement) 1561 const AtomicString& name, HTMLFrameOwnerElement* ownerElement)
1566 { 1562 {
1567 DCHECK(m_client); 1563 DCHECK(m_client);
1568 TRACE_EVENT0("blink", "WebLocalFrameImpl::createChildframe"); 1564 TRACE_EVENT0("blink", "WebLocalFrameImpl::createChildframe");
1569 WebTreeScopeType scope = frame()->document() == ownerElement->treeScope() 1565 WebTreeScopeType scope = frame()->document() == ownerElement->treeScope()
1570 ? WebTreeScopeType::Document 1566 ? WebTreeScopeType::Document
1571 : WebTreeScopeType::Shadow; 1567 : WebTreeScopeType::Shadow;
1572 WebFrameOwnerProperties ownerProperties(ownerElement->scrollingMode(), owner Element->marginWidth(), ownerElement->marginHeight()); 1568 WebFrameOwnerProperties ownerProperties(ownerElement->scrollingMode(), owner Element->marginWidth(), ownerElement->marginHeight());
1573 // FIXME: Using subResourceAttributeName as fallback is not a perfect 1569 // FIXME: Using subResourceAttributeName as fallback is not a perfect
1574 // solution. subResourceAttributeName returns just one attribute name. The 1570 // solution. subResourceAttributeName returns just one attribute name. The
1575 // element might not have the attribute, and there might be other attributes 1571 // element might not have the attribute, and there might be other attributes
1576 // which can identify the element. 1572 // which can identify the element.
1577 AtomicString uniqueName = frame()->tree().calculateUniqueNameForNewChildFram e( 1573 AtomicString uniqueName = frame()->tree().calculateUniqueNameForNewChildFram e(
1578 name, ownerElement->getAttribute(ownerElement->subResourceAttributeName( ))); 1574 name, ownerElement->getAttribute(ownerElement->subResourceAttributeName( )));
1579 RawPtr<WebLocalFrameImpl> webframeChild = toWebLocalFrameImpl(m_client->crea teChildFrame(this, scope, name, uniqueName, static_cast<WebSandboxFlags>(ownerEl ement->getSandboxFlags()), ownerProperties)); 1575 WebLocalFrameImpl* webframeChild = toWebLocalFrameImpl(m_client->createChild Frame(this, scope, name, uniqueName, static_cast<WebSandboxFlags>(ownerElement-> getSandboxFlags()), ownerProperties));
1580 if (!webframeChild) 1576 if (!webframeChild)
1581 return nullptr; 1577 return nullptr;
1582 1578
1583 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name, uniq ueName); 1579 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name, uniq ueName);
1584 // Initializing the core frame may cause the new child to be detached, since 1580 // Initializing the core frame may cause the new child to be detached, since
1585 // it may dispatch a load event in the parent. 1581 // it may dispatch a load event in the parent.
1586 if (!webframeChild->parent()) 1582 if (!webframeChild->parent())
1587 return nullptr; 1583 return nullptr;
1588 1584
1589 // If we're moving in the back/forward list, we might want to replace the co ntent 1585 // If we're moving in the back/forward list, we might want to replace the co ntent
1590 // of this child frame with whatever was there at that point. 1586 // of this child frame with whatever was there at that point.
1591 RawPtr<HistoryItem> childItem = nullptr; 1587 HistoryItem* childItem = nullptr;
1592 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished()) 1588 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished())
1593 childItem = RawPtr<HistoryItem>(webframeChild->client()->historyItemForN ewChildFrame()); 1589 childItem = webframeChild->client()->historyItemForNewChildFrame();
1594 1590
1595 FrameLoadRequest newRequest = request; 1591 FrameLoadRequest newRequest = request;
1596 FrameLoadType loadType = FrameLoadTypeStandard; 1592 FrameLoadType loadType = FrameLoadTypeStandard;
1597 if (childItem) { 1593 if (childItem) {
1598 newRequest = FrameLoadRequest(request.originDocument(), 1594 newRequest = FrameLoadRequest(request.originDocument(),
1599 FrameLoader::resourceRequestFromHistoryItem(childItem.get(), WebCach ePolicy::UseProtocolCachePolicy)); 1595 FrameLoader::resourceRequestFromHistoryItem(childItem, WebCachePolic y::UseProtocolCachePolicy));
1600 loadType = FrameLoadTypeInitialHistoryLoad; 1596 loadType = FrameLoadTypeInitialHistoryLoad;
1601 } 1597 }
1602 webframeChild->frame()->loader().load(newRequest, loadType, childItem.get()) ; 1598 webframeChild->frame()->loader().load(newRequest, loadType, childItem);
1603 1599
1604 // Note a synchronous navigation (about:blank) would have already processed 1600 // Note a synchronous navigation (about:blank) would have already processed
1605 // onload, so it is possible for the child frame to have already been 1601 // onload, so it is possible for the child frame to have already been
1606 // detached by script in the page. 1602 // detached by script in the page.
1607 if (!webframeChild->parent()) 1603 if (!webframeChild->parent())
1608 return nullptr; 1604 return nullptr;
1609 return webframeChild->frame(); 1605 return webframeChild->frame();
1610 } 1606 }
1611 1607
1612 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) 1608 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 // Unfortunately, we cannot just use that method since it is private, and 1790 // Unfortunately, we cannot just use that method since it is private, and
1795 // it also doesn't quite behave as we require it to for bookmarklets. The 1791 // it also doesn't quite behave as we require it to for bookmarklets. The
1796 // key difference is that we need to suppress loading the string result 1792 // key difference is that we need to suppress loading the string result
1797 // from evaluating the JS URL if executing the JS URL resulted in a 1793 // from evaluating the JS URL if executing the JS URL resulted in a
1798 // location change. We also allow a JS URL to be loaded even if scripts on 1794 // location change. We also allow a JS URL to be loaded even if scripts on
1799 // the page are otherwise disabled. 1795 // the page are otherwise disabled.
1800 1796
1801 if (!frame()->document() || !frame()->page()) 1797 if (!frame()->document() || !frame()->page())
1802 return; 1798 return;
1803 1799
1804 RawPtr<Document> ownerDocument(frame()->document()); 1800 Document* ownerDocument(frame()->document());
1805 1801
1806 // Protect privileged pages against bookmarklets and other javascript manipu lations. 1802 // Protect privileged pages against bookmarklets and other javascript manipu lations.
1807 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()- >document()->url().protocol())) 1803 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()- >document()->url().protocol()))
1808 return; 1804 return;
1809 1805
1810 String script = decodeURLEscapeSequences(url.getString().substring(strlen("j avascript:"))); 1806 String script = decodeURLEscapeSequences(url.getString().substring(strlen("j avascript:")));
1811 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 1807 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
1812 v8::HandleScope handleScope(toIsolate(frame())); 1808 v8::HandleScope handleScope(toIsolate(frame()));
1813 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR eturnValue(ScriptSourceCode(script)); 1809 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR eturnValue(ScriptSourceCode(script));
1814 if (result.IsEmpty() || !result->IsString()) 1810 if (result.IsEmpty() || !result->IsString())
1815 return; 1811 return;
1816 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result)); 1812 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result));
1817 if (!frame()->navigationScheduler().locationChangePending()) 1813 if (!frame()->navigationScheduler().locationChangePending())
1818 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResul t, ownerDocument.get()); 1814 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResul t, ownerDocument);
1819 } 1815 }
1820 1816
1821 static void ensureFrameLoaderHasCommitted(FrameLoader& frameLoader) 1817 static void ensureFrameLoaderHasCommitted(FrameLoader& frameLoader)
1822 { 1818 {
1823 // Internally, Blink uses CommittedMultipleRealLoads to track whether the 1819 // Internally, Blink uses CommittedMultipleRealLoads to track whether the
1824 // next commit should create a new history item or not. Ensure we have 1820 // next commit should create a new history item or not. Ensure we have
1825 // reached that state. 1821 // reached that state.
1826 if (frameLoader.stateMachine()->committedMultipleRealLoads()) 1822 if (frameLoader.stateMachine()->committedMultipleRealLoads())
1827 return; 1823 return;
1828 frameLoader.stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedMult ipleRealLoads); 1824 frameLoader.stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedMult ipleRealLoads);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 void WebLocalFrameImpl::sendPings(const WebNode& contextNode, const WebURL& dest inationURL) 1886 void WebLocalFrameImpl::sendPings(const WebNode& contextNode, const WebURL& dest inationURL)
1891 { 1887 {
1892 DCHECK(frame()); 1888 DCHECK(frame());
1893 Element* anchor = contextNode.constUnwrap<Node>()->enclosingLinkEventParentO rSelf(); 1889 Element* anchor = contextNode.constUnwrap<Node>()->enclosingLinkEventParentO rSelf();
1894 if (isHTMLAnchorElement(anchor)) 1890 if (isHTMLAnchorElement(anchor))
1895 toHTMLAnchorElement(anchor)->sendPings(destinationURL); 1891 toHTMLAnchorElement(anchor)->sendPings(destinationURL);
1896 } 1892 }
1897 1893
1898 WebURLRequest WebLocalFrameImpl::requestFromHistoryItem(const WebHistoryItem& it em, WebCachePolicy cachePolicy) const 1894 WebURLRequest WebLocalFrameImpl::requestFromHistoryItem(const WebHistoryItem& it em, WebCachePolicy cachePolicy) const
1899 { 1895 {
1900 RawPtr<HistoryItem> historyItem = RawPtr<HistoryItem>(item); 1896 HistoryItem* historyItem = item;
1901 ResourceRequest request = FrameLoader::resourceRequestFromHistoryItem( 1897 ResourceRequest request = FrameLoader::resourceRequestFromHistoryItem(
1902 historyItem.get(), cachePolicy); 1898 historyItem, cachePolicy);
1903 return WrappedResourceRequest(request); 1899 return WrappedResourceRequest(request);
1904 } 1900 }
1905 1901
1906 WebURLRequest WebLocalFrameImpl::requestForReload(WebFrameLoadType loadType, 1902 WebURLRequest WebLocalFrameImpl::requestForReload(WebFrameLoadType loadType,
1907 const WebURL& overrideUrl) const 1903 const WebURL& overrideUrl) const
1908 { 1904 {
1909 DCHECK(frame()); 1905 DCHECK(frame());
1910 ResourceRequest request = frame()->loader().resourceRequestForReload( 1906 ResourceRequest request = frame()->loader().resourceRequestForReload(
1911 static_cast<FrameLoadType>(loadType), overrideUrl); 1907 static_cast<FrameLoadType>(loadType), overrideUrl);
1912 return WrappedResourceRequest(request); 1908 return WrappedResourceRequest(request);
1913 } 1909 }
1914 1910
1915 void WebLocalFrameImpl::load(const WebURLRequest& request, WebFrameLoadType webF rameLoadType, 1911 void WebLocalFrameImpl::load(const WebURLRequest& request, WebFrameLoadType webF rameLoadType,
1916 const WebHistoryItem& item, WebHistoryLoadType webHistoryLoadType, bool isCl ientRedirect) 1912 const WebHistoryItem& item, WebHistoryLoadType webHistoryLoadType, bool isCl ientRedirect)
1917 { 1913 {
1918 DCHECK(frame()); 1914 DCHECK(frame());
1919 DCHECK(!request.isNull()); 1915 DCHECK(!request.isNull());
1920 const ResourceRequest& resourceRequest = request.toResourceRequest(); 1916 const ResourceRequest& resourceRequest = request.toResourceRequest();
1921 1917
1922 if (resourceRequest.url().protocolIs("javascript") 1918 if (resourceRequest.url().protocolIs("javascript")
1923 && webFrameLoadType == WebFrameLoadType::Standard) { 1919 && webFrameLoadType == WebFrameLoadType::Standard) {
1924 loadJavaScriptURL(resourceRequest.url()); 1920 loadJavaScriptURL(resourceRequest.url());
1925 return; 1921 return;
1926 } 1922 }
1927 1923
1928 FrameLoadRequest frameRequest = FrameLoadRequest(nullptr, resourceRequest); 1924 FrameLoadRequest frameRequest = FrameLoadRequest(nullptr, resourceRequest);
1929 if (isClientRedirect) 1925 if (isClientRedirect)
1930 frameRequest.setClientRedirect(ClientRedirectPolicy::ClientRedirect); 1926 frameRequest.setClientRedirect(ClientRedirectPolicy::ClientRedirect);
1931 RawPtr<HistoryItem> historyItem = RawPtr<HistoryItem>(item); 1927 HistoryItem* historyItem = item;
1932 frame()->loader().load( 1928 frame()->loader().load(
1933 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem. get(), 1929 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem,
1934 static_cast<HistoryLoadType>(webHistoryLoadType)); 1930 static_cast<HistoryLoadType>(webHistoryLoadType));
1935 } 1931 }
1936 1932
1937 void WebLocalFrameImpl::loadData(const WebData& data, const WebString& mimeType, 1933 void WebLocalFrameImpl::loadData(const WebData& data, const WebString& mimeType,
1938 const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreacha bleURL, bool replace, 1934 const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreacha bleURL, bool replace,
1939 WebFrameLoadType webFrameLoadType, const WebHistoryItem& item, 1935 WebFrameLoadType webFrameLoadType, const WebHistoryItem& item,
1940 WebHistoryLoadType webHistoryLoadType, bool isClientRedirect) 1936 WebHistoryLoadType webHistoryLoadType, bool isClientRedirect)
1941 { 1937 {
1942 DCHECK(frame()); 1938 DCHECK(frame());
1943 1939
1944 // If we are loading substitute data to replace an existing load, then 1940 // If we are loading substitute data to replace an existing load, then
1945 // inherit all of the properties of that original request. This way, 1941 // inherit all of the properties of that original request. This way,
1946 // reload will re-attempt the original request. It is essential that 1942 // reload will re-attempt the original request. It is essential that
1947 // we only do this when there is an unreachableURL since a non-empty 1943 // we only do this when there is an unreachableURL since a non-empty
1948 // unreachableURL informs FrameLoader::reload to load unreachableURL 1944 // unreachableURL informs FrameLoader::reload to load unreachableURL
1949 // instead of the currently loaded URL. 1945 // instead of the currently loaded URL.
1950 ResourceRequest request; 1946 ResourceRequest request;
1951 if (replace && !unreachableURL.isEmpty() && frame()->loader().provisionalDoc umentLoader()) 1947 if (replace && !unreachableURL.isEmpty() && frame()->loader().provisionalDoc umentLoader())
1952 request = frame()->loader().provisionalDocumentLoader()->originalRequest (); 1948 request = frame()->loader().provisionalDocumentLoader()->originalRequest ();
1953 request.setURL(baseURL); 1949 request.setURL(baseURL);
1954 request.setCheckForBrowserSideNavigation(false); 1950 request.setCheckForBrowserSideNavigation(false);
1955 1951
1956 FrameLoadRequest frameRequest(0, request, SubstituteData(data, mimeType, tex tEncoding, unreachableURL)); 1952 FrameLoadRequest frameRequest(0, request, SubstituteData(data, mimeType, tex tEncoding, unreachableURL));
1957 DCHECK(frameRequest.substituteData().isValid()); 1953 DCHECK(frameRequest.substituteData().isValid());
1958 frameRequest.setReplacesCurrentItem(replace); 1954 frameRequest.setReplacesCurrentItem(replace);
1959 if (isClientRedirect) 1955 if (isClientRedirect)
1960 frameRequest.setClientRedirect(ClientRedirectPolicy::ClientRedirect); 1956 frameRequest.setClientRedirect(ClientRedirectPolicy::ClientRedirect);
1961 1957
1962 RawPtr<HistoryItem> historyItem = RawPtr<HistoryItem>(item); 1958 HistoryItem* historyItem = item;
1963 frame()->loader().load( 1959 frame()->loader().load(
1964 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem. get(), 1960 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem,
1965 static_cast<HistoryLoadType>(webHistoryLoadType)); 1961 static_cast<HistoryLoadType>(webHistoryLoadType));
1966 } 1962 }
1967 1963
1968 bool WebLocalFrameImpl::isLoading() const 1964 bool WebLocalFrameImpl::isLoading() const
1969 { 1965 {
1970 if (!frame() || !frame()->document()) 1966 if (!frame() || !frame()->document())
1971 return false; 1967 return false;
1972 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() || frame()->loader().provisionalDocumentLoader() || !frame()->document()->loadEv entFinished(); 1968 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() || frame()->loader().provisionalDocumentLoader() || !frame()->document()->loadEv entFinished();
1973 } 1969 }
1974 1970
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 return WebSandboxFlags::None; 2168 return WebSandboxFlags::None;
2173 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); 2169 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( ));
2174 } 2170 }
2175 2171
2176 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) 2172 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags)
2177 { 2173 {
2178 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); 2174 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags));
2179 } 2175 }
2180 2176
2181 } // namespace blink 2177 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.h ('k') | third_party/WebKit/Source/web/WebMetaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698