OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/permissions_updater.h" | 5 #include "chrome/browser/extensions/permissions_updater.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" | 10 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" |
11 #include "chrome/browser/extensions/event_router.h" | 11 #include "chrome/browser/extensions/event_router.h" |
12 #include "chrome/browser/extensions/extension_prefs.h" | 12 #include "chrome/browser/extensions/extension_prefs.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/extension_system.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/signin/token_service.h" | 16 #include "chrome/browser/signin/token_service.h" |
16 #include "chrome/browser/signin/token_service_factory.h" | 17 #include "chrome/browser/signin/token_service_factory.h" |
17 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/extensions/api/permissions.h" | 19 #include "chrome/common/extensions/api/permissions.h" |
19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/extensions/extension_messages.h" | 21 #include "chrome/common/extensions/extension_messages.h" |
21 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 void PermissionsUpdater::UpdateActivePermissions( | 160 void PermissionsUpdater::UpdateActivePermissions( |
160 const Extension* extension, const PermissionSet* permissions) { | 161 const Extension* extension, const PermissionSet* permissions) { |
161 GetExtensionPrefs()->SetActivePermissions(extension->id(), permissions); | 162 GetExtensionPrefs()->SetActivePermissions(extension->id(), permissions); |
162 extension->SetActivePermissions(permissions); | 163 extension->SetActivePermissions(permissions); |
163 } | 164 } |
164 | 165 |
165 void PermissionsUpdater::DispatchEvent( | 166 void PermissionsUpdater::DispatchEvent( |
166 const std::string& extension_id, | 167 const std::string& extension_id, |
167 const char* event_name, | 168 const char* event_name, |
168 const PermissionSet* changed_permissions) { | 169 const PermissionSet* changed_permissions) { |
169 if (!profile_ || !profile_->GetExtensionEventRouter()) | 170 if (!profile_ || |
| 171 !extensions::ExtensionSystem::Get(profile_)->event_router()) |
170 return; | 172 return; |
171 | 173 |
172 scoped_ptr<ListValue> value(new ListValue()); | 174 scoped_ptr<ListValue> value(new ListValue()); |
173 scoped_ptr<api::permissions::Permissions> permissions = | 175 scoped_ptr<api::permissions::Permissions> permissions = |
174 PackPermissionSet(changed_permissions); | 176 PackPermissionSet(changed_permissions); |
175 value->Append(permissions->ToValue().release()); | 177 value->Append(permissions->ToValue().release()); |
176 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 178 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
177 extension_id, event_name, value.Pass(), profile_, GURL()); | 179 DispatchEventToExtension(extension_id, event_name, value.Pass(), |
| 180 profile_, GURL()); |
178 } | 181 } |
179 | 182 |
180 void PermissionsUpdater::NotifyPermissionsUpdated( | 183 void PermissionsUpdater::NotifyPermissionsUpdated( |
181 EventType event_type, | 184 EventType event_type, |
182 const Extension* extension, | 185 const Extension* extension, |
183 const PermissionSet* changed) { | 186 const PermissionSet* changed) { |
184 if (!changed || changed->IsEmpty()) | 187 if (!changed || changed->IsEmpty()) |
185 return; | 188 return; |
186 | 189 |
187 UpdatedExtensionPermissionsInfo::Reason reason; | 190 UpdatedExtensionPermissionsInfo::Reason reason; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 223 |
221 // Trigger the onAdded and onRemoved events in the extension. | 224 // Trigger the onAdded and onRemoved events in the extension. |
222 DispatchEvent(extension->id(), event_name, changed); | 225 DispatchEvent(extension->id(), event_name, changed); |
223 } | 226 } |
224 | 227 |
225 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { | 228 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { |
226 return profile_->GetExtensionService()->extension_prefs(); | 229 return profile_->GetExtensionService()->extension_prefs(); |
227 } | 230 } |
228 | 231 |
229 } // namespace extensions | 232 } // namespace extensions |
OLD | NEW |