1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "config.h" 6 7 #include "public/platform/WebPermissionCallbacks.h" 8 9 #include "platform/PermissionCallbacks.h" 10 11 namespace blink { 12 13 class WebPermissionCallbacksPrivate : public RefCounted<WebPermissionCallbacksPrivate> { 14 public: 15 static PassRefPtr<WebPermissionCallbacksPrivate> create(const PassOwnPtr<PermissionCallbacks>& callbacks) 16 { 17 return adoptRef(new WebPermissionCallbacksPrivate(callbacks)); 18 } 19 20 PermissionCallbacks* callbacks() { return m_callbacks.get(); } 21 22 private: 23 WebPermissionCallbacksPrivate(const PassOwnPtr<PermissionCallbacks>& callbacks) : m_callbacks(callbacks) { } 24 OwnPtr<PermissionCallbacks> m_callbacks; 25 }; 26 27 WebPermissionCallbacks::WebPermissionCallbacks(const PassOwnPtr<PermissionCallbacks>& callbacks) 28 { 29 m_private = WebPermissionCallbacksPrivate::create(callbacks); 30 } 31 32 void WebPermissionCallbacks::reset() 33 { 34 m_private.reset(); 35 } 36 37 void WebPermissionCallbacks::assign(const WebPermissionCallbacks& other) 38 { 39 m_private = other.m_private; 40 } 41 42 void WebPermissionCallbacks::doAllow() 43 { 44 ASSERT(!m_private.isNull()); 45 m_private->callbacks()->onAllowed(); 46 m_private.reset(); 47 } 48 49 void WebPermissionCallbacks::doDeny() 50 { 51 ASSERT(!m_private.isNull()); 52 m_private->callbacks()->onDenied(); 53 m_private.reset(); 54 } 55 56 } // namespace blink 57