• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 using namespace WebCore;
12 
13 namespace blink {
14 
15 class WebPermissionCallbacksPrivate : public RefCounted<WebPermissionCallbacksPrivate> {
16 public:
create(const PassOwnPtr<PermissionCallbacks> & callbacks)17     static PassRefPtr<WebPermissionCallbacksPrivate> create(const PassOwnPtr<PermissionCallbacks>& callbacks)
18     {
19         return adoptRef(new WebPermissionCallbacksPrivate(callbacks));
20     }
21 
callbacks()22     PermissionCallbacks* callbacks() { return m_callbacks.get(); }
23 
24 private:
WebPermissionCallbacksPrivate(const PassOwnPtr<PermissionCallbacks> & callbacks)25     WebPermissionCallbacksPrivate(const PassOwnPtr<PermissionCallbacks>& callbacks) : m_callbacks(callbacks) { }
26     OwnPtr<PermissionCallbacks> m_callbacks;
27 };
28 
WebPermissionCallbacks(const PassOwnPtr<PermissionCallbacks> & callbacks)29 WebPermissionCallbacks::WebPermissionCallbacks(const PassOwnPtr<PermissionCallbacks>& callbacks)
30 {
31     m_private = WebPermissionCallbacksPrivate::create(callbacks);
32 }
33 
reset()34 void WebPermissionCallbacks::reset()
35 {
36     m_private.reset();
37 }
38 
assign(const WebPermissionCallbacks & other)39 void WebPermissionCallbacks::assign(const WebPermissionCallbacks& other)
40 {
41     m_private = other.m_private;
42 }
43 
doAllow()44 void WebPermissionCallbacks::doAllow()
45 {
46     ASSERT(!m_private.isNull());
47     m_private->callbacks()->onAllowed();
48     m_private.reset();
49 }
50 
doDeny()51 void WebPermissionCallbacks::doDeny()
52 {
53     ASSERT(!m_private.isNull());
54     m_private->callbacks()->onDenied();
55     m_private.reset();
56 }
57 
58 } // namespace blink
59