OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_permissions_api.h" | 5 #include "chrome/browser/extensions/extension_permissions_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_event_router.h" | 9 #include "chrome/browser/extensions/extension_event_router.h" |
10 #include "chrome/browser/extensions/extension_prefs.h" | 10 #include "chrome/browser/extensions/extension_prefs.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
15 #include "chrome/common/extensions/extension_error_utils.h" | 15 #include "chrome/common/extensions/extension_error_utils.h" |
16 #include "chrome/common/extensions/extension_messages.h" | 16 #include "chrome/common/extensions/extension_messages.h" |
17 #include "chrome/common/extensions/extension_permission_set.h" | 17 #include "chrome/common/extensions/extension_permission_set.h" |
18 #include "chrome/common/extensions/url_pattern_set.h" | 18 #include "chrome/common/extensions/url_pattern_set.h" |
19 #include "content/common/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const char kApisKey[] = "permissions"; | 24 const char kApisKey[] = "permissions"; |
25 const char kOriginsKey[] = "origins"; | 25 const char kOriginsKey[] = "origins"; |
26 | 26 |
27 const char kCantRemoveRequiredPermissionsError[] = | 27 const char kCantRemoveRequiredPermissionsError[] = |
28 "You cannot remove required permissions."; | 28 "You cannot remove required permissions."; |
29 const char kNotInOptionalPermissionsError[] = | 29 const char kNotInOptionalPermissionsError[] = |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 event_name = kOnRemoved; | 205 event_name = kOnRemoved; |
206 } else { | 206 } else { |
207 CHECK_EQ(ADDED, event_type); | 207 CHECK_EQ(ADDED, event_type); |
208 reason = UpdatedExtensionPermissionsInfo::ADDED; | 208 reason = UpdatedExtensionPermissionsInfo::ADDED; |
209 event_name = kOnAdded; | 209 event_name = kOnAdded; |
210 } | 210 } |
211 | 211 |
212 // Notify other APIs or interested parties. | 212 // Notify other APIs or interested parties. |
213 UpdatedExtensionPermissionsInfo info = UpdatedExtensionPermissionsInfo( | 213 UpdatedExtensionPermissionsInfo info = UpdatedExtensionPermissionsInfo( |
214 extension, changed, reason); | 214 extension, changed, reason); |
215 NotificationService::current()->Notify( | 215 content::NotificationService::current()->Notify( |
216 chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED, | 216 chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED, |
217 content::Source<Profile>(extension_service_->profile()), | 217 content::Source<Profile>(extension_service_->profile()), |
218 content::Details<UpdatedExtensionPermissionsInfo>(&info)); | 218 content::Details<UpdatedExtensionPermissionsInfo>(&info)); |
219 | 219 |
220 // Send the new permissions to the renderers. | 220 // Send the new permissions to the renderers. |
221 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 221 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
222 !i.IsAtEnd(); i.Advance()) { | 222 !i.IsAtEnd(); i.Advance()) { |
223 RenderProcessHost* host = i.GetCurrentValue(); | 223 RenderProcessHost* host = i.GetCurrentValue(); |
224 Profile* profile = Profile::FromBrowserContext(host->browser_context()); | 224 Profile* profile = Profile::FromBrowserContext(host->browser_context()); |
225 if (extension_service_->profile()->IsSameProfile(profile)) | 225 if (extension_service_->profile()->IsSameProfile(profile)) |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 408 } |
409 | 409 |
410 void RequestPermissionsFunction::InstallUIAbort(bool user_initiated) { | 410 void RequestPermissionsFunction::InstallUIAbort(bool user_initiated) { |
411 install_ui_.reset(); | 411 install_ui_.reset(); |
412 result_.reset(Value::CreateBooleanValue(false)); | 412 result_.reset(Value::CreateBooleanValue(false)); |
413 requested_permissions_ = NULL; | 413 requested_permissions_ = NULL; |
414 | 414 |
415 SendResponse(true); | 415 SendResponse(true); |
416 Release(); | 416 Release(); |
417 } | 417 } |
OLD | NEW |