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" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 const char* event_name, | 95 const char* event_name, |
96 const ExtensionPermissionSet* changed_permissions) { | 96 const ExtensionPermissionSet* changed_permissions) { |
97 if (!profile_ || !profile_->GetExtensionEventRouter()) | 97 if (!profile_ || !profile_->GetExtensionEventRouter()) |
98 return; | 98 return; |
99 | 99 |
100 ListValue value; | 100 ListValue value; |
101 scoped_ptr<api::permissions::Permissions> permissions = | 101 scoped_ptr<api::permissions::Permissions> permissions = |
102 PackPermissionSet(changed_permissions); | 102 PackPermissionSet(changed_permissions); |
103 value.Append(permissions->ToValue().release()); | 103 value.Append(permissions->ToValue().release()); |
104 std::string json_value; | 104 std::string json_value; |
105 base::JSONWriter::Write(&value, false, &json_value); | 105 base::JSONWriter::Write(&value, &json_value); |
106 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 106 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
107 extension_id, event_name, json_value, profile_, GURL()); | 107 extension_id, event_name, json_value, profile_, GURL()); |
108 } | 108 } |
109 | 109 |
110 void PermissionsUpdater::NotifyPermissionsUpdated( | 110 void PermissionsUpdater::NotifyPermissionsUpdated( |
111 EventType event_type, | 111 EventType event_type, |
112 const Extension* extension, | 112 const Extension* extension, |
113 const ExtensionPermissionSet* changed) { | 113 const ExtensionPermissionSet* changed) { |
114 if (!changed || changed->IsEmpty()) | 114 if (!changed || changed->IsEmpty()) |
115 return; | 115 return; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 // Trigger the onAdded and onRemoved events in the extension. | 151 // Trigger the onAdded and onRemoved events in the extension. |
152 DispatchEvent(extension->id(), event_name, changed); | 152 DispatchEvent(extension->id(), event_name, changed); |
153 } | 153 } |
154 | 154 |
155 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { | 155 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { |
156 return profile_->GetExtensionService()->extension_prefs(); | 156 return profile_->GetExtensionService()->extension_prefs(); |
157 } | 157 } |
158 | 158 |
159 } // namespace extensions | 159 } // namespace extensions |
OLD | NEW |