Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: third_party/WebKit/Source/core/dom/ContextFeatures.h

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
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 #ifndef ContextFeatures_h 27 #ifndef ContextFeatures_h
28 #define ContextFeatures_h 28 #define ContextFeatures_h
29 29
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/page/Page.h" 31 #include "core/page/Page.h"
32 #include "platform/heap/Handle.h" 32 #include "platform/heap/Handle.h"
33 #include <memory>
33 34
34 namespace blink { 35 namespace blink {
35 36
36 class ContextFeaturesClient; 37 class ContextFeaturesClient;
37 class Document; 38 class Document;
38 class Page; 39 class Page;
39 40
40 class ContextFeatures final : public GarbageCollectedFinalized<ContextFeatures>, public Supplement<Page> { 41 class ContextFeatures final : public GarbageCollectedFinalized<ContextFeatures>, public Supplement<Page> {
41 USING_GARBAGE_COLLECTED_MIXIN(ContextFeatures); 42 USING_GARBAGE_COLLECTED_MIXIN(ContextFeatures);
42 public: 43 public:
43 enum FeatureType { 44 enum FeatureType {
44 PagePopup = 0, 45 PagePopup = 0,
45 MutationEvents, 46 MutationEvents,
46 FeatureTypeSize // Should be the last entry. 47 FeatureTypeSize // Should be the last entry.
47 }; 48 };
48 49
49 static const char* supplementName(); 50 static const char* supplementName();
50 static ContextFeatures& defaultSwitch(); 51 static ContextFeatures& defaultSwitch();
51 static ContextFeatures* create(PassOwnPtr<ContextFeaturesClient>); 52 static ContextFeatures* create(std::unique_ptr<ContextFeaturesClient>);
52 53
53 static bool pagePopupEnabled(Document*); 54 static bool pagePopupEnabled(Document*);
54 static bool mutationEventsEnabled(Document*); 55 static bool mutationEventsEnabled(Document*);
55 56
56 bool isEnabled(Document*, FeatureType, bool) const; 57 bool isEnabled(Document*, FeatureType, bool) const;
57 void urlDidChange(Document*); 58 void urlDidChange(Document*);
58 59
59 private: 60 private:
60 explicit ContextFeatures(PassOwnPtr<ContextFeaturesClient> client) 61 explicit ContextFeatures(std::unique_ptr<ContextFeaturesClient> client)
61 : m_client(std::move(client)) 62 : m_client(std::move(client))
62 { } 63 { }
63 64
64 OwnPtr<ContextFeaturesClient> m_client; 65 std::unique_ptr<ContextFeaturesClient> m_client;
65 }; 66 };
66 67
67 class ContextFeaturesClient { 68 class ContextFeaturesClient {
68 USING_FAST_MALLOC(ContextFeaturesClient); 69 USING_FAST_MALLOC(ContextFeaturesClient);
69 public: 70 public:
70 static PassOwnPtr<ContextFeaturesClient> empty(); 71 static std::unique_ptr<ContextFeaturesClient> empty();
71 72
72 virtual ~ContextFeaturesClient() { } 73 virtual ~ContextFeaturesClient() { }
73 virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool default Value) { return defaultValue; } 74 virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool default Value) { return defaultValue; }
74 virtual void urlDidChange(Document*) { } 75 virtual void urlDidChange(Document*) { }
75 }; 76 };
76 77
77 CORE_EXPORT void provideContextFeaturesTo(Page&, PassOwnPtr<ContextFeaturesClien t>); 78 CORE_EXPORT void provideContextFeaturesTo(Page&, std::unique_ptr<ContextFeatures Client>);
78 void provideContextFeaturesToDocumentFrom(Document&, Page&); 79 void provideContextFeaturesToDocumentFrom(Document&, Page&);
79 80
80 inline ContextFeatures* ContextFeatures::create(PassOwnPtr<ContextFeaturesClient > client) 81 inline ContextFeatures* ContextFeatures::create(std::unique_ptr<ContextFeaturesC lient> client)
81 { 82 {
82 return new ContextFeatures(std::move(client)); 83 return new ContextFeatures(std::move(client));
83 } 84 }
84 85
85 inline bool ContextFeatures::isEnabled(Document* document, FeatureType type, boo l defaultValue) const 86 inline bool ContextFeatures::isEnabled(Document* document, FeatureType type, boo l defaultValue) const
86 { 87 {
87 if (!m_client) 88 if (!m_client)
88 return defaultValue; 89 return defaultValue;
89 return m_client->isEnabled(document, type, defaultValue); 90 return m_client->isEnabled(document, type, defaultValue);
90 } 91 }
91 92
92 inline void ContextFeatures::urlDidChange(Document* document) 93 inline void ContextFeatures::urlDidChange(Document* document)
93 { 94 {
94 // FIXME: The original code, commented out below, is obviously 95 // FIXME: The original code, commented out below, is obviously
95 // wrong, but the seemingly correct fix of negating the test to 96 // wrong, but the seemingly correct fix of negating the test to
96 // the more logical 'if (!m_client)' crashes the renderer. 97 // the more logical 'if (!m_client)' crashes the renderer.
97 // See issue 294180 98 // See issue 294180
98 // 99 //
99 // if (m_client) 100 // if (m_client)
100 // return; 101 // return;
101 // m_client->urlDidChange(document); 102 // m_client->urlDidChange(document);
102 } 103 }
103 104
104 } // namespace blink 105 } // namespace blink
105 106
106 #endif // ContextFeatures_h 107 #endif // ContextFeatures_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ContainerNode.h ('k') | third_party/WebKit/Source/core/dom/ContextFeatures.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698