 Chromium Code Reviews
 Chromium Code Reviews Issue 23570006:
  Refactoring: Add convenience method toPluginContainerImpl.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 23570006:
  Refactoring: Add convenience method toPluginContainerImpl.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| Index: Source/web/WebPluginContainerImpl.h | 
| diff --git a/Source/web/WebPluginContainerImpl.h b/Source/web/WebPluginContainerImpl.h | 
| index 5ecc64f243310669c3ffa7dfb7622e08ddda9ff7..36b97fae2ff55d710fee11c71cbcff6ed7a36e44 100644 | 
| --- a/Source/web/WebPluginContainerImpl.h | 
| +++ b/Source/web/WebPluginContainerImpl.h | 
| @@ -53,6 +53,7 @@ class ResourceError; | 
| class ResourceResponse; | 
| class TouchEvent; | 
| class WheelEvent; | 
| +class Widget; | 
| } | 
| namespace WebKit { | 
| @@ -197,6 +198,25 @@ private: | 
| bool m_wantsWheelEvents; | 
| }; | 
| +inline WebPluginContainerImpl* toPluginContainerImpl(WebCore::Widget* widget) | 
| +{ | 
| + ASSERT_WITH_SECURITY_IMPLICATION(!widget || widget->isPluginContainer()); | 
| + // We need to ensure that the object is actually of type PluginContainer | 
| + // as many childs will be of type Widget. | 
| 
tkent
2013/09/03 12:59:33
childs -> children, subclasses, or something?
 | 
| + return static_cast<WebPluginContainerImpl*>(widget); | 
| +} | 
| + | 
| +inline WebPluginContainerImpl* toPluginContainerImpl(WebPluginContainer* container) | 
| +{ | 
| + ASSERT_WITH_SECURITY_IMPLICATION(!container); | 
| 
tkent
2013/09/03 12:59:33
This assertion is wrong.
- Nullness doesn't have
 | 
| + // Unlike Widget, we need not worry about object type for container. | 
| + // WebPluginContainerImpl is the only child of WebPluginContainer. | 
| + return static_cast<WebPluginContainerImpl*>(container); | 
| +} | 
| + | 
| +// This will catch anyone doing an unnecessary cast. | 
| +void toPluginContainerImpl(const WebPluginContainerImpl*); | 
| + | 
| } // namespace WebKit | 
| #endif |