summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcsharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-24 15:14:12 +0000
committercsharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-24 15:14:12 +0000
commit32a20672297ab2f7d2725e5811e45e09e6cb84c4 (patch)
tree299a468b6eb80fb211a4a28c01c7f1071e246ca9
parent4990299ded0cd00c29f5f59e4aa34ccd23414216 (diff)
downloadchromium_src-32a20672297ab2f7d2725e5811e45e09e6cb84c4.zip
chromium_src-32a20672297ab2f7d2725e5811e45e09e6cb84c4.tar.gz
chromium_src-32a20672297ab2f7d2725e5811e45e09e6cb84c4.tar.bz2
Use extension IDs instead of Extension instance pointers for app_launcher_handler.cc
Replace the the set of Extension pointers with a set of the extension ids. These ids can be used to retrieve the Extension pointers when needed, ensuring that we get either the current valid pointer, or a NULL pointer if the extension is no longer valid (Instead of using invalid pointers and potentially crashing). BUG=136094 TEST= 1.click on "Remove from chrome" option by right click on application installed application in this case "Google mail checker". 2.Pop up window will be displayed with "Remove" and "cancel" option. 3.Click on Remove. 4.Immediately after that click on "Chrome webstore icon" in new tab. 5.Chrome opens up the web store (instead of crashing). Review URL: https://chromiumcodereview.appspot.com/10797010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148109 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/webui/ntp/app_launcher_handler.cc25
-rw-r--r--chrome/browser/ui/webui/ntp/app_launcher_handler.h4
2 files changed, 19 insertions, 10 deletions
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index 5faf905..f5916f5 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -271,7 +271,7 @@ void AppLauncherHandler::Observe(int type,
scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension));
if (app_info.get()) {
- visible_apps_.insert(extension);
+ visible_apps_.insert(extension->id());
ExtensionPrefs* prefs = extension_service_->extension_prefs();
scoped_ptr<base::FundamentalValue> highlight(Value::CreateBooleanValue(
@@ -297,7 +297,7 @@ void AppLauncherHandler::Observe(int type,
content::Details<extensions::UnloadedExtensionInfo>(
details)->reason == extension_misc::UNLOAD_REASON_UNINSTALL));
if (app_info.get()) {
- visible_apps_.erase(extension);
+ visible_apps_.erase(extension->id());
scoped_ptr<base::FundamentalValue> from_page(
Value::CreateBooleanValue(!extension_id_prompting_.empty()));
@@ -359,10 +359,10 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
ListValue* list = new ListValue();
- for (std::set<const Extension*>::iterator it = visible_apps_.begin();
+ for (std::set<std::string>::iterator it = visible_apps_.begin();
it != visible_apps_.end(); ++it) {
- const Extension* extension = *it;
- if (extension->ShouldDisplayInLauncher()) {
+ const Extension* extension = extension_service_->GetInstalledExtension(*it);
+ if (extension && extension->ShouldDisplayInLauncher()) {
DictionaryValue* app_info = GetAppInfo(extension);
list->Append(app_info);
}
@@ -460,13 +460,22 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
// of apps visible on the NTP.
if (!has_loaded_apps_) {
const ExtensionSet* extensions = extension_service_->extensions();
- visible_apps_.insert(extensions->begin(), extensions->end());
+ for (ExtensionSet::const_iterator it = extensions->begin();
+ it != extensions->end(); ++it) {
+ visible_apps_.insert((*it)->id());
+ }
extensions = extension_service_->disabled_extensions();
- visible_apps_.insert(extensions->begin(), extensions->end());
+ for (ExtensionSet::const_iterator it = extensions->begin();
+ it != extensions->end(); ++it) {
+ visible_apps_.insert((*it)->id());
+ }
extensions = extension_service_->terminated_extensions();
- visible_apps_.insert(extensions->begin(), extensions->end());
+ for (ExtensionSet::const_iterator it = extensions->begin();
+ it != extensions->end(); ++it) {
+ visible_apps_.insert((*it)->id());
+ }
}
SetAppToBeHighlighted();
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.h b/chrome/browser/ui/webui/ntp/app_launcher_handler.h
index d797a26..4f0bb63 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.h
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.h
@@ -181,8 +181,8 @@ class AppLauncherHandler : public content::WebUIMessageHandler,
// Used to show confirmation UI for enabling extensions in incognito mode.
scoped_ptr<ExtensionInstallPrompt> extension_install_ui_;
- // The set of apps to show on the NTP.
- std::set<const extensions::Extension*> visible_apps_;
+ // The ids of apps to show on the NTP.
+ std::set<std::string> visible_apps_;
// The id of the extension we are prompting the user about.
std::string extension_id_prompting_;