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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 for (host_perms_iter = host_perms.begin(); | 136 for (host_perms_iter = host_perms.begin(); |
137 host_perms_iter != host_perms.end(); | 137 host_perms_iter != host_perms.end(); |
138 ++host_perms_iter) { | 138 ++host_perms_iter) { |
139 StringValue* name = new StringValue(host_perms_iter->GetAsString()); | 139 StringValue* name = new StringValue(host_perms_iter->GetAsString()); |
140 host_permission_list->Append(name); | 140 host_permission_list->Append(name); |
141 } | 141 } |
142 } | 142 } |
143 } | 143 } |
144 info->Set(keys::kHostPermissionsKey, host_permission_list); | 144 info->Set(keys::kHostPermissionsKey, host_permission_list); |
145 | 145 |
| 146 std::string install_type = keys::kInstallTypeOther; |
| 147 switch (extension.location()) { |
| 148 case Extension::INTERNAL: |
| 149 install_type = keys::kInstallTypeNormal; |
| 150 break; |
| 151 case Extension::LOAD: |
| 152 install_type = keys::kInstallTypeDevelopment; |
| 153 break; |
| 154 case Extension::EXTERNAL_PREF: |
| 155 case Extension::EXTERNAL_REGISTRY: |
| 156 case Extension::EXTERNAL_PREF_DOWNLOAD: |
| 157 install_type = keys::kInstallTypeSideload; |
| 158 break; |
| 159 case Extension::EXTERNAL_POLICY_DOWNLOAD: |
| 160 install_type = keys::kInstallTypeAdmin; |
| 161 break; |
| 162 default: |
| 163 install_type = keys::kInstallTypeOther; |
| 164 } |
| 165 info->SetString(keys::kInstallTypeKey, install_type); |
| 166 |
146 return info; | 167 return info; |
147 } | 168 } |
148 | 169 |
149 static void AddExtensionInfo(ListValue* list, | 170 static void AddExtensionInfo(ListValue* list, |
150 const ExtensionSet& extensions, | 171 const ExtensionSet& extensions, |
151 ExtensionService* service) { | 172 ExtensionService* service) { |
152 for (ExtensionSet::const_iterator i = extensions.begin(); | 173 for (ExtensionSet::const_iterator i = extensions.begin(); |
153 i != extensions.end(); ++i) { | 174 i != extensions.end(); ++i) { |
154 const Extension& extension = **i; | 175 const Extension& extension = **i; |
155 | 176 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 ExtensionService* service = profile->GetExtensionService(); | 606 ExtensionService* service = profile->GetExtensionService(); |
586 args.Append(CreateExtensionInfo(*extension, service)); | 607 args.Append(CreateExtensionInfo(*extension, service)); |
587 } | 608 } |
588 | 609 |
589 std::string args_json; | 610 std::string args_json; |
590 base::JSONWriter::Write(&args, &args_json); | 611 base::JSONWriter::Write(&args, &args_json); |
591 | 612 |
592 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 613 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
593 event_name, args_json, NULL, GURL(), extensions::EventFilteringInfo()); | 614 event_name, args_json, NULL, GURL(), extensions::EventFilteringInfo()); |
594 } | 615 } |
OLD | NEW |