OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 #include "core/fetch/ResourceFetcher.h" | 35 #include "core/fetch/ResourceFetcher.h" |
36 #include "core/frame/ContentSecurityPolicyResponseHeaders.h" | 36 #include "core/frame/ContentSecurityPolicyResponseHeaders.h" |
37 #include "core/html/HTMLDocument.h" | 37 #include "core/html/HTMLDocument.h" |
38 #include "core/html/HTMLImport.h" | 38 #include "core/html/HTMLImport.h" |
39 #include "core/html/HTMLImportLoaderClient.h" | 39 #include "core/html/HTMLImportLoaderClient.h" |
40 #include "core/loader/DocumentWriter.h" | 40 #include "core/loader/DocumentWriter.h" |
41 | 41 |
42 | 42 |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 PassRefPtr<HTMLImportLoader> HTMLImportLoader::create(HTMLImport* import, Resour
ceFetcher* fetcher) | 45 HTMLImportLoader::HTMLImportLoader(HTMLImport* import) |
46 { | |
47 RefPtr<HTMLImportLoader> self = adoptRef(new HTMLImportLoader(import, fetche
r)); | |
48 return self.release(); | |
49 } | |
50 | |
51 HTMLImportLoader::HTMLImportLoader(HTMLImport* import, ResourceFetcher* fetcher) | |
52 : m_import(import) | 46 : m_import(import) |
53 , m_fetcher(fetcher) | |
54 , m_state(StateLoading) | 47 , m_state(StateLoading) |
55 { | 48 { |
56 } | 49 } |
57 | 50 |
58 HTMLImportLoader::~HTMLImportLoader() | 51 HTMLImportLoader::~HTMLImportLoader() |
59 { | 52 { |
60 if (m_importedDocument) | 53 if (m_importedDocument) |
61 m_importedDocument->setImport(0); | 54 m_importedDocument->setImport(0); |
62 } | 55 } |
63 | 56 |
64 void HTMLImportLoader::startLoading(const ResourcePtr<RawResource>& resource) | 57 void HTMLImportLoader::startLoading(const ResourcePtr<RawResource>& resource) |
65 { | 58 { |
66 setResource(resource); | 59 setResource(resource); |
67 } | 60 } |
68 | 61 |
69 void HTMLImportLoader::responseReceived(Resource* resource, const ResourceRespon
se& response) | 62 void HTMLImportLoader::responseReceived(Resource* resource, const ResourceRespon
se& response) |
70 { | 63 { |
71 // Current canAccess() implementation isn't sufficient for catching cross-do
main redirects: http://crbug.com/256976 | 64 // Resource may already have been loaded with the import loader |
72 if (!m_fetcher->canAccess(resource, PotentiallyCORSEnabled)) { | 65 // being added as a client later & now being notified. Fail early. |
| 66 if (resource->loadFailedOrCanceled()) { |
73 setState(StateError); | 67 setState(StateError); |
74 return; | 68 return; |
75 } | 69 } |
76 | |
77 setState(startWritingAndParsing(response)); | 70 setState(startWritingAndParsing(response)); |
78 } | 71 } |
79 | 72 |
80 void HTMLImportLoader::dataReceived(Resource*, const char* data, int length) | 73 void HTMLImportLoader::dataReceived(Resource*, const char* data, int length) |
81 { | 74 { |
82 RefPtr<DocumentWriter> protectingWriter(m_writer); | 75 RefPtr<DocumentWriter> protectingWriter(m_writer); |
83 m_writer->addData(data, length); | 76 m_writer->addData(data, length); |
84 } | 77 } |
85 | 78 |
86 void HTMLImportLoader::notifyFinished(Resource* resource) | 79 void HTMLImportLoader::notifyFinished(Resource* resource) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 if (isDone()) | 155 if (isDone()) |
163 client->didFinishLoading(); | 156 client->didFinishLoading(); |
164 } | 157 } |
165 | 158 |
166 void HTMLImportLoader::removeClient(HTMLImportLoaderClient* client) | 159 void HTMLImportLoader::removeClient(HTMLImportLoaderClient* client) |
167 { | 160 { |
168 ASSERT(kNotFound != m_clients.find(client)); | 161 ASSERT(kNotFound != m_clients.find(client)); |
169 m_clients.remove(m_clients.find(client)); | 162 m_clients.remove(m_clients.find(client)); |
170 } | 163 } |
171 | 164 |
172 | |
173 } // namespace WebCore | 165 } // namespace WebCore |
OLD | NEW |