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

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

Issue 22573005: [HTML Imports] Implement "load" and "error" events. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: For landing Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLImportsController.h ('k') | Source/core/html/HTMLLinkElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 15 matching lines...) Expand all
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 "config.h" 31 #include "config.h"
32 #include "core/html/HTMLImportsController.h" 32 #include "core/html/HTMLImportsController.h"
33 33
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/html/HTMLImportLoader.h" 35 #include "core/html/HTMLImportLoader.h"
36 #include "core/html/HTMLImportLoaderClient.h"
37 #include "core/loader/cache/ResourceFetcher.h"
36 38
37 namespace WebCore { 39 namespace WebCore {
38 40
39 void HTMLImportsController::provideTo(Document* master) 41 void HTMLImportsController::provideTo(Document* master)
40 { 42 {
41 DEFINE_STATIC_LOCAL(const char*, name, ("HTMLImportsController")); 43 DEFINE_STATIC_LOCAL(const char*, name, ("HTMLImportsController"));
42 OwnPtr<HTMLImportsController> controller = adoptPtr(new HTMLImportsControlle r(master)); 44 OwnPtr<HTMLImportsController> controller = adoptPtr(new HTMLImportsControlle r(master));
43 master->setImport(controller.get()); 45 master->setImport(controller.get());
44 Supplement<ScriptExecutionContext>::provideTo(master, name, controller.relea se()); 46 Supplement<ScriptExecutionContext>::provideTo(master, name, controller.relea se());
45 } 47 }
(...skipping 11 matching lines...) Expand all
57 59
58 void HTMLImportsController::clear() 60 void HTMLImportsController::clear()
59 { 61 {
60 for (size_t i = 0; i < m_imports.size(); ++i) 62 for (size_t i = 0; i < m_imports.size(); ++i)
61 m_imports[i]->importDestroyed(); 63 m_imports[i]->importDestroyed();
62 if (m_master) 64 if (m_master)
63 m_master->setImport(0); 65 m_master->setImport(0);
64 m_master = 0; 66 m_master = 0;
65 } 67 }
66 68
67 PassRefPtr<HTMLImportLoader> HTMLImportsController::createLoader(HTMLImport* par ent, const KURL& url, const ResourcePtr<CachedRawResource>& resource) 69 PassRefPtr<HTMLImportLoader> HTMLImportsController::createLoader(HTMLImport* par ent, FetchRequest request)
68 { 70 {
69 ASSERT(!url.isEmpty() && url.isValid()); 71 ASSERT(!request.url().isEmpty() && request.url().isValid());
70 RefPtr<HTMLImportLoader> loader = adoptRef(new HTMLImportLoader(parent, url, resource)); 72
73 if (RefPtr<HTMLImportLoader> found = findLinkFor(request.url()))
74 return found.release();
75
76 request.setPotentiallyCrossOriginEnabled(securityOrigin(), DoNotAllowStoredC redentials);
77 ResourcePtr<CachedRawResource> resource = parent->document()->fetcher()->req uestImport(request);
78 if (!resource)
79 return 0;
80
81 RefPtr<HTMLImportLoader> loader = adoptRef(new HTMLImportLoader(parent, requ est.url(), resource));
71 parent->appendChild(loader.get()); 82 parent->appendChild(loader.get());
72 m_imports.append(loader); 83 m_imports.append(loader);
73 return loader.release(); 84 return loader.release();
74 } 85 }
75 86
76 void HTMLImportsController::showSecurityErrorMessage(const String& message) 87 void HTMLImportsController::showSecurityErrorMessage(const String& message)
77 { 88 {
78 m_master->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message); 89 m_master->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message);
79 } 90 }
80 91
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 152
142 void HTMLImportsController::unblockTimerFired(Timer<HTMLImportsController>*) 153 void HTMLImportsController::unblockTimerFired(Timer<HTMLImportsController>*)
143 { 154 {
144 do { 155 do {
145 m_unblockTimer.stop(); 156 m_unblockTimer.stop();
146 HTMLImport::unblock(this); 157 HTMLImport::unblock(this);
147 } while (m_unblockTimer.isActive()); 158 } while (m_unblockTimer.isActive());
148 } 159 }
149 160
150 } // namespace WebCore 161 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLImportsController.h ('k') | Source/core/html/HTMLLinkElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698