diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-16 01:40:27 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-16 01:40:27 +0000 |
commit | 529a287fbf187be341a65bab1afeb0e323e1d5fe (patch) | |
tree | e161e54255c525c1c772ce3bab820050a05b6c79 /chrome/browser/extensions | |
parent | c7aa87dd258247dd771e9538e418ec4d3050d87b (diff) | |
download | chromium_src-529a287fbf187be341a65bab1afeb0e323e1d5fe.zip chromium_src-529a287fbf187be341a65bab1afeb0e323e1d5fe.tar.gz chromium_src-529a287fbf187be341a65bab1afeb0e323e1d5fe.tar.bz2 |
Fix crash caused by multiple app launcher ordinal conflicts.
BUG=155603
TEST=Covered by unit test.
R=csharp@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11154013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162033 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension_sorting.cc | 9 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_sorting_unittest.cc | 7 |
2 files changed, 15 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_sorting.cc b/chrome/browser/extensions/extension_sorting.cc index 0be326b..48eea40 100644 --- a/chrome/browser/extensions/extension_sorting.cc +++ b/chrome/browser/extensions/extension_sorting.cc @@ -612,8 +612,15 @@ syncer::StringOrdinal ExtensionSorting::ResolveCollision( if (app_it == page.end()) return app_launch_ordinal; + // Finds the next app launcher ordinal. This is done by the following loop + // because this function could be called before FixNTPOrdinalCollisions and + // thus |page| might contains multiple entries with the same app launch + // ordinal. See http://crbug.com/155603 + while (app_it != page.end() && app_launch_ordinal.Equals(app_it->first)) + ++app_it; + // If there is no next after the collision, returns the next ordinal. - if (++app_it == page.end()) + if (app_it == page.end()) return app_launch_ordinal.CreateAfter(); // Otherwise, returns the ordinal between the collision and the next ordinal. diff --git a/chrome/browser/extensions/extension_sorting_unittest.cc b/chrome/browser/extensions/extension_sorting_unittest.cc index 8158b90..201b62f 100644 --- a/chrome/browser/extensions/extension_sorting_unittest.cc +++ b/chrome/browser/extensions/extension_sorting_unittest.cc @@ -937,10 +937,17 @@ class ExtensionSortingDefaultOrdinalNoCollision extension_sorting->SetPageOrdinal(other_app_->id(), default_page_ordinal_); extension_sorting->SetAppLaunchOrdinal(other_app_->id(), default_app_launch_ordinal_); + + yet_another_app_ = prefs_.AddApp("yet_aother_app"); + extension_sorting->SetPageOrdinal(yet_another_app_->id(), + default_page_ordinal_); + extension_sorting->SetAppLaunchOrdinal(yet_another_app_->id(), + default_app_launch_ordinal_); } private: scoped_refptr<Extension> other_app_; + scoped_refptr<Extension> yet_another_app_; }; TEST_F(ExtensionSortingDefaultOrdinalNoCollision, ExtensionSortingDefaultOrdinalNoCollision) {} |