| 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 "chrome/browser/notifications/notifier_state_tracker.h" | 5 #include "chrome/browser/notifications/notifier_state_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 SetNotifierEnabled(notifier_id, true); | 170 SetNotifierEnabled(notifier_id, true); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void NotifierStateTracker::FirePermissionLevelChangedEvent( | 173 void NotifierStateTracker::FirePermissionLevelChangedEvent( |
| 174 const NotifierId& notifier_id, bool enabled) { | 174 const NotifierId& notifier_id, bool enabled) { |
| 175 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); | 175 DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); |
| 176 extensions::api::notifications::PermissionLevel permission = | 176 extensions::api::notifications::PermissionLevel permission = |
| 177 enabled ? extensions::api::notifications::PERMISSION_LEVEL_GRANTED | 177 enabled ? extensions::api::notifications::PERMISSION_LEVEL_GRANTED |
| 178 : extensions::api::notifications::PERMISSION_LEVEL_DENIED; | 178 : extensions::api::notifications::PERMISSION_LEVEL_DENIED; |
| 179 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 179 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 180 args->Append(new base::StringValue( | 180 args->AppendString(extensions::api::notifications::ToString(permission)); |
| 181 extensions::api::notifications::ToString(permission))); | |
| 182 std::unique_ptr<extensions::Event> event(new extensions::Event( | 181 std::unique_ptr<extensions::Event> event(new extensions::Event( |
| 183 extensions::events::NOTIFICATIONS_ON_PERMISSION_LEVEL_CHANGED, | 182 extensions::events::NOTIFICATIONS_ON_PERMISSION_LEVEL_CHANGED, |
| 184 extensions::api::notifications::OnPermissionLevelChanged::kEventName, | 183 extensions::api::notifications::OnPermissionLevelChanged::kEventName, |
| 185 std::move(args))); | 184 std::move(args))); |
| 186 extensions::EventRouter::Get(profile_) | 185 extensions::EventRouter::Get(profile_) |
| 187 ->DispatchEventToExtension(notifier_id.id, std::move(event)); | 186 ->DispatchEventToExtension(notifier_id.id, std::move(event)); |
| 188 | 187 |
| 189 // Tell the IO thread that this extension's permission for notifications | 188 // Tell the IO thread that this extension's permission for notifications |
| 190 // has changed. | 189 // has changed. |
| 191 extensions::InfoMap* extension_info_map = | 190 extensions::InfoMap* extension_info_map = |
| 192 extensions::ExtensionSystem::Get(profile_)->info_map(); | 191 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 193 content::BrowserThread::PostTask( | 192 content::BrowserThread::PostTask( |
| 194 content::BrowserThread::IO, FROM_HERE, | 193 content::BrowserThread::IO, FROM_HERE, |
| 195 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 194 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 196 extension_info_map, notifier_id.id, !enabled)); | 195 extension_info_map, notifier_id.id, !enabled)); |
| 197 } | 196 } |
| 198 #endif | 197 #endif |
| OLD | NEW |