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

Side by Side Diff: third_party/WebKit/Source/core/html/LinkResource.cpp

Issue 2553803003: Refactor HTMLLinkElement
Patch Set: a Created 4 years 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/html/LinkResource.h" 31 #include "core/html/LinkResource.h"
32 32
33 #include "core/HTMLNames.h"
34 #include "core/dom/Document.h"
35 #include "core/html/HTMLLinkElement.h" 33 #include "core/html/HTMLLinkElement.h"
36 #include "core/html/imports/HTMLImportsController.h"
37 34
38 namespace blink { 35 namespace blink {
39 36
40 using namespace HTMLNames;
41
42 LinkResource::LinkResource(HTMLLinkElement* owner) : m_owner(owner) {} 37 LinkResource::LinkResource(HTMLLinkElement* owner) : m_owner(owner) {}
43 38
44 LinkResource::~LinkResource() {} 39 LinkResource::~LinkResource() {}
45 40
46 bool LinkResource::shouldLoadResource() const {
47 return m_owner->document().frame() || m_owner->document().importsController();
48 }
49
50 LocalFrame* LinkResource::loadingFrame() const {
51 HTMLImportsController* importsController =
52 m_owner->document().importsController();
53 if (!importsController)
54 return m_owner->document().frame();
55 return importsController->master()->frame();
56 }
57
58 DEFINE_TRACE(LinkResource) { 41 DEFINE_TRACE(LinkResource) {
59 visitor->trace(m_owner); 42 visitor->trace(m_owner);
60 } 43 }
61 44
62 LinkRequestBuilder::LinkRequestBuilder(HTMLLinkElement* owner)
63 : m_owner(owner), m_url(owner->getNonEmptyURLAttribute(hrefAttr)) {
64 m_charset = m_owner->getAttribute(charsetAttr);
65 if (m_charset.isEmpty() && m_owner->document().frame())
66 m_charset = m_owner->document().characterSet();
67 }
68
69 FetchRequest LinkRequestBuilder::build(bool lowPriority) const {
70 FetchRequest request(ResourceRequest(m_owner->document().completeURL(m_url)),
71 m_owner->localName(), m_charset);
72 if (lowPriority)
73 request.setDefer(FetchRequest::LazyLoad);
74 request.setContentSecurityPolicyNonce(
75 m_owner->fastGetAttribute(HTMLNames::nonceAttr));
76 return request;
77 }
78
79 } // namespace blink 45 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/LinkResource.h ('k') | third_party/WebKit/Source/core/html/LinkStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698