| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/dom/ContextFeatures.h" | 27 #include "core/dom/ContextFeatures.h" |
| 28 | 28 |
| 29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
| 30 #include "core/page/Page.h" | 30 #include "core/page/Page.h" |
| 31 #include "platform/RuntimeEnabledFeatures.h" | 31 #include "platform/RuntimeEnabledFeatures.h" |
| 32 #include "wtf/PtrUtil.h" | |
| 33 #include "wtf/StdLibExtras.h" | 32 #include "wtf/StdLibExtras.h" |
| 34 #include <memory> | |
| 35 | 33 |
| 36 namespace blink { | 34 namespace blink { |
| 37 | 35 |
| 38 std::unique_ptr<ContextFeaturesClient> ContextFeaturesClient::empty() | 36 PassOwnPtr<ContextFeaturesClient> ContextFeaturesClient::empty() |
| 39 { | 37 { |
| 40 return wrapUnique(new ContextFeaturesClient()); | 38 return adoptPtr(new ContextFeaturesClient()); |
| 41 } | 39 } |
| 42 | 40 |
| 43 const char* ContextFeatures::supplementName() | 41 const char* ContextFeatures::supplementName() |
| 44 { | 42 { |
| 45 return "ContextFeatures"; | 43 return "ContextFeatures"; |
| 46 } | 44 } |
| 47 | 45 |
| 48 ContextFeatures& ContextFeatures::defaultSwitch() | 46 ContextFeatures& ContextFeatures::defaultSwitch() |
| 49 { | 47 { |
| 50 DEFINE_STATIC_LOCAL(ContextFeatures, instance, (ContextFeatures::create(Cont
extFeaturesClient::empty()))); | 48 DEFINE_STATIC_LOCAL(ContextFeatures, instance, (ContextFeatures::create(Cont
extFeaturesClient::empty()))); |
| 51 return instance; | 49 return instance; |
| 52 } | 50 } |
| 53 | 51 |
| 54 bool ContextFeatures::pagePopupEnabled(Document* document) | 52 bool ContextFeatures::pagePopupEnabled(Document* document) |
| 55 { | 53 { |
| 56 if (!document) | 54 if (!document) |
| 57 return false; | 55 return false; |
| 58 return document->contextFeatures().isEnabled(document, PagePopup, false); | 56 return document->contextFeatures().isEnabled(document, PagePopup, false); |
| 59 } | 57 } |
| 60 | 58 |
| 61 bool ContextFeatures::mutationEventsEnabled(Document* document) | 59 bool ContextFeatures::mutationEventsEnabled(Document* document) |
| 62 { | 60 { |
| 63 DCHECK(document); | 61 DCHECK(document); |
| 64 if (!document) | 62 if (!document) |
| 65 return true; | 63 return true; |
| 66 return document->contextFeatures().isEnabled(document, MutationEvents, true)
; | 64 return document->contextFeatures().isEnabled(document, MutationEvents, true)
; |
| 67 } | 65 } |
| 68 | 66 |
| 69 void provideContextFeaturesTo(Page& page, std::unique_ptr<ContextFeaturesClient>
client) | 67 void provideContextFeaturesTo(Page& page, PassOwnPtr<ContextFeaturesClient> clie
nt) |
| 70 { | 68 { |
| 71 Supplement<Page>::provideTo(page, ContextFeatures::supplementName(), Context
Features::create(std::move(client))); | 69 Supplement<Page>::provideTo(page, ContextFeatures::supplementName(), Context
Features::create(std::move(client))); |
| 72 } | 70 } |
| 73 | 71 |
| 74 void provideContextFeaturesToDocumentFrom(Document& document, Page& page) | 72 void provideContextFeaturesToDocumentFrom(Document& document, Page& page) |
| 75 { | 73 { |
| 76 ContextFeatures* provided = static_cast<ContextFeatures*>(Supplement<Page>::
from(page, ContextFeatures::supplementName())); | 74 ContextFeatures* provided = static_cast<ContextFeatures*>(Supplement<Page>::
from(page, ContextFeatures::supplementName())); |
| 77 if (!provided) | 75 if (!provided) |
| 78 return; | 76 return; |
| 79 document.setContextFeatures(*provided); | 77 document.setContextFeatures(*provided); |
| 80 } | 78 } |
| 81 | 79 |
| 82 } // namespace blink | 80 } // namespace blink |
| OLD | NEW |