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/automation/automation_provider_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2011 } | 2011 } |
2012 delete this; | 2012 delete this; |
2013 } | 2013 } |
2014 | 2014 |
2015 namespace { | 2015 namespace { |
2016 | 2016 |
2017 // Returns a vector of dictionaries containing information about installed apps, | 2017 // Returns a vector of dictionaries containing information about installed apps, |
2018 // as identified from a given list of extensions. The caller takes ownership | 2018 // as identified from a given list of extensions. The caller takes ownership |
2019 // of the created vector. | 2019 // of the created vector. |
2020 std::vector<DictionaryValue*>* GetAppInfoFromExtensions( | 2020 std::vector<DictionaryValue*>* GetAppInfoFromExtensions( |
2021 const ExtensionList* extensions, | 2021 const ExtensionSet* extensions, |
2022 ExtensionService* ext_service) { | 2022 ExtensionService* ext_service) { |
2023 std::vector<DictionaryValue*>* apps_list = | 2023 std::vector<DictionaryValue*>* apps_list = |
2024 new std::vector<DictionaryValue*>(); | 2024 new std::vector<DictionaryValue*>(); |
2025 for (ExtensionList::const_iterator ext = extensions->begin(); | 2025 for (ExtensionSet::const_iterator ext = extensions->begin(); |
2026 ext != extensions->end(); ++ext) { | 2026 ext != extensions->end(); ++ext) { |
2027 // Only return information about extensions that are actually apps. | 2027 // Only return information about extensions that are actually apps. |
2028 if ((*ext)->is_app()) { | 2028 if ((*ext)->is_app()) { |
2029 DictionaryValue* app_info = new DictionaryValue(); | 2029 DictionaryValue* app_info = new DictionaryValue(); |
2030 AppLauncherHandler::CreateAppInfo(*ext, NULL, ext_service, app_info); | 2030 AppLauncherHandler::CreateAppInfo(*ext, NULL, ext_service, app_info); |
2031 app_info->SetBoolean("is_component_extension", | 2031 app_info->SetBoolean("is_component_extension", |
2032 (*ext)->location() == Extension::COMPONENT); | 2032 (*ext)->location() == Extension::COMPONENT); |
2033 | 2033 |
2034 // Convert the launch_type integer into a more descriptive string. | 2034 // Convert the launch_type integer into a more descriptive string. |
2035 int launch_type; | 2035 int launch_type; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 | 2083 |
2084 // Collect information about the apps in the new tab page. | 2084 // Collect information about the apps in the new tab page. |
2085 ExtensionService* ext_service = automation_->profile()->GetExtensionService(); | 2085 ExtensionService* ext_service = automation_->profile()->GetExtensionService(); |
2086 if (!ext_service) { | 2086 if (!ext_service) { |
2087 AutomationJSONReply(automation_, reply_message_.release()) | 2087 AutomationJSONReply(automation_, reply_message_.release()) |
2088 .SendError("No ExtensionService."); | 2088 .SendError("No ExtensionService."); |
2089 return; | 2089 return; |
2090 } | 2090 } |
2091 // Process enabled extensions. | 2091 // Process enabled extensions. |
2092 ListValue* apps_list = new ListValue(); | 2092 ListValue* apps_list = new ListValue(); |
2093 const ExtensionList* extensions = ext_service->extensions(); | 2093 const ExtensionSet* extensions = ext_service->extensions(); |
2094 std::vector<DictionaryValue*>* enabled_apps = GetAppInfoFromExtensions( | 2094 std::vector<DictionaryValue*>* enabled_apps = GetAppInfoFromExtensions( |
2095 extensions, ext_service); | 2095 extensions, ext_service); |
2096 for (std::vector<DictionaryValue*>::const_iterator app = | 2096 for (std::vector<DictionaryValue*>::const_iterator app = |
2097 enabled_apps->begin(); app != enabled_apps->end(); ++app) { | 2097 enabled_apps->begin(); app != enabled_apps->end(); ++app) { |
2098 (*app)->SetBoolean("is_disabled", false); | 2098 (*app)->SetBoolean("is_disabled", false); |
2099 apps_list->Append(*app); | 2099 apps_list->Append(*app); |
2100 } | 2100 } |
2101 delete enabled_apps; | 2101 delete enabled_apps; |
2102 // Process disabled extensions. | 2102 // Process disabled extensions. |
2103 const ExtensionList* disabled_extensions = ext_service->disabled_extensions(); | 2103 const ExtensionSet* disabled_extensions = ext_service->disabled_extensions(); |
2104 std::vector<DictionaryValue*>* disabled_apps = GetAppInfoFromExtensions( | 2104 std::vector<DictionaryValue*>* disabled_apps = GetAppInfoFromExtensions( |
2105 disabled_extensions, ext_service); | 2105 disabled_extensions, ext_service); |
2106 for (std::vector<DictionaryValue*>::const_iterator app = | 2106 for (std::vector<DictionaryValue*>::const_iterator app = |
2107 disabled_apps->begin(); app != disabled_apps->end(); ++app) { | 2107 disabled_apps->begin(); app != disabled_apps->end(); ++app) { |
2108 (*app)->SetBoolean("is_disabled", true); | 2108 (*app)->SetBoolean("is_disabled", true); |
2109 apps_list->Append(*app); | 2109 apps_list->Append(*app); |
2110 } | 2110 } |
2111 delete disabled_apps; | 2111 delete disabled_apps; |
2112 // Process terminated extensions. | 2112 // Process terminated extensions. |
2113 const ExtensionList* terminated_extensions = | 2113 const ExtensionSet* terminated_extensions = |
2114 ext_service->terminated_extensions(); | 2114 ext_service->terminated_extensions(); |
2115 std::vector<DictionaryValue*>* terminated_apps = GetAppInfoFromExtensions( | 2115 std::vector<DictionaryValue*>* terminated_apps = GetAppInfoFromExtensions( |
2116 terminated_extensions, ext_service); | 2116 terminated_extensions, ext_service); |
2117 for (std::vector<DictionaryValue*>::const_iterator app = | 2117 for (std::vector<DictionaryValue*>::const_iterator app = |
2118 terminated_apps->begin(); app != terminated_apps->end(); ++app) { | 2118 terminated_apps->begin(); app != terminated_apps->end(); ++app) { |
2119 (*app)->SetBoolean("is_disabled", true); | 2119 (*app)->SetBoolean("is_disabled", true); |
2120 apps_list->Append(*app); | 2120 apps_list->Append(*app); |
2121 } | 2121 } |
2122 delete terminated_apps; | 2122 delete terminated_apps; |
2123 ntp_info_->Set("apps", apps_list); | 2123 ntp_info_->Set("apps", apps_list); |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3092 } | 3092 } |
3093 | 3093 |
3094 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); | 3094 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); |
3095 if (host->extension_id() == extension_id_ && | 3095 if (host->extension_id() == extension_id_ && |
3096 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { | 3096 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { |
3097 AutomationJSONReply(automation_, reply_message_.release()) | 3097 AutomationJSONReply(automation_, reply_message_.release()) |
3098 .SendSuccess(NULL); | 3098 .SendSuccess(NULL); |
3099 delete this; | 3099 delete this; |
3100 } | 3100 } |
3101 } | 3101 } |
OLD | NEW |