From c691a593ac199d774a43f239342cd85c80ca1a2a Mon Sep 17 00:00:00 2001 From: "csharp@chromium.org" Date: Wed, 21 Dec 2011 05:04:08 +0000 Subject: Fix Apps on the NTP failing to display. This fixes the case where an app that we wish to display on the NTP has an invalid page index value, as well as adding the chrome web store app to the ordinal index (so that it gets a valid index value). BUG=107440 TEST=Users should be able to launch chrome and navigate to the apps panel on the NTP Review URL: http://codereview.chromium.org/8961016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115275 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/extensions/extension_prefs.cc | 10 ++++++++++ chrome/browser/ui/webui/ntp/app_launcher_handler.cc | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'chrome/browser') diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc index a49f934..c70e268 100644 --- a/chrome/browser/extensions/extension_prefs.cc +++ b/chrome/browser/extensions/extension_prefs.cc @@ -1708,7 +1708,17 @@ void ExtensionPrefs::InitializePageOrdinalMap( for (ExtensionIdSet::const_iterator ext_it = extension_ids.begin(); ext_it != extension_ids.end(); ++ext_it) { UpdatePageOrdinalMap(StringOrdinal(), GetPageOrdinal(*ext_it)); + + // Ensure that the web store app still isn't found in this list, since + // it is added after this loop. + DCHECK(*ext_it != extension_misc::kWebStoreAppId); } + + // Include the Web Store App since it is displayed on the NTP. + StringOrdinal web_store_app_page = + GetPageOrdinal(extension_misc::kWebStoreAppId); + if (web_store_app_page.IsValid()) + UpdatePageOrdinalMap(StringOrdinal(), web_store_app_page); } void ExtensionPrefs::UpdatePageOrdinalMap(const StringOrdinal& old_value, diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index a494a9c..893fb0b 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -173,8 +173,8 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension, // We convert the page_ordinal to an integer because the pages are referenced // from within an array in the javascript code, which can't be easily // changed to handle the StringOrdinal values, so we do the conversion here. - value->SetInteger("page_index", - prefs->PageStringOrdinalAsInteger(page_ordinal)); + int page_index = prefs->PageStringOrdinalAsInteger(page_ordinal); + value->SetInteger("page_index", page_index >= 0 ? page_index : 0); StringOrdinal app_launch_ordinal = prefs->GetAppLaunchOrdinal(extension->id()); -- cgit v1.1