Chromium Code Reviews| 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 "content/shell/browser/layout_test/layout_test_permission_manager.h" | 5 #include "content/shell/browser/layout_test/layout_test_permission_manager.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <memory> | |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/permission_type.h" | 13 #include "content/public/browser/permission_type.h" |
| 13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 14 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h " | 15 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h " |
| 15 #include "content/shell/browser/layout_test/layout_test_notification_manager.h" | 16 #include "content/shell/browser/layout_test/layout_test_notification_manager.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 141 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 141 } | 142 } |
| 142 | 143 |
| 143 int LayoutTestPermissionManager::SubscribePermissionStatusChange( | 144 int LayoutTestPermissionManager::SubscribePermissionStatusChange( |
| 144 PermissionType permission, | 145 PermissionType permission, |
| 145 const GURL& requesting_origin, | 146 const GURL& requesting_origin, |
| 146 const GURL& embedding_origin, | 147 const GURL& embedding_origin, |
| 147 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { | 148 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { |
| 148 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 149 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 149 | 150 |
| 150 Subscription* subscription = new Subscription(); | 151 std::unique_ptr<Subscription> subscription = base::MakeUnique<Subscription>(); |
|
danakj
2016/11/18 00:15:34
"auto subscription" .. if u want
| |
| 151 subscription->permission = | 152 subscription->permission = |
| 152 PermissionDescription(permission, requesting_origin, embedding_origin); | 153 PermissionDescription(permission, requesting_origin, embedding_origin); |
| 153 subscription->callback = callback; | 154 subscription->callback = callback; |
| 154 subscription->current_value = | 155 subscription->current_value = |
| 155 GetPermissionStatus(permission, | 156 GetPermissionStatus(permission, |
| 156 subscription->permission.origin, | 157 subscription->permission.origin, |
| 157 subscription->permission.embedding_origin); | 158 subscription->permission.embedding_origin); |
| 158 | 159 |
| 159 return subscriptions_.Add(subscription); | 160 return subscriptions_.Add(std::move(subscription)); |
| 160 } | 161 } |
| 161 | 162 |
| 162 void LayoutTestPermissionManager::UnsubscribePermissionStatusChange( | 163 void LayoutTestPermissionManager::UnsubscribePermissionStatusChange( |
| 163 int subscription_id) { | 164 int subscription_id) { |
| 164 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 165 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 165 | 166 |
| 166 // Whether |subscription_id| is known will be checked by the Remove() call. | 167 // Whether |subscription_id| is known will be checked by the Remove() call. |
| 167 subscriptions_.Remove(subscription_id); | 168 subscriptions_.Remove(subscription_id); |
| 168 } | 169 } |
| 169 | 170 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 // Add the callback to |callbacks| which will be run after the loop to | 217 // Add the callback to |callbacks| which will be run after the loop to |
| 217 // prevent re-entrance issues. | 218 // prevent re-entrance issues. |
| 218 callbacks.push_back(base::Bind(subscription->callback, status)); | 219 callbacks.push_back(base::Bind(subscription->callback, status)); |
| 219 } | 220 } |
| 220 | 221 |
| 221 for (const auto& callback : callbacks) | 222 for (const auto& callback : callbacks) |
| 222 callback.Run(); | 223 callback.Run(); |
| 223 } | 224 } |
| 224 | 225 |
| 225 } // namespace content | 226 } // namespace content |
| OLD | NEW |