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

Unified Diff: DartApplicationLoader.cpp

Issue 18024004: Bugfix in DOM bindings: canonicalize URLs even if no ApplicationLoader is available (Closed) Base URL: http://src.chromium.org/multivm/trunk/webkit/Source/bindings/dart
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « DartApplicationLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: DartApplicationLoader.cpp
diff --git a/DartApplicationLoader.cpp b/DartApplicationLoader.cpp
index 04dba16d4f282c72d18308765484d4e1136c3d2b..84341b5abd459f602f1f908839feed6923d6ceb3 100644
--- a/DartApplicationLoader.cpp
+++ b/DartApplicationLoader.cpp
@@ -86,12 +86,6 @@ void DartApplicationLoader::reportDartError(Dart_Handle error)
Dart_Handle DartApplicationLoader::libraryTagHandlerCallback(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle urlHandle)
{
ASSERT(Dart_CurrentIsolate());
- ASSERT(DartDOMData::current()->applicationLoader());
- return DartDOMData::current()->applicationLoader()->libraryTagHandler(tag, library, urlHandle);
kustermann 2013/07/10 13:50:39 (Sidenote: AFAIK the styleguide allows long lines,
-}
-
-Dart_Handle DartApplicationLoader::libraryTagHandler(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle urlHandle)
-{
ASSERT(Dart_IsLibrary(library));
const String url = DartUtilities::toString(urlHandle);
@@ -101,24 +95,38 @@ Dart_Handle DartApplicationLoader::libraryTagHandler(Dart_LibraryTag tag, Dart_H
String libraryURL = DartUtilities::toString(libraryURLHandle);
siva 2013/07/10 18:10:26 Why does this library to libraryURL translation ha
kustermann 2013/07/11 12:34:11 Done.
if (tag == Dart_kCanonicalizeUrl) {
- if (url.startsWith("dart:") || url.startsWith("package:"))
- return urlHandle;
-
- bool packageScheme = false;
- if (libraryURL.startsWith("package:")) {
- // KURL have problems concating package:foo/bar (without slashes right after colon)
- // and relative urls. Therefore pretend to be a standard absolute URL.
- packageScheme = true;
- libraryURL = "http://" + libraryURL.substring(8);
- }
+ // If a dart application calls spawnUri, the DartVM will call this
+ // libraryTagHandler to canonicalize the url.
+ // DartDOMData::current()->applicationLoader() may be NULL at this point.
+ return DartApplicationLoader::CanonicalizeUrl(urlHandle, url, libraryURL);
+ } else {
+ ASSERT(DartDOMData::current()->applicationLoader());
+ return DartDOMData::current()->applicationLoader()->libraryTagHandler(tag, urlHandle, url, libraryURL);
siva 2013/07/10 18:10:26 Similarly change the signature of libraryTagHandle
kustermann 2013/07/11 12:34:11 Done.
+ }
+}
- const KURL canonical = KURL(KURL(KURL(), libraryURL), url);
- String result = canonical.string();
- if (packageScheme)
- result = "package:" + result.substring(7);
- return DartUtilities::stringToDartString(result);
+Dart_Handle DartApplicationLoader::CanonicalizeUrl(Dart_Handle urlHandle, String url, String libraryURL)
+{
+ if (url.startsWith("dart:") || url.startsWith("package:"))
+ return urlHandle;
+
+ bool packageScheme = false;
+ if (libraryURL.startsWith("package:")) {
+ // KURL have problems concating package:foo/bar (without slashes right after colon)
siva 2013/07/10 18:10:26 KURL has problems......
kustermann 2013/07/11 12:34:11 Done.
+ // and relative urls. Therefore pretend to be a standard absolute URL.
+ packageScheme = true;
+ libraryURL = "http://" + libraryURL.substring(8);
siva 2013/07/10 18:10:26 These magic numbers 8, 7 etc. make me uncomfortabl
kustermann 2013/07/11 12:34:11 Done.
}
+ const KURL canonical = KURL(KURL(KURL(), libraryURL), url);
+ String result = canonical.string();
+ if (packageScheme)
+ result = "package:" + result.substring(7);
+ return DartUtilities::stringToDartString(result);
+}
+
+Dart_Handle DartApplicationLoader::libraryTagHandler(Dart_LibraryTag tag, Dart_Handle urlHandle, String url, String libraryURL)
+{
ASSERT(url != "dart:html");
// Record the importer.
« no previous file with comments | « DartApplicationLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698