| 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) 2014, Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2014, 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 void NavigatorContentUtils::registerProtocolHandler( | 140 void NavigatorContentUtils::registerProtocolHandler( |
| 141 Navigator& navigator, | 141 Navigator& navigator, |
| 142 const String& scheme, | 142 const String& scheme, |
| 143 const String& url, | 143 const String& url, |
| 144 const String& title, | 144 const String& title, |
| 145 ExceptionState& exception_state) { | 145 ExceptionState& exception_state) { |
| 146 if (!navigator.GetFrame()) | 146 if (!navigator.GetFrame()) |
| 147 return; | 147 return; |
| 148 | 148 |
| 149 Document* document = navigator.GetFrame()->GetDocument(); | 149 Document* document = navigator.GetFrame()->GetDocument(); |
| 150 ASSERT(document); | 150 DCHECK(document); |
| 151 | 151 |
| 152 if (!VerifyCustomHandlerURL(*document, url, exception_state)) | 152 if (!VerifyCustomHandlerURL(*document, url, exception_state)) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 if (!VerifyCustomHandlerScheme(scheme, exception_state)) | 155 if (!VerifyCustomHandlerScheme(scheme, exception_state)) |
| 156 return; | 156 return; |
| 157 | 157 |
| 158 // Count usage; perhaps we can lock this to secure contexts. | 158 // Count usage; perhaps we can lock this to secure contexts. |
| 159 UseCounter::Count(*document, | 159 UseCounter::Count(*document, |
| 160 document->IsSecureContext() | 160 document->IsSecureContext() |
| (...skipping 27 matching lines...) Expand all Loading... |
| 188 Navigator& navigator, | 188 Navigator& navigator, |
| 189 const String& scheme, | 189 const String& scheme, |
| 190 const String& url, | 190 const String& url, |
| 191 ExceptionState& exception_state) { | 191 ExceptionState& exception_state) { |
| 192 DEFINE_STATIC_LOCAL(const String, declined, ("declined")); | 192 DEFINE_STATIC_LOCAL(const String, declined, ("declined")); |
| 193 | 193 |
| 194 if (!navigator.GetFrame()) | 194 if (!navigator.GetFrame()) |
| 195 return declined; | 195 return declined; |
| 196 | 196 |
| 197 Document* document = navigator.GetFrame()->GetDocument(); | 197 Document* document = navigator.GetFrame()->GetDocument(); |
| 198 ASSERT(document); | 198 DCHECK(document); |
| 199 if (document->IsContextDestroyed()) | 199 if (document->IsContextDestroyed()) |
| 200 return declined; | 200 return declined; |
| 201 | 201 |
| 202 if (!VerifyCustomHandlerURL(*document, url, exception_state)) | 202 if (!VerifyCustomHandlerURL(*document, url, exception_state)) |
| 203 return declined; | 203 return declined; |
| 204 | 204 |
| 205 if (!VerifyCustomHandlerScheme(scheme, exception_state)) | 205 if (!VerifyCustomHandlerScheme(scheme, exception_state)) |
| 206 return declined; | 206 return declined; |
| 207 | 207 |
| 208 return CustomHandlersStateString( | 208 return CustomHandlersStateString( |
| 209 NavigatorContentUtils::From(navigator) | 209 NavigatorContentUtils::From(navigator) |
| 210 ->Client() | 210 ->Client() |
| 211 ->IsProtocolHandlerRegistered(scheme, document->CompleteURL(url))); | 211 ->IsProtocolHandlerRegistered(scheme, document->CompleteURL(url))); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void NavigatorContentUtils::unregisterProtocolHandler( | 214 void NavigatorContentUtils::unregisterProtocolHandler( |
| 215 Navigator& navigator, | 215 Navigator& navigator, |
| 216 const String& scheme, | 216 const String& scheme, |
| 217 const String& url, | 217 const String& url, |
| 218 ExceptionState& exception_state) { | 218 ExceptionState& exception_state) { |
| 219 if (!navigator.GetFrame()) | 219 if (!navigator.GetFrame()) |
| 220 return; | 220 return; |
| 221 | 221 |
| 222 Document* document = navigator.GetFrame()->GetDocument(); | 222 Document* document = navigator.GetFrame()->GetDocument(); |
| 223 ASSERT(document); | 223 DCHECK(document); |
| 224 | 224 |
| 225 if (!VerifyCustomHandlerURL(*document, url, exception_state)) | 225 if (!VerifyCustomHandlerURL(*document, url, exception_state)) |
| 226 return; | 226 return; |
| 227 | 227 |
| 228 if (!VerifyCustomHandlerScheme(scheme, exception_state)) | 228 if (!VerifyCustomHandlerScheme(scheme, exception_state)) |
| 229 return; | 229 return; |
| 230 | 230 |
| 231 NavigatorContentUtils::From(navigator)->Client()->UnregisterProtocolHandler( | 231 NavigatorContentUtils::From(navigator)->Client()->UnregisterProtocolHandler( |
| 232 scheme, document->CompleteURL(url)); | 232 scheme, document->CompleteURL(url)); |
| 233 } | 233 } |
| 234 | 234 |
| 235 DEFINE_TRACE(NavigatorContentUtils) { | 235 DEFINE_TRACE(NavigatorContentUtils) { |
| 236 visitor->Trace(client_); | 236 visitor->Trace(client_); |
| 237 Supplement<Navigator>::Trace(visitor); | 237 Supplement<Navigator>::Trace(visitor); |
| 238 } | 238 } |
| 239 | 239 |
| 240 const char* NavigatorContentUtils::SupplementName() { | 240 const char* NavigatorContentUtils::SupplementName() { |
| 241 return "NavigatorContentUtils"; | 241 return "NavigatorContentUtils"; |
| 242 } | 242 } |
| 243 | 243 |
| 244 void NavigatorContentUtils::ProvideTo(Navigator& navigator, | 244 void NavigatorContentUtils::ProvideTo(Navigator& navigator, |
| 245 NavigatorContentUtilsClient* client) { | 245 NavigatorContentUtilsClient* client) { |
| 246 Supplement<Navigator>::ProvideTo( | 246 Supplement<Navigator>::ProvideTo( |
| 247 navigator, NavigatorContentUtils::SupplementName(), | 247 navigator, NavigatorContentUtils::SupplementName(), |
| 248 new NavigatorContentUtils(navigator, client)); | 248 new NavigatorContentUtils(navigator, client)); |
| 249 } | 249 } |
| 250 | 250 |
| 251 } // namespace blink | 251 } // namespace blink |
| OLD | NEW |