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