Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/extensions/extension_management_api.cc

Issue 7432006: Add an experimental permissions API for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_management_api.h" 5 #include "chrome/browser/extensions/extension_management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 GURL url = ExtensionIconSource::GetIconURL( 85 GURL url = ExtensionIconSource::GetIconURL(
86 &extension, size, ExtensionIconSet::MATCH_EXACTLY, false); 86 &extension, size, ExtensionIconSet::MATCH_EXACTLY, false);
87 icon_info->SetInteger(kSizeKey, icon_iter->first); 87 icon_info->SetInteger(kSizeKey, icon_iter->first);
88 icon_info->SetString(kUrlKey, url.spec()); 88 icon_info->SetString(kUrlKey, url.spec());
89 icon_list->Append(icon_info); 89 icon_list->Append(icon_info);
90 } 90 }
91 info->Set("icons", icon_list); 91 info->Set("icons", icon_list);
92 } 92 }
93 93
94 const std::set<std::string> perms = 94 const std::set<std::string> perms =
95 extension.permission_set()->GetAPIsAsStrings(); 95 extension.GetActivePermissions()->GetAPIsAsStrings();
96 ListValue* permission_list = new ListValue(); 96 ListValue* permission_list = new ListValue();
97 if (!perms.empty()) { 97 if (!perms.empty()) {
98 std::set<std::string>::const_iterator perms_iter; 98 std::set<std::string>::const_iterator perms_iter;
99 for (perms_iter = perms.begin(); perms_iter != perms.end(); ++perms_iter) { 99 for (perms_iter = perms.begin(); perms_iter != perms.end(); ++perms_iter) {
100 StringValue* permission_name = new StringValue(*perms_iter); 100 StringValue* permission_name = new StringValue(*perms_iter);
101 permission_list->Append(permission_name); 101 permission_list->Append(permission_name);
102 } 102 }
103 } 103 }
104 info->Set("permissions", permission_list); 104 info->Set("permissions", permission_list);
105 105
106 ListValue* host_permission_list = new ListValue(); 106 ListValue* host_permission_list = new ListValue();
107 if (!extension.is_hosted_app()) { 107 if (!extension.is_hosted_app()) {
108 // Skip host permissions for hosted apps. 108 // Skip host permissions for hosted apps.
109 const URLPatternSet host_perms = 109 const URLPatternSet host_perms =
110 extension.permission_set()->explicit_hosts(); 110 extension.GetActivePermissions()->explicit_hosts();
111 if (!host_perms.is_empty()) { 111 if (!host_perms.is_empty()) {
112 URLPatternSet::const_iterator host_perms_iter; 112 URLPatternSet::const_iterator host_perms_iter;
113 for (host_perms_iter = host_perms.begin(); 113 for (host_perms_iter = host_perms.begin();
114 host_perms_iter != host_perms.end(); 114 host_perms_iter != host_perms.end();
115 ++host_perms_iter) { 115 ++host_perms_iter) {
116 StringValue* name = new StringValue(host_perms_iter->GetAsString()); 116 StringValue* name = new StringValue(host_perms_iter->GetAsString());
117 host_permission_list->Append(name); 117 host_permission_list->Append(name);
118 } 118 }
119 } 119 }
120 } 120 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 bool enabled = service->GetExtensionById(extension->id(), false) != NULL; 315 bool enabled = service->GetExtensionById(extension->id(), false) != NULL;
316 args.Append(CreateExtensionInfo(*extension, enabled)); 316 args.Append(CreateExtensionInfo(*extension, enabled));
317 } 317 }
318 318
319 std::string args_json; 319 std::string args_json;
320 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); 320 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json);
321 321
322 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 322 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
323 event_name, args_json, NULL, GURL()); 323 event_name, args_json, NULL, GURL());
324 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698