| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 typedef RefCountedSupplement<Page, ContextFeatures> SupplementType; | 48 typedef RefCountedSupplement<Page, ContextFeatures> SupplementType; |
| 49 #endif | 49 #endif |
| 50 enum FeatureType { | 50 enum FeatureType { |
| 51 PagePopup = 0, | 51 PagePopup = 0, |
| 52 MutationEvents, | 52 MutationEvents, |
| 53 FeatureTypeSize // Should be the last entry. | 53 FeatureTypeSize // Should be the last entry. |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 static const char* supplementName(); | 56 static const char* supplementName(); |
| 57 static ContextFeatures* defaultSwitch(); | 57 static ContextFeatures* defaultSwitch(); |
| 58 static PassRefPtrWillBeRawPtr<ContextFeatures> create(PassOwnPtr<ContextFeat
uresClient>); | 58 static RawPtr<ContextFeatures> create(PassOwnPtr<ContextFeaturesClient>); |
| 59 | 59 |
| 60 static bool pagePopupEnabled(Document*); | 60 static bool pagePopupEnabled(Document*); |
| 61 static bool mutationEventsEnabled(Document*); | 61 static bool mutationEventsEnabled(Document*); |
| 62 | 62 |
| 63 bool isEnabled(Document*, FeatureType, bool) const; | 63 bool isEnabled(Document*, FeatureType, bool) const; |
| 64 void urlDidChange(Document*); | 64 void urlDidChange(Document*); |
| 65 | 65 |
| 66 #if ENABLE(OILPAN) | 66 #if ENABLE(OILPAN) |
| 67 DEFINE_INLINE_VIRTUAL_TRACE() { HeapSupplement<Page>::trace(visitor); } | 67 DEFINE_INLINE_VIRTUAL_TRACE() { HeapSupplement<Page>::trace(visitor); } |
| 68 #endif | 68 #endif |
| (...skipping 12 matching lines...) Expand all Loading... |
| 81 static PassOwnPtr<ContextFeaturesClient> empty(); | 81 static PassOwnPtr<ContextFeaturesClient> empty(); |
| 82 | 82 |
| 83 virtual ~ContextFeaturesClient() { } | 83 virtual ~ContextFeaturesClient() { } |
| 84 virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool default
Value) { return defaultValue; } | 84 virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool default
Value) { return defaultValue; } |
| 85 virtual void urlDidChange(Document*) { } | 85 virtual void urlDidChange(Document*) { } |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 CORE_EXPORT void provideContextFeaturesTo(Page&, PassOwnPtr<ContextFeaturesClien
t>); | 88 CORE_EXPORT void provideContextFeaturesTo(Page&, PassOwnPtr<ContextFeaturesClien
t>); |
| 89 void provideContextFeaturesToDocumentFrom(Document&, Page&); | 89 void provideContextFeaturesToDocumentFrom(Document&, Page&); |
| 90 | 90 |
| 91 inline PassRefPtrWillBeRawPtr<ContextFeatures> ContextFeatures::create(PassOwnPt
r<ContextFeaturesClient> client) | 91 inline RawPtr<ContextFeatures> ContextFeatures::create(PassOwnPtr<ContextFeature
sClient> client) |
| 92 { | 92 { |
| 93 return adoptRefWillBeNoop(new ContextFeatures(std::move(client))); | 93 return (new ContextFeatures(std::move(client))); |
| 94 } | 94 } |
| 95 | 95 |
| 96 inline bool ContextFeatures::isEnabled(Document* document, FeatureType type, boo
l defaultValue) const | 96 inline bool ContextFeatures::isEnabled(Document* document, FeatureType type, boo
l defaultValue) const |
| 97 { | 97 { |
| 98 if (!m_client) | 98 if (!m_client) |
| 99 return defaultValue; | 99 return defaultValue; |
| 100 return m_client->isEnabled(document, type, defaultValue); | 100 return m_client->isEnabled(document, type, defaultValue); |
| 101 } | 101 } |
| 102 | 102 |
| 103 inline void ContextFeatures::urlDidChange(Document* document) | 103 inline void ContextFeatures::urlDidChange(Document* document) |
| 104 { | 104 { |
| 105 // FIXME: The original code, commented out below, is obviously | 105 // FIXME: The original code, commented out below, is obviously |
| 106 // wrong, but the seemingly correct fix of negating the test to | 106 // wrong, but the seemingly correct fix of negating the test to |
| 107 // the more logical 'if (!m_client)' crashes the renderer. | 107 // the more logical 'if (!m_client)' crashes the renderer. |
| 108 // See issue 294180 | 108 // See issue 294180 |
| 109 // | 109 // |
| 110 // if (m_client) | 110 // if (m_client) |
| 111 // return; | 111 // return; |
| 112 // m_client->urlDidChange(document); | 112 // m_client->urlDidChange(document); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace blink | 115 } // namespace blink |
| 116 | 116 |
| 117 #endif // ContextFeatures_h | 117 #endif // ContextFeatures_h |
| OLD | NEW |