| 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/StdLibExtras.h" |
| 32 | 33 |
| 33 namespace blink { | 34 namespace blink { |
| 34 | 35 |
| 35 PassOwnPtr<ContextFeaturesClient> ContextFeaturesClient::empty() | 36 PassOwnPtr<ContextFeaturesClient> ContextFeaturesClient::empty() |
| 36 { | 37 { |
| 37 return adoptPtr(new ContextFeaturesClient()); | 38 return adoptPtr(new ContextFeaturesClient()); |
| 38 } | 39 } |
| 39 | 40 |
| 40 const char* ContextFeatures::supplementName() | 41 const char* ContextFeatures::supplementName() |
| 41 { | 42 { |
| 42 return "ContextFeatures"; | 43 return "ContextFeatures"; |
| 43 } | 44 } |
| 44 | 45 |
| 45 ContextFeatures* ContextFeatures::defaultSwitch() | 46 ContextFeatures& ContextFeatures::defaultSwitch() |
| 46 { | 47 { |
| 47 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(ContextFeatures, instance, (ContextFeat
ures::create(ContextFeaturesClient::empty()))); | 48 DEFINE_STATIC_LOCAL(ContextFeatures, instance, (ContextFeatures::create(Cont
extFeaturesClient::empty()))); |
| 48 return instance; | 49 return instance; |
| 49 } | 50 } |
| 50 | 51 |
| 51 bool ContextFeatures::pagePopupEnabled(Document* document) | 52 bool ContextFeatures::pagePopupEnabled(Document* document) |
| 52 { | 53 { |
| 53 if (!document) | 54 if (!document) |
| 54 return false; | 55 return false; |
| 55 return document->contextFeatures().isEnabled(document, PagePopup, false); | 56 return document->contextFeatures().isEnabled(document, PagePopup, false); |
| 56 } | 57 } |
| 57 | 58 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 70 | 71 |
| 71 void provideContextFeaturesToDocumentFrom(Document& document, Page& page) | 72 void provideContextFeaturesToDocumentFrom(Document& document, Page& page) |
| 72 { | 73 { |
| 73 ContextFeatures* provided = static_cast<ContextFeatures*>(Supplement<Page>::
from(page, ContextFeatures::supplementName())); | 74 ContextFeatures* provided = static_cast<ContextFeatures*>(Supplement<Page>::
from(page, ContextFeatures::supplementName())); |
| 74 if (!provided) | 75 if (!provided) |
| 75 return; | 76 return; |
| 76 document.setContextFeatures(*provided); | 77 document.setContextFeatures(*provided); |
| 77 } | 78 } |
| 78 | 79 |
| 79 } // namespace blink | 80 } // namespace blink |
| OLD | NEW |