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

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

Issue 224113006: Apply OwnPtr|PassOwnPtr to member variables and arguments in ContextFeatures. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | Source/core/dom/ContextFeatures.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 30 matching lines...) Expand all
41 DialogElement = 0, 41 DialogElement = 0,
42 StyleScoped, 42 StyleScoped,
43 PagePopup, 43 PagePopup,
44 MutationEvents, 44 MutationEvents,
45 PushState, 45 PushState,
46 FeatureTypeSize // Should be the last entry. 46 FeatureTypeSize // Should be the last entry.
47 }; 47 };
48 48
49 static const char* supplementName(); 49 static const char* supplementName();
50 static ContextFeatures* defaultSwitch(); 50 static ContextFeatures* defaultSwitch();
51 static PassRefPtr<ContextFeatures> create(ContextFeaturesClient*); 51 static PassRefPtr<ContextFeatures> create(PassOwnPtr<ContextFeaturesClient>) ;
52 52
53 static bool dialogElementEnabled(Document*); 53 static bool dialogElementEnabled(Document*);
54 static bool styleScopedEnabled(Document*); 54 static bool styleScopedEnabled(Document*);
55 static bool pagePopupEnabled(Document*); 55 static bool pagePopupEnabled(Document*);
56 static bool mutationEventsEnabled(Document*); 56 static bool mutationEventsEnabled(Document*);
57 static bool pushStateEnabled(Document*); 57 static bool pushStateEnabled(Document*);
58 58
59 bool isEnabled(Document*, FeatureType, bool) const; 59 bool isEnabled(Document*, FeatureType, bool) const;
60 void urlDidChange(Document*); 60 void urlDidChange(Document*);
61 61
62 private: 62 private:
63 explicit ContextFeatures(ContextFeaturesClient* client) 63 explicit ContextFeatures(PassOwnPtr<ContextFeaturesClient> client)
64 : m_client(client) 64 : m_client(client)
65 { } 65 { }
66 66
67 virtual void hostDestroyed() OVERRIDE; 67 OwnPtr<ContextFeaturesClient> m_client;
68
69 ContextFeaturesClient* m_client;
70 }; 68 };
71 69
72 inline void ContextFeatures::hostDestroyed()
73 {
74 m_client = 0;
75 }
76
77
78 class ContextFeaturesClient { 70 class ContextFeaturesClient {
79 WTF_MAKE_FAST_ALLOCATED; 71 WTF_MAKE_FAST_ALLOCATED;
80 public: 72 public:
81 static ContextFeaturesClient* empty(); 73 static PassOwnPtr<ContextFeaturesClient> empty();
82 74
83 virtual ~ContextFeaturesClient() { } 75 virtual ~ContextFeaturesClient() { }
84 virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool default Value) { return defaultValue; } 76 virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool default Value) { return defaultValue; }
85 virtual void urlDidChange(Document*) { } 77 virtual void urlDidChange(Document*) { }
86 }; 78 };
87 79
88 void provideContextFeaturesTo(Page&, ContextFeaturesClient*); 80 void provideContextFeaturesTo(Page&, PassOwnPtr<ContextFeaturesClient>);
89 void provideContextFeaturesToDocumentFrom(Document&, Page&); 81 void provideContextFeaturesToDocumentFrom(Document&, Page&);
90 82
91 inline PassRefPtr<ContextFeatures> ContextFeatures::create(ContextFeaturesClient * client) 83 inline PassRefPtr<ContextFeatures> ContextFeatures::create(PassOwnPtr<ContextFea turesClient> client)
92 { 84 {
93 return adoptRef(new ContextFeatures(client)); 85 return adoptRef(new ContextFeatures(client));
94 } 86 }
95 87
96 inline bool ContextFeatures::isEnabled(Document* document, FeatureType type, boo l defaultValue) const 88 inline bool ContextFeatures::isEnabled(Document* document, FeatureType type, boo l defaultValue) const
97 { 89 {
98 if (!m_client) 90 if (!m_client)
99 return defaultValue; 91 return defaultValue;
100 return m_client->isEnabled(document, type, defaultValue); 92 return m_client->isEnabled(document, type, defaultValue);
101 } 93 }
102 94
103 inline void ContextFeatures::urlDidChange(Document* document) 95 inline void ContextFeatures::urlDidChange(Document* document)
104 { 96 {
105 // FIXME: The original code, commented out below, is obviously 97 // FIXME: The original code, commented out below, is obviously
106 // wrong, but the seemingly correct fix of negating the test to 98 // wrong, but the seemingly correct fix of negating the test to
107 // the more logical 'if (!m_client)' crashes the renderer. 99 // the more logical 'if (!m_client)' crashes the renderer.
108 // See issue 294180 100 // See issue 294180
109 // 101 //
110 // if (m_client) 102 // if (m_client)
111 // return; 103 // return;
112 // m_client->urlDidChange(document); 104 // m_client->urlDidChange(document);
113 } 105 }
114 106
115 } // namespace WebCore 107 } // namespace WebCore
116 108
117 #endif // ContextFeatures_h 109 #endif // ContextFeatures_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/ContextFeatures.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698