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

Unified Diff: chrome/browser/cocoa/search_engine_list_model.mm

Issue 341060: [Mac] Prevent search engines from disappearing in the preferences list (Closed)
Patch Set: Created 11 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/cocoa/search_engine_list_model_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/search_engine_list_model.mm
diff --git a/chrome/browser/cocoa/search_engine_list_model.mm b/chrome/browser/cocoa/search_engine_list_model.mm
index 190023166290f54b477e77725888a8aeb144ffb3..748ede081a48008ca2d74b88e8b79fc8754d62a3 100644
--- a/chrome/browser/cocoa/search_engine_list_model.mm
+++ b/chrome/browser/cocoa/search_engine_list_model.mm
@@ -88,14 +88,19 @@ class SearchEngineObserver : public TemplateURLModelObserver {
- (NSUInteger)defaultIndex {
if (!model_) return 0;
+ NSUInteger index = 0;
const TemplateURL* defaultSearchProvider = model_->GetDefaultSearchProvider();
if (defaultSearchProvider) {
typedef std::vector<const TemplateURL*> TemplateURLs;
TemplateURLs urls = model_->GetTemplateURLs();
- TemplateURLs::iterator i =
- find(urls.begin(), urls.end(), defaultSearchProvider);
- if (i != urls.end())
- return static_cast<int>(i - urls.begin());
+ for (std::vector<const TemplateURL*>::iterator it = urls.begin();
+ it != urls.end(); ++it) {
pink (ping after 24hrs) 2009/11/02 15:46:23 align with |std| above, not paren.
+ const TemplateURL* url = *it;
+ if (url->id() == defaultSearchProvider->id())
+ return index;
+ if (url->ShowInDefaultList())
+ ++index;
+ }
}
return 0;
}
« no previous file with comments | « no previous file | chrome/browser/cocoa/search_engine_list_model_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698