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/extension_management_api.h" | 5 #include "chrome/browser/extensions/api/management/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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "chrome/browser/extensions/api/management/management_api_constants.h" |
16 #include "chrome/browser/extensions/event_names.h" | 17 #include "chrome/browser/extensions/event_names.h" |
17 #include "chrome/browser/extensions/event_router.h" | 18 #include "chrome/browser/extensions/event_router.h" |
18 #include "chrome/browser/extensions/extension_management_api_constants.h" | |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/extension_system.h" | 20 #include "chrome/browser/extensions/extension_system.h" |
21 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 21 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
22 #include "chrome/browser/extensions/management_policy.h" | 22 #include "chrome/browser/extensions/management_policy.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/extensions/application_launch.h" | 24 #include "chrome/browser/ui/extensions/application_launch.h" |
25 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 25 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
27 #include "chrome/common/chrome_utility_messages.h" | 27 #include "chrome/common/chrome_utility_messages.h" |
28 #include "chrome/common/extensions/extension.h" | 28 #include "chrome/common/extensions/extension.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 for (host_perms_iter = host_perms.begin(); | 137 for (host_perms_iter = host_perms.begin(); |
138 host_perms_iter != host_perms.end(); | 138 host_perms_iter != host_perms.end(); |
139 ++host_perms_iter) { | 139 ++host_perms_iter) { |
140 StringValue* name = new StringValue(host_perms_iter->GetAsString()); | 140 StringValue* name = new StringValue(host_perms_iter->GetAsString()); |
141 host_permission_list->Append(name); | 141 host_permission_list->Append(name); |
142 } | 142 } |
143 } | 143 } |
144 } | 144 } |
145 info->Set(keys::kHostPermissionsKey, host_permission_list); | 145 info->Set(keys::kHostPermissionsKey, host_permission_list); |
146 | 146 |
| 147 std::string install_type = keys::kInstallTypeOther; |
| 148 switch (extension.location()) { |
| 149 case Extension::INTERNAL: |
| 150 install_type = keys::kInstallTypeNormal; |
| 151 break; |
| 152 case Extension::LOAD: |
| 153 install_type = keys::kInstallTypeDevelopment; |
| 154 break; |
| 155 case Extension::EXTERNAL_PREF: |
| 156 case Extension::EXTERNAL_REGISTRY: |
| 157 case Extension::EXTERNAL_PREF_DOWNLOAD: |
| 158 install_type = keys::kInstallTypeSideload; |
| 159 break; |
| 160 case Extension::EXTERNAL_POLICY_DOWNLOAD: |
| 161 install_type = keys::kInstallTypeAdmin; |
| 162 break; |
| 163 default: |
| 164 install_type = keys::kInstallTypeOther; |
| 165 } |
| 166 info->SetString(keys::kInstallTypeKey, install_type); |
| 167 |
147 return info; | 168 return info; |
148 } | 169 } |
149 | 170 |
150 static void AddExtensionInfo(ListValue* list, | 171 static void AddExtensionInfo(ListValue* list, |
151 const ExtensionSet& extensions, | 172 const ExtensionSet& extensions, |
152 ExtensionService* service) { | 173 ExtensionService* service) { |
153 for (ExtensionSet::const_iterator i = extensions.begin(); | 174 for (ExtensionSet::const_iterator i = extensions.begin(); |
154 i != extensions.end(); ++i) { | 175 i != extensions.end(); ++i) { |
155 const Extension& extension = **i; | 176 const Extension& extension = **i; |
156 | 177 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 ExtensionService* service = profile->GetExtensionService(); | 607 ExtensionService* service = profile->GetExtensionService(); |
587 args.Append(CreateExtensionInfo(*extension, service)); | 608 args.Append(CreateExtensionInfo(*extension, service)); |
588 } | 609 } |
589 | 610 |
590 std::string args_json; | 611 std::string args_json; |
591 base::JSONWriter::Write(&args, &args_json); | 612 base::JSONWriter::Write(&args, &args_json); |
592 | 613 |
593 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 614 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
594 event_name, args_json, NULL, GURL(), extensions::EventFilteringInfo()); | 615 event_name, args_json, NULL, GURL(), extensions::EventFilteringInfo()); |
595 } | 616 } |
OLD | NEW |