| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012, Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2012, Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 "urn", | 60 "urn", |
| 61 "webcal", | 61 "webcal", |
| 62 "xmpp", | 62 "xmpp", |
| 63 }; | 63 }; |
| 64 for (size_t i = 0; i < WTF_ARRAY_LENGTH(protocols); ++i) | 64 for (size_t i = 0; i < WTF_ARRAY_LENGTH(protocols); ++i) |
| 65 protocolWhitelist->add(protocols[i]); | 65 protocolWhitelist->add(protocols[i]); |
| 66 } | 66 } |
| 67 | 67 |
| 68 static bool verifyCustomHandlerURL(const String& baseURL, const String& url, Exc
eptionCode& ec) | 68 static bool verifyCustomHandlerURL(const String& baseURL, const String& url, Exc
eptionCode& ec) |
| 69 { | 69 { |
| 70 // The specification requires that it is a SYNTAX_ERR if the "%s" token is | 70 // The specification requires that it is a SyntaxError if the "%s" token is |
| 71 // not present. | 71 // not present. |
| 72 static const char token[] = "%s"; | 72 static const char token[] = "%s"; |
| 73 int index = url.find(token); | 73 int index = url.find(token); |
| 74 if (-1 == index) { | 74 if (-1 == index) { |
| 75 ec = SYNTAX_ERR; | 75 ec = SyntaxError; |
| 76 return false; | 76 return false; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // It is also a SYNTAX_ERR if the custom handler URL, as created by removing | 79 // It is also a SyntaxError if the custom handler URL, as created by removin
g |
| 80 // the "%s" token and prepending the base url, does not resolve. | 80 // the "%s" token and prepending the base url, does not resolve. |
| 81 String newURL = url; | 81 String newURL = url; |
| 82 newURL.remove(index, WTF_ARRAY_LENGTH(token) - 1); | 82 newURL.remove(index, WTF_ARRAY_LENGTH(token) - 1); |
| 83 | 83 |
| 84 KURL base(ParsedURLString, baseURL); | 84 KURL base(ParsedURLString, baseURL); |
| 85 KURL kurl(base, newURL); | 85 KURL kurl(base, newURL); |
| 86 | 86 |
| 87 if (kurl.isEmpty() || !kurl.isValid()) { | 87 if (kurl.isEmpty() || !kurl.isValid()) { |
| 88 ec = SYNTAX_ERR; | 88 ec = SyntaxError; |
| 89 return false; | 89 return false; |
| 90 } | 90 } |
| 91 | 91 |
| 92 return true; | 92 return true; |
| 93 } | 93 } |
| 94 | 94 |
| 95 static bool isProtocolWhitelisted(const String& scheme) | 95 static bool isProtocolWhitelisted(const String& scheme) |
| 96 { | 96 { |
| 97 if (!protocolWhitelist) | 97 if (!protocolWhitelist) |
| 98 initProtocolHandlerWhitelist(); | 98 initProtocolHandlerWhitelist(); |
| 99 return protocolWhitelist->contains(scheme); | 99 return protocolWhitelist->contains(scheme); |
| 100 } | 100 } |
| 101 | 101 |
| 102 static bool verifyProtocolHandlerScheme(const String& scheme, ExceptionCode& ec) | 102 static bool verifyProtocolHandlerScheme(const String& scheme, ExceptionCode& ec) |
| 103 { | 103 { |
| 104 if (scheme.startsWith("web+")) { | 104 if (scheme.startsWith("web+")) { |
| 105 if (isValidProtocol(scheme)) | 105 if (isValidProtocol(scheme)) |
| 106 return true; | 106 return true; |
| 107 ec = SECURITY_ERR; | 107 ec = SecurityError; |
| 108 return false; | 108 return false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 if (isProtocolWhitelisted(scheme)) | 111 if (isProtocolWhitelisted(scheme)) |
| 112 return true; | 112 return true; |
| 113 ec = SECURITY_ERR; | 113 ec = SecurityError; |
| 114 return false; | 114 return false; |
| 115 } | 115 } |
| 116 | 116 |
| 117 NavigatorContentUtils* NavigatorContentUtils::from(Page* page) | 117 NavigatorContentUtils* NavigatorContentUtils::from(Page* page) |
| 118 { | 118 { |
| 119 return static_cast<NavigatorContentUtils*>(RefCountedSupplement<Page, Naviga
torContentUtils>::from(page, NavigatorContentUtils::supplementName())); | 119 return static_cast<NavigatorContentUtils*>(RefCountedSupplement<Page, Naviga
torContentUtils>::from(page, NavigatorContentUtils::supplementName())); |
| 120 } | 120 } |
| 121 | 121 |
| 122 NavigatorContentUtils::~NavigatorContentUtils() | 122 NavigatorContentUtils::~NavigatorContentUtils() |
| 123 { | 123 { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 void provideNavigatorContentUtilsTo(Page* page, NavigatorContentUtilsClient* cli
ent) | 213 void provideNavigatorContentUtilsTo(Page* page, NavigatorContentUtilsClient* cli
ent) |
| 214 { | 214 { |
| 215 RefCountedSupplement<Page, NavigatorContentUtils>::provideTo(page, Navigator
ContentUtils::supplementName(), NavigatorContentUtils::create(client)); | 215 RefCountedSupplement<Page, NavigatorContentUtils>::provideTo(page, Navigator
ContentUtils::supplementName(), NavigatorContentUtils::create(client)); |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace WebCore | 218 } // namespace WebCore |
| 219 | 219 |
| 220 #endif // ENABLE(NAVIGATOR_CONTENT_UTILS) | 220 #endif // ENABLE(NAVIGATOR_CONTENT_UTILS) |
| 221 | 221 |
| OLD | NEW |