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

Side by Side Diff: Source/core/html/HTMLLinkElement.cpp

Issue 135723008: Add CORS support for <link> elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) 6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com)
7 * Copyright (C) 2011 Google Inc. All rights reserved. 7 * Copyright (C) 2011 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // let the latest (innermost) mutation occur. 131 // let the latest (innermost) mutation occur.
132 if (recursionRank != m_beforeLoadRecurseCount) 132 if (recursionRank != m_beforeLoadRecurseCount)
133 continueLoad = false; 133 continueLoad = false;
134 134
135 if (recursionRank == 1) 135 if (recursionRank == 1)
136 m_beforeLoadRecurseCount = 0; 136 m_beforeLoadRecurseCount = 0;
137 137
138 return continueLoad; 138 return continueLoad;
139 } 139 }
140 140
141 bool HTMLLinkElement::loadLink(const String& type, const KURL& url)
142 {
143 return m_linkLoader.loadLink(m_relAttribute, fastGetAttribute(HTMLNames::cro ssoriginAttr), type, url, document());
144 }
145
141 LinkResource* HTMLLinkElement::linkResourceToProcess() 146 LinkResource* HTMLLinkElement::linkResourceToProcess()
142 { 147 {
143 bool visible = inDocument() && !m_isInShadowTree; 148 bool visible = inDocument() && !m_isInShadowTree;
144 if (!visible) { 149 if (!visible) {
145 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); 150 ASSERT(!linkStyle() || !linkStyle()->hasSheet());
146 return 0; 151 return 0;
147 } 152 }
148 153
149 if (!m_link) { 154 if (!m_link) {
150 if (m_relAttribute.isImport() && RuntimeEnabledFeatures::htmlImportsEnab led()) 155 if (m_relAttribute.isImport() && RuntimeEnabledFeatures::htmlImportsEnab led())
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 mediaQueryMatches = evaluator.eval(media.get()); 588 mediaQueryMatches = evaluator.eval(media.get());
584 } 589 }
585 590
586 // Don't hold up render tree construction and script execution on styles heets 591 // Don't hold up render tree construction and script execution on styles heets
587 // that are not needed for the rendering at the moment. 592 // that are not needed for the rendering at the moment.
588 bool blocking = mediaQueryMatches && !m_owner->isAlternate(); 593 bool blocking = mediaQueryMatches && !m_owner->isAlternate();
589 addPendingSheet(blocking ? Blocking : NonBlocking); 594 addPendingSheet(blocking ? Blocking : NonBlocking);
590 595
591 // Load stylesheets that are not needed for the rendering immediately wi th low priority. 596 // Load stylesheets that are not needed for the rendering immediately wi th low priority.
592 FetchRequest request = builder.build(blocking); 597 FetchRequest request = builder.build(blocking);
598 AtomicString crossOriginMode = m_owner->fastGetAttribute(HTMLNames::cros soriginAttr);
599 if (!crossOriginMode.isNull()) {
600 StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMo de, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
abarth-chromium 2014/01/28 06:38:45 Should we make a helper function that does this wo
sof 2014/01/28 07:23:01 Great suggestion, less repetition. Added FetchReq
601 request.setCrossOriginAccessControl(document().securityOrigin(), all owCredentials);
602 }
593 setResource(document().fetcher()->fetchCSSStyleSheet(request)); 603 setResource(document().fetcher()->fetchCSSStyleSheet(request));
594 604
595 if (!resource()) { 605 if (!resource()) {
596 // The request may have been denied if (for example) the stylesheet is local and the document is remote. 606 // The request may have been denied if (for example) the stylesheet is local and the document is remote.
597 m_loading = false; 607 m_loading = false;
598 removePendingSheet(); 608 removePendingSheet();
599 } 609 }
600 } else if (m_sheet) { 610 } else if (m_sheet) {
601 // we no longer contain a stylesheet, e.g. perhaps rel or type was chang ed 611 // we no longer contain a stylesheet, e.g. perhaps rel or type was chang ed
602 RefPtr<StyleSheet> removedSheet = m_sheet; 612 RefPtr<StyleSheet> removedSheet = m_sheet;
(...skipping 11 matching lines...) Expand all
614 void LinkStyle::ownerRemoved() 624 void LinkStyle::ownerRemoved()
615 { 625 {
616 if (m_sheet) 626 if (m_sheet)
617 clearSheet(); 627 clearSheet();
618 628
619 if (styleSheetIsLoading()) 629 if (styleSheetIsLoading())
620 removePendingSheet(RemovePendingSheetNotifyLater); 630 removePendingSheet(RemovePendingSheetNotifyLater);
621 } 631 }
622 632
623 } // namespace WebCore 633 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698