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

Side by Side Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 8733004: Make ExtensionService use ExtensionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: = Created 9 years 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/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 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 } 2000 }
2001 delete this; 2001 delete this;
2002 } 2002 }
2003 2003
2004 namespace { 2004 namespace {
2005 2005
2006 // Returns a vector of dictionaries containing information about installed apps, 2006 // Returns a vector of dictionaries containing information about installed apps,
2007 // as identified from a given list of extensions. The caller takes ownership 2007 // as identified from a given list of extensions. The caller takes ownership
2008 // of the created vector. 2008 // of the created vector.
2009 std::vector<DictionaryValue*>* GetAppInfoFromExtensions( 2009 std::vector<DictionaryValue*>* GetAppInfoFromExtensions(
2010 const ExtensionList* extensions, 2010 const ExtensionSet* extensions,
2011 ExtensionService* ext_service) { 2011 ExtensionService* ext_service) {
2012 std::vector<DictionaryValue*>* apps_list = 2012 std::vector<DictionaryValue*>* apps_list =
2013 new std::vector<DictionaryValue*>(); 2013 new std::vector<DictionaryValue*>();
2014 for (ExtensionList::const_iterator ext = extensions->begin(); 2014 for (ExtensionSet::const_iterator ext = extensions->begin();
2015 ext != extensions->end(); ++ext) { 2015 ext != extensions->end(); ++ext) {
2016 // Only return information about extensions that are actually apps. 2016 // Only return information about extensions that are actually apps.
2017 if ((*ext)->is_app()) { 2017 if ((*ext)->is_app()) {
2018 DictionaryValue* app_info = new DictionaryValue(); 2018 DictionaryValue* app_info = new DictionaryValue();
2019 AppLauncherHandler::CreateAppInfo(*ext, NULL, ext_service, app_info); 2019 AppLauncherHandler::CreateAppInfo(*ext, NULL, ext_service, app_info);
2020 app_info->SetBoolean("is_component_extension", 2020 app_info->SetBoolean("is_component_extension",
2021 (*ext)->location() == Extension::COMPONENT); 2021 (*ext)->location() == Extension::COMPONENT);
2022 2022
2023 // Convert the launch_type integer into a more descriptive string. 2023 // Convert the launch_type integer into a more descriptive string.
2024 int launch_type; 2024 int launch_type;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 2072
2073 // Collect information about the apps in the new tab page. 2073 // Collect information about the apps in the new tab page.
2074 ExtensionService* ext_service = automation_->profile()->GetExtensionService(); 2074 ExtensionService* ext_service = automation_->profile()->GetExtensionService();
2075 if (!ext_service) { 2075 if (!ext_service) {
2076 AutomationJSONReply(automation_, reply_message_.release()) 2076 AutomationJSONReply(automation_, reply_message_.release())
2077 .SendError("No ExtensionService."); 2077 .SendError("No ExtensionService.");
2078 return; 2078 return;
2079 } 2079 }
2080 // Process enabled extensions. 2080 // Process enabled extensions.
2081 ListValue* apps_list = new ListValue(); 2081 ListValue* apps_list = new ListValue();
2082 const ExtensionList* extensions = ext_service->extensions(); 2082 const ExtensionSet* extensions = ext_service->extensions();
2083 std::vector<DictionaryValue*>* enabled_apps = GetAppInfoFromExtensions( 2083 std::vector<DictionaryValue*>* enabled_apps = GetAppInfoFromExtensions(
2084 extensions, ext_service); 2084 extensions, ext_service);
2085 for (std::vector<DictionaryValue*>::const_iterator app = 2085 for (std::vector<DictionaryValue*>::const_iterator app =
2086 enabled_apps->begin(); app != enabled_apps->end(); ++app) { 2086 enabled_apps->begin(); app != enabled_apps->end(); ++app) {
2087 (*app)->SetBoolean("is_disabled", false); 2087 (*app)->SetBoolean("is_disabled", false);
2088 apps_list->Append(*app); 2088 apps_list->Append(*app);
2089 } 2089 }
2090 delete enabled_apps; 2090 delete enabled_apps;
2091 // Process disabled extensions. 2091 // Process disabled extensions.
2092 const ExtensionList* disabled_extensions = ext_service->disabled_extensions(); 2092 const ExtensionSet* disabled_extensions = ext_service->disabled_extensions();
2093 std::vector<DictionaryValue*>* disabled_apps = GetAppInfoFromExtensions( 2093 std::vector<DictionaryValue*>* disabled_apps = GetAppInfoFromExtensions(
2094 disabled_extensions, ext_service); 2094 disabled_extensions, ext_service);
2095 for (std::vector<DictionaryValue*>::const_iterator app = 2095 for (std::vector<DictionaryValue*>::const_iterator app =
2096 disabled_apps->begin(); app != disabled_apps->end(); ++app) { 2096 disabled_apps->begin(); app != disabled_apps->end(); ++app) {
2097 (*app)->SetBoolean("is_disabled", true); 2097 (*app)->SetBoolean("is_disabled", true);
2098 apps_list->Append(*app); 2098 apps_list->Append(*app);
2099 } 2099 }
2100 delete disabled_apps; 2100 delete disabled_apps;
2101 // Process terminated extensions. 2101 // Process terminated extensions.
2102 const ExtensionList* terminated_extensions = 2102 const ExtensionSet* terminated_extensions =
2103 ext_service->terminated_extensions(); 2103 ext_service->terminated_extensions();
2104 std::vector<DictionaryValue*>* terminated_apps = GetAppInfoFromExtensions( 2104 std::vector<DictionaryValue*>* terminated_apps = GetAppInfoFromExtensions(
2105 terminated_extensions, ext_service); 2105 terminated_extensions, ext_service);
2106 for (std::vector<DictionaryValue*>::const_iterator app = 2106 for (std::vector<DictionaryValue*>::const_iterator app =
2107 terminated_apps->begin(); app != terminated_apps->end(); ++app) { 2107 terminated_apps->begin(); app != terminated_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 terminated_apps; 2111 delete terminated_apps;
2112 ntp_info_->Set("apps", apps_list); 2112 ntp_info_->Set("apps", apps_list);
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
2953 if (automation_) { 2953 if (automation_) {
2954 AutomationJSONReply(automation_, reply_message_.release()) 2954 AutomationJSONReply(automation_, reply_message_.release())
2955 .SendSuccess(NULL); 2955 .SendSuccess(NULL);
2956 } 2956 }
2957 delete this; 2957 delete this;
2958 } 2958 }
2959 } else { 2959 } else {
2960 NOTREACHED(); 2960 NOTREACHED();
2961 } 2961 }
2962 } 2962 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698