OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/chrome/browser/ui/settings/search_engine_settings_collection_view_c
ontroller.h" | 5 #import "ios/chrome/browser/ui/settings/search_engine_settings_collection_view_c
ontroller.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #import "base/ios/weak_nsobject.h" | 9 #import "base/ios/weak_nsobject.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // Show the checkmark on the new default engine. | 159 // Show the checkmark on the new default engine. |
160 CollectionViewTextItem* newDefaultEngine = | 160 CollectionViewTextItem* newDefaultEngine = |
161 base::mac::ObjCCastStrict<CollectionViewTextItem>( | 161 base::mac::ObjCCastStrict<CollectionViewTextItem>( |
162 [model itemAtIndexPath:indexPath]); | 162 [model itemAtIndexPath:indexPath]); |
163 newDefaultEngine.accessoryType = MDCCollectionViewCellAccessoryCheckmark; | 163 newDefaultEngine.accessoryType = MDCCollectionViewCellAccessoryCheckmark; |
164 [modifiedItems addObject:newDefaultEngine]; | 164 [modifiedItems addObject:newDefaultEngine]; |
165 | 165 |
166 // Set the new engine as the default. | 166 // Set the new engine as the default. |
167 [self setValueFromIndex:[model indexInItemTypeForIndexPath:indexPath]]; | 167 [self setValueFromIndex:[model indexInItemTypeForIndexPath:indexPath]]; |
168 | 168 |
169 [self reconfigureCellsForItems:modifiedItems | 169 [self reconfigureCellsForItems:modifiedItems]; |
170 inSectionWithIdentifier:SectionIdentifierSearchEngines]; | |
171 } | 170 } |
172 | 171 |
173 #pragma mark Internal methods | 172 #pragma mark Internal methods |
174 | 173 |
175 - (NSArray*)allValues { | 174 - (NSArray*)allValues { |
176 std::vector<TemplateURL*> urls = templateURLService_->GetTemplateURLs(); | 175 std::vector<TemplateURL*> urls = templateURLService_->GetTemplateURLs(); |
177 NSMutableArray* items = [NSMutableArray arrayWithCapacity:urls.size()]; | 176 NSMutableArray* items = [NSMutableArray arrayWithCapacity:urls.size()]; |
178 for (std::vector<TemplateURL*>::const_iterator iter = urls.begin(); | 177 for (std::vector<TemplateURL*>::const_iterator iter = urls.begin(); |
179 iter != urls.end(); ++iter) { | 178 iter != urls.end(); ++iter) { |
180 [items addObject:base::SysUTF16ToNSString((*iter)->short_name())]; | 179 [items addObject:base::SysUTF16ToNSString((*iter)->short_name())]; |
(...skipping 14 matching lines...) Expand all Loading... |
195 templateURLService_->SetUserSelectedDefaultSearchProvider(urls[index]); | 194 templateURLService_->SetUserSelectedDefaultSearchProvider(urls[index]); |
196 updatingBackend_ = NO; | 195 updatingBackend_ = NO; |
197 } | 196 } |
198 | 197 |
199 - (void)onChange { | 198 - (void)onChange { |
200 if (!updatingBackend_) | 199 if (!updatingBackend_) |
201 [self reloadData]; | 200 [self reloadData]; |
202 } | 201 } |
203 | 202 |
204 @end | 203 @end |
OLD | NEW |