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

Unified Diff: chrome/browser/extensions/extension_sorting.cc

Issue 12331003: Apps that don't appear on the NTP shouldn't contribute to NTP page overflow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 7 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_sorting.cc
diff --git a/chrome/browser/extensions/extension_sorting.cc b/chrome/browser/extensions/extension_sorting.cc
index d5e07db3edc707a900db49221a703db21eb53629..8963fa0455a06d190f9bbc2c351fbdfd61ce016b 100644
--- a/chrome/browser/extensions/extension_sorting.cc
+++ b/chrome/browser/extensions/extension_sorting.cc
@@ -364,7 +364,7 @@ syncer::StringOrdinal ExtensionSorting::GetNaturalAppPageOrdinal() const {
for (PageOrdinalMap::const_iterator it = ntp_ordinal_map_.begin();
it != ntp_ordinal_map_.end(); ++it) {
- if (it->second.size() < kNaturalAppPageSize)
+ if (CountNonHiddenItems(it->second) < kNaturalAppPageSize)
return it->first;
}
@@ -445,6 +445,10 @@ syncer::StringOrdinal ExtensionSorting::PageIntegerAsStringOrdinal(
return ntp_ordinal_map_.rbegin()->first;
}
+void ExtensionSorting::MarkExtensionAsHidden(const std::string& extension_id) {
+ hidden_extensions_.insert(extension_id);
+}
+
syncer::StringOrdinal ExtensionSorting::GetMinOrMaxAppLaunchOrdinalsOnPage(
const syncer::StringOrdinal& target_page_ordinal,
AppLaunchOrdinalReturn return_type) const {
@@ -610,3 +614,15 @@ syncer::StringOrdinal ExtensionSorting::ResolveCollision(
return app_launch_ordinal.CreateBetween(app_it->first);
}
+size_t ExtensionSorting::CountNonHiddenItems(
+ const AppLaunchOrdinalMap& m) const {
+ size_t result = 0;
+ for (AppLaunchOrdinalMap::const_iterator it = m.begin(); it != m.end();
+ ++it) {
+ const std::string& id = it->second;
+ if (hidden_extensions_.count(id) == 0) {
tapted 2013/02/26 03:38:49 nit: no braces on single-line if (seems to prevail
koz (OOO until 15th September) 2013/02/26 03:58:37 Yeah, I find it helps when dealing with iterators
+ result++;
+ }
+ }
+ return result;
+}

Powered by Google App Engine
This is Rietveld 408576698