Commit b59fb043 authored by Yi Su's avatar Yi Su Committed by Commit Bot

Migrate SearchEngineSettingsCollectionViewController from

CollectionViewController to ChromeTableViewController, and show search
engines' keywords in Settings.

This CL migrates the SearchEngineSettingsCollectionViewController from
CollectionViewController, which is based on MDCCollectionViewController,
to ChromeTableViewController, which is based on UITableViewController.

This CL also enables showing search engines' keywords in Settings for
security considerations.

Bug: 894791, 433824
Change-Id: I0eb6cf7081159d13cf389750f99ca13ee162c9d6
Reviewed-on: https://chromium-review.googlesource.com/c/1344134
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609781}
parent 27a03725
...@@ -74,8 +74,8 @@ source_set("settings") { ...@@ -74,8 +74,8 @@ source_set("settings") {
"reauthentication_protocol.h", "reauthentication_protocol.h",
"save_passwords_collection_view_controller.h", "save_passwords_collection_view_controller.h",
"save_passwords_collection_view_controller.mm", "save_passwords_collection_view_controller.mm",
"search_engine_settings_collection_view_controller.h", "search_engine_table_view_controller.h",
"search_engine_settings_collection_view_controller.mm", "search_engine_table_view_controller.mm",
"settings_collection_view_controller.h", "settings_collection_view_controller.h",
"settings_collection_view_controller.mm", "settings_collection_view_controller.mm",
"settings_navigation_controller.h", "settings_navigation_controller.h",
...@@ -285,7 +285,7 @@ source_set("unit_tests") { ...@@ -285,7 +285,7 @@ source_set("unit_tests") {
"privacy_table_view_controller_unittest.mm", "privacy_table_view_controller_unittest.mm",
"reauthentication_module_unittest.mm", "reauthentication_module_unittest.mm",
"save_passwords_collection_view_controller_unittest.mm", "save_passwords_collection_view_controller_unittest.mm",
"search_engine_settings_collection_view_controller_unittest.mm", "search_engine_table_view_controller_unittest.mm",
"settings_navigation_controller_unittest.mm", "settings_navigation_controller_unittest.mm",
"settings_root_collection_view_controller_unittest.mm", "settings_root_collection_view_controller_unittest.mm",
"settings_root_table_view_controller_unittest.mm", "settings_root_table_view_controller_unittest.mm",
......
...@@ -2,27 +2,26 @@ ...@@ -2,27 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_SEARCH_ENGINE_SETTINGS_COLLECTION_VIEW_CONTROLLER_H_ #ifndef IOS_CHROME_BROWSER_UI_SETTINGS_SEARCH_ENGINE_TABLE_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_SEARCH_ENGINE_SETTINGS_COLLECTION_VIEW_CONTROLLER_H_ #define IOS_CHROME_BROWSER_UI_SETTINGS_SEARCH_ENGINE_TABLE_VIEW_CONTROLLER_H_
#import "ios/chrome/browser/ui/settings/settings_root_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/settings_root_table_view_controller.h"
namespace ios { namespace ios {
class ChromeBrowserState; class ChromeBrowserState;
} // namespace ios } // namespace ios
// This class is the table view for the Search Engine settings. // This class is the table view for the Search Engine settings.
@interface SearchEngineSettingsCollectionViewController @interface SearchEngineTableViewController : SettingsRootTableViewController
: SettingsRootCollectionViewController
// The designated initializer. |browserState| must not be nil. // The designated initializer. |browserState| must not be nil.
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
NS_DESIGNATED_INITIALIZER; NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithTableViewStyle:(UITableViewStyle)style
- (instancetype)initWithLayout:(UICollectionViewLayout*)layout appBarStyle:
style:(CollectionViewControllerStyle)style (ChromeTableViewControllerStyle)appBarStyle
NS_UNAVAILABLE; NS_UNAVAILABLE;
@end @end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_SEARCH_ENGINE_SETTINGS_COLLECTION_VIEW_CONTROLLER_H_ #endif // IOS_CHROME_BROWSER_UI_SETTINGS_SEARCH_ENGINE_TABLE_VIEW_CONTROLLER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/search_engine_settings_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/search_engine_table_view_controller.h"
#include <memory> #include <memory>
...@@ -14,11 +14,9 @@ ...@@ -14,11 +14,9 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/search_engines/search_engine_observer_bridge.h" #import "ios/chrome/browser/search_engines/search_engine_observer_bridge.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_detail_text_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_text_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_text_header_footer_item.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h"
#import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -45,11 +43,10 @@ const char kUmaSelectDefaultSearchEngine[] = ...@@ -45,11 +43,10 @@ const char kUmaSelectDefaultSearchEngine[] =
} // namespace } // namespace
@interface SearchEngineSettingsCollectionViewController ()< @interface SearchEngineTableViewController ()<SearchEngineObserving>
SearchEngineObserving>
@end @end
@implementation SearchEngineSettingsCollectionViewController { @implementation SearchEngineTableViewController {
TemplateURLService* _templateURLService; // weak TemplateURLService* _templateURLService; // weak
std::unique_ptr<SearchEngineObserverBridge> _observer; std::unique_ptr<SearchEngineObserverBridge> _observer;
// Prevent unnecessary notifications when we write to the setting. // Prevent unnecessary notifications when we write to the setting.
...@@ -67,9 +64,9 @@ const char kUmaSelectDefaultSearchEngine[] = ...@@ -67,9 +64,9 @@ const char kUmaSelectDefaultSearchEngine[] =
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState { - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState {
DCHECK(browserState); DCHECK(browserState);
UICollectionViewLayout* layout = [[MDCCollectionViewFlowLayout alloc] init];
self = self =
[super initWithLayout:layout style:CollectionViewControllerStyleAppBar]; [super initWithTableViewStyle:UITableViewStyleGrouped
appBarStyle:ChromeTableViewControllerStyleWithAppBar];
if (self) { if (self) {
_templateURLService = _templateURLService =
ios::TemplateURLServiceFactory::GetForBrowserState(browserState); ios::TemplateURLServiceFactory::GetForBrowserState(browserState);
...@@ -77,17 +74,23 @@ const char kUmaSelectDefaultSearchEngine[] = ...@@ -77,17 +74,23 @@ const char kUmaSelectDefaultSearchEngine[] =
std::make_unique<SearchEngineObserverBridge>(self, _templateURLService); std::make_unique<SearchEngineObserverBridge>(self, _templateURLService);
_templateURLService->Load(); _templateURLService->Load();
[self setTitle:l10n_util::GetNSString(IDS_IOS_SEARCH_ENGINE_SETTING_TITLE)]; [self setTitle:l10n_util::GetNSString(IDS_IOS_SEARCH_ENGINE_SETTING_TITLE)];
[self setCollectionViewAccessibilityIdentifier:@"Search Engine"];
// TODO(crbug.com/764578): -loadModel should not be called from
// initializer. A possible fix is to move this call to -viewDidLoad.
[self loadModel];
} }
return self; return self;
} }
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self loadModel];
}
#pragma mark - ChromeTableViewController
- (void)loadModel { - (void)loadModel {
[super loadModel]; [super loadModel];
CollectionViewModel* model = self.collectionViewModel; TableViewModel* model = self.tableViewModel;
[self loadSearchEngines]; [self loadSearchEngines];
// Add prior search engines. // Add prior search engines.
...@@ -95,11 +98,12 @@ const char kUmaSelectDefaultSearchEngine[] = ...@@ -95,11 +98,12 @@ const char kUmaSelectDefaultSearchEngine[] =
[model addSectionWithIdentifier:SectionIdentifierPriorSearchEngines]; [model addSectionWithIdentifier:SectionIdentifierPriorSearchEngines];
for (TemplateURL* url : _priorSearchEngines) { for (TemplateURL* url : _priorSearchEngines) {
SettingsTextItem* engine = [[SettingsTextItem alloc] TableViewDetailTextItem* engine = [[TableViewDetailTextItem alloc]
initWithType:ItemTypePriorSearchEnginesEngine]; initWithType:ItemTypePriorSearchEnginesEngine];
[engine setText:base::SysUTF16ToNSString(url->short_name())]; engine.text = base::SysUTF16ToNSString(url->short_name());
engine.detailText = base::SysUTF16ToNSString(url->keyword());
if (url == _templateURLService->GetDefaultSearchProvider()) { if (url == _templateURLService->GetDefaultSearchProvider()) {
[engine setAccessoryType:MDCCollectionViewCellAccessoryCheckmark]; [engine setAccessoryType:UITableViewCellAccessoryCheckmark];
} }
[model addItem:engine [model addItem:engine
toSectionWithIdentifier:SectionIdentifierPriorSearchEngines]; toSectionWithIdentifier:SectionIdentifierPriorSearchEngines];
...@@ -110,20 +114,21 @@ const char kUmaSelectDefaultSearchEngine[] = ...@@ -110,20 +114,21 @@ const char kUmaSelectDefaultSearchEngine[] =
if (_customSearchEngines.size() > 0) { if (_customSearchEngines.size() > 0) {
[model addSectionWithIdentifier:SectionIdentifierCustomSearchEngines]; [model addSectionWithIdentifier:SectionIdentifierCustomSearchEngines];
SettingsTextItem* header = [[SettingsTextItem alloc] TableViewTextHeaderFooterItem* header =
[[TableViewTextHeaderFooterItem alloc]
initWithType:ItemTypeCustomSearchEnginesEngineHeader]; initWithType:ItemTypeCustomSearchEnginesEngineHeader];
header.text = l10n_util::GetNSString( header.text = l10n_util::GetNSString(
IDS_IOS_SEARCH_ENGINE_SETTING_CUSTOM_SECTION_HEADER); IDS_IOS_SEARCH_ENGINE_SETTING_CUSTOM_SECTION_HEADER);
header.textColor = [[MDCPalette greyPalette] tint500];
[model setHeader:header [model setHeader:header
forSectionWithIdentifier:SectionIdentifierCustomSearchEngines]; forSectionWithIdentifier:SectionIdentifierCustomSearchEngines];
for (TemplateURL* url : _customSearchEngines) { for (TemplateURL* url : _customSearchEngines) {
SettingsTextItem* engine = [[SettingsTextItem alloc] TableViewDetailTextItem* engine = [[TableViewDetailTextItem alloc]
initWithType:ItemTypeCustomSearchEnginesEngine]; initWithType:ItemTypeCustomSearchEnginesEngine];
[engine setText:base::SysUTF16ToNSString(url->short_name())]; engine.text = base::SysUTF16ToNSString(url->short_name());
engine.detailText = base::SysUTF16ToNSString(url->keyword());
if (url == _templateURLService->GetDefaultSearchProvider()) { if (url == _templateURLService->GetDefaultSearchProvider()) {
[engine setAccessoryType:MDCCollectionViewCellAccessoryCheckmark]; [engine setAccessoryType:UITableViewCellAccessoryCheckmark];
} }
[model addItem:engine [model addItem:engine
toSectionWithIdentifier:SectionIdentifierCustomSearchEngines]; toSectionWithIdentifier:SectionIdentifierCustomSearchEngines];
...@@ -131,25 +136,24 @@ const char kUmaSelectDefaultSearchEngine[] = ...@@ -131,25 +136,24 @@ const char kUmaSelectDefaultSearchEngine[] =
} }
} }
#pragma mark UICollectionViewDelegate #pragma mark UITableViewDelegate
- (void)collectionView:(UICollectionView*)collectionView - (void)tableView:(UITableView*)tableView
didSelectItemAtIndexPath:(NSIndexPath*)indexPath { didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
[super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; [super tableView:tableView didSelectRowAtIndexPath:indexPath];
CollectionViewModel* model = self.collectionViewModel; TableViewModel* model = self.tableViewModel;
// Only handle taps on search engine items. // Only handle taps on search engine items.
CollectionViewItem* selectedItem = [model itemAtIndexPath:indexPath]; TableViewItem* selectedItem = [model itemAtIndexPath:indexPath];
if (selectedItem.type != ItemTypePriorSearchEnginesEngine && if (selectedItem.type != ItemTypePriorSearchEnginesEngine &&
selectedItem.type != ItemTypeCustomSearchEnginesEngine) { selectedItem.type != ItemTypeCustomSearchEnginesEngine) {
return; return;
} }
// Do nothing if the tapped engine was already the default. // Do nothing if the tapped engine was already the default.
SettingsTextItem* selectedTextItem = TableViewDetailTextItem* selectedTextItem =
base::mac::ObjCCastStrict<SettingsTextItem>(selectedItem); base::mac::ObjCCastStrict<TableViewDetailTextItem>(selectedItem);
if (selectedTextItem.accessoryType == if (selectedTextItem.accessoryType == UITableViewCellAccessoryCheckmark) {
MDCCollectionViewCellAccessoryCheckmark) {
return; return;
} }
...@@ -158,42 +162,42 @@ const char kUmaSelectDefaultSearchEngine[] = ...@@ -158,42 +162,42 @@ const char kUmaSelectDefaultSearchEngine[] =
// Iterate through the engines and remove the checkmark from any that have it. // Iterate through the engines and remove the checkmark from any that have it.
if ([model if ([model
hasSectionForSectionIdentifier:SectionIdentifierPriorSearchEngines]) { hasSectionForSectionIdentifier:SectionIdentifierPriorSearchEngines]) {
for (CollectionViewItem* item in for (TableViewItem* item in
[model itemsInSectionWithIdentifier: [model itemsInSectionWithIdentifier:
SectionIdentifierPriorSearchEngines]) { SectionIdentifierPriorSearchEngines]) {
if (item.type != ItemTypePriorSearchEnginesEngine) { if (item.type != ItemTypePriorSearchEnginesEngine) {
continue; continue;
} }
SettingsTextItem* textItem = TableViewDetailTextItem* textItem =
base::mac::ObjCCastStrict<SettingsTextItem>(item); base::mac::ObjCCastStrict<TableViewDetailTextItem>(item);
if (textItem.accessoryType == MDCCollectionViewCellAccessoryCheckmark) { if (textItem.accessoryType == UITableViewCellAccessoryCheckmark) {
textItem.accessoryType = MDCCollectionViewCellAccessoryNone; textItem.accessoryType = UITableViewCellAccessoryNone;
[modifiedItems addObject:textItem]; [modifiedItems addObject:textItem];
} }
} }
} }
if ([model hasSectionForSectionIdentifier: if ([model hasSectionForSectionIdentifier:
SectionIdentifierCustomSearchEngines]) { SectionIdentifierCustomSearchEngines]) {
for (CollectionViewItem* item in for (TableViewItem* item in
[model itemsInSectionWithIdentifier: [model itemsInSectionWithIdentifier:
SectionIdentifierCustomSearchEngines]) { SectionIdentifierCustomSearchEngines]) {
if (item.type != ItemTypeCustomSearchEnginesEngine) { if (item.type != ItemTypeCustomSearchEnginesEngine) {
continue; continue;
} }
SettingsTextItem* textItem = TableViewDetailTextItem* textItem =
base::mac::ObjCCastStrict<SettingsTextItem>(item); base::mac::ObjCCastStrict<TableViewDetailTextItem>(item);
if (textItem.accessoryType == MDCCollectionViewCellAccessoryCheckmark) { if (textItem.accessoryType == UITableViewCellAccessoryCheckmark) {
textItem.accessoryType = MDCCollectionViewCellAccessoryNone; textItem.accessoryType = UITableViewCellAccessoryNone;
[modifiedItems addObject:textItem]; [modifiedItems addObject:textItem];
} }
} }
} }
// Show the checkmark on the new default engine. // Show the checkmark on the new default engine.
SettingsTextItem* newDefaultEngine = TableViewDetailTextItem* newDefaultEngine =
base::mac::ObjCCastStrict<SettingsTextItem>( base::mac::ObjCCastStrict<TableViewDetailTextItem>(
[model itemAtIndexPath:indexPath]); [model itemAtIndexPath:indexPath]);
newDefaultEngine.accessoryType = MDCCollectionViewCellAccessoryCheckmark; newDefaultEngine.accessoryType = UITableViewCellAccessoryCheckmark;
[modifiedItems addObject:newDefaultEngine]; [modifiedItems addObject:newDefaultEngine];
// Set the new engine as the default. // Set the new engine as the default.
...@@ -205,6 +209,7 @@ const char kUmaSelectDefaultSearchEngine[] = ...@@ -205,6 +209,7 @@ const char kUmaSelectDefaultSearchEngine[] =
[model indexInItemTypeForIndexPath:indexPath]]; [model indexInItemTypeForIndexPath:indexPath]];
[self reconfigureCellsForItems:modifiedItems]; [self reconfigureCellsForItems:modifiedItems];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
} }
#pragma mark Internal methods #pragma mark Internal methods
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/search_engine_settings_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/search_engine_table_view_controller.h"
#include <memory> #include <memory>
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
#include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/sync_preferences/testing_pref_service_syncable.h"
#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_detail_text_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_text_item.h" #import "ios/chrome/browser/ui/table_view/chrome_table_view_controller_test.h"
#import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h"
#include "ios/web/public/test/test_web_thread_bundle.h" #include "ios/web/public/test/test_web_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h" #import "testing/gtest_mac.h"
...@@ -36,11 +35,11 @@ namespace { ...@@ -36,11 +35,11 @@ namespace {
const char kUmaSelectDefaultSearchEngine[] = const char kUmaSelectDefaultSearchEngine[] =
"Search.iOS.SelectDefaultSearchEngine"; "Search.iOS.SelectDefaultSearchEngine";
class SearchEngineSettingsCollectionViewControllerTest class SearchEngineTableViewControllerTest
: public CollectionViewControllerTest { : public ChromeTableViewControllerTest {
protected: protected:
void SetUp() override { void SetUp() override {
CollectionViewControllerTest::SetUp(); ChromeTableViewControllerTest::SetUp();
TestChromeBrowserState::Builder test_cbs_builder; TestChromeBrowserState::Builder test_cbs_builder;
test_cbs_builder.AddTestingFactory( test_cbs_builder.AddTestingFactory(
ios::TemplateURLServiceFactory::GetInstance(), ios::TemplateURLServiceFactory::GetInstance(),
...@@ -52,18 +51,20 @@ class SearchEngineSettingsCollectionViewControllerTest ...@@ -52,18 +51,20 @@ class SearchEngineSettingsCollectionViewControllerTest
template_url_service_->Load(); template_url_service_->Load();
} }
CollectionViewController* InstantiateController() override { ChromeTableViewController* InstantiateController() override {
return [[SearchEngineSettingsCollectionViewController alloc] return [[SearchEngineTableViewController alloc]
initWithBrowserState:chrome_browser_state_.get()]; initWithBrowserState:chrome_browser_state_.get()];
} }
// Adds a prepopulated search engine to TemplateURLService. // Adds a prepopulated search engine to TemplateURLService.
TemplateURL* AddPriorSearchEngine(const std::string& short_name, TemplateURL* AddPriorSearchEngine(const std::string& short_name,
const std::string& keyword,
int prepopulate_id, int prepopulate_id,
bool set_default) { bool set_default) {
TemplateURLData data; TemplateURLData data;
data.SetShortName(base::ASCIIToUTF16(short_name)); data.SetShortName(base::ASCIIToUTF16(short_name));
data.SetURL("https://chromium.test/index.php?q={searchTerms}"); data.SetURL("https://chromium.test/index.php?q={searchTerms}");
data.SetKeyword(base::ASCIIToUTF16(keyword));
data.prepopulate_id = prepopulate_id; data.prepopulate_id = prepopulate_id;
TemplateURL* url = TemplateURL* url =
template_url_service_->Add(std::make_unique<TemplateURL>(data)); template_url_service_->Add(std::make_unique<TemplateURL>(data));
...@@ -74,11 +75,13 @@ class SearchEngineSettingsCollectionViewControllerTest ...@@ -74,11 +75,13 @@ class SearchEngineSettingsCollectionViewControllerTest
// Adds a custom search engine to TemplateURLService. // Adds a custom search engine to TemplateURLService.
TemplateURL* AddCustomSearchEngine(const std::string& short_name, TemplateURL* AddCustomSearchEngine(const std::string& short_name,
const std::string& keyword,
base::Time last_visited_time, base::Time last_visited_time,
bool set_default) { bool set_default) {
TemplateURLData data; TemplateURLData data;
data.SetShortName(base::ASCIIToUTF16(short_name)); data.SetShortName(base::ASCIIToUTF16(short_name));
data.SetURL("https://chromium.test/index.php?q={searchTerms}"); data.SetURL("https://chromium.test/index.php?q={searchTerms}");
data.SetKeyword(base::ASCIIToUTF16(keyword));
data.last_visited = last_visited_time; data.last_visited = last_visited_time;
TemplateURL* url = TemplateURL* url =
template_url_service_->Add(std::make_unique<TemplateURL>(data)); template_url_service_->Add(std::make_unique<TemplateURL>(data));
...@@ -87,13 +90,14 @@ class SearchEngineSettingsCollectionViewControllerTest ...@@ -87,13 +90,14 @@ class SearchEngineSettingsCollectionViewControllerTest
return url; return url;
} }
// Checks if a text cell in the CollectionView has a check mark. // Checks if a text cell in the TableView has a check mark.
void CheckTextCellChecked(bool expect_checked, int section, int item) { void CheckTextCellChecked(bool expect_checked, int section, int item) {
SettingsTextItem* text_item = base::mac::ObjCCastStrict<SettingsTextItem>( TableViewDetailTextItem* text_item =
GetCollectionViewItem(section, item)); base::mac::ObjCCastStrict<TableViewDetailTextItem>(
GetTableViewItem(section, item));
ASSERT_TRUE(text_item); ASSERT_TRUE(text_item);
EXPECT_EQ(expect_checked ? MDCCollectionViewCellAccessoryCheckmark EXPECT_EQ(expect_checked ? UITableViewCellAccessoryCheckmark
: MDCCollectionViewCellAccessoryNone, : UITableViewCellAccessoryNone,
text_item.accessoryType); text_item.accessoryType);
} }
...@@ -104,7 +108,7 @@ class SearchEngineSettingsCollectionViewControllerTest ...@@ -104,7 +108,7 @@ class SearchEngineSettingsCollectionViewControllerTest
}; };
// Tests that no items are shown if TemplateURLService is empty. // Tests that no items are shown if TemplateURLService is empty.
TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestNoUrl) { TEST_F(SearchEngineTableViewControllerTest, TestNoUrl) {
CreateController(); CreateController();
CheckController(); CheckController();
EXPECT_EQ(0, NumberOfSections()); EXPECT_EQ(0, NumberOfSections());
...@@ -112,110 +116,119 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestNoUrl) { ...@@ -112,110 +116,119 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestNoUrl) {
// Tests that items are displayed correctly when TemplateURLService is filled // Tests that items are displayed correctly when TemplateURLService is filled
// and a prepopulated search engine is selected as default. // and a prepopulated search engine is selected as default.
TEST_F(SearchEngineSettingsCollectionViewControllerTest, TEST_F(SearchEngineTableViewControllerTest,
TestUrlsLoadedWithPrepopulatedSearchEngineAsDefault) { TestUrlsLoadedWithPrepopulatedSearchEngineAsDefault) {
AddPriorSearchEngine("prepopulated-3", 3, false); AddPriorSearchEngine("prepopulated-3", "p3.com", 3, false);
AddPriorSearchEngine("prepopulated-1", 1, false); AddPriorSearchEngine("prepopulated-1", "p1.com", 1, false);
AddPriorSearchEngine("prepopulated-2", 2, true); AddPriorSearchEngine("prepopulated-2", "p2.com", 2, true);
AddCustomSearchEngine( AddCustomSearchEngine("custom-4", "c4.com",
"custom-4", base::Time::Now() - base::TimeDelta::FromDays(10), false); base::Time::Now() - base::TimeDelta::FromDays(10),
AddCustomSearchEngine( false);
"custom-1", base::Time::Now() - base::TimeDelta::FromSeconds(10), false); AddCustomSearchEngine("custom-1", "c1.com",
AddCustomSearchEngine( base::Time::Now() - base::TimeDelta::FromSeconds(10),
"custom-3", base::Time::Now() - base::TimeDelta::FromHours(10), false); false);
AddCustomSearchEngine( AddCustomSearchEngine("custom-3", "c3.com",
"custom-2", base::Time::Now() - base::TimeDelta::FromMinutes(10), false); base::Time::Now() - base::TimeDelta::FromHours(10),
false);
AddCustomSearchEngine("custom-2", "c2.com",
base::Time::Now() - base::TimeDelta::FromMinutes(10),
false);
CreateController(); CreateController();
CheckController(); CheckController();
ASSERT_EQ(2, NumberOfSections()); ASSERT_EQ(2, NumberOfSections());
ASSERT_EQ(3, NumberOfItemsInSection(0)); ASSERT_EQ(3, NumberOfItemsInSection(0));
CheckTextCellTitle(@"prepopulated-1", 0, 0); CheckTextCellTextAndDetailText(@"prepopulated-1", @"p1.com", 0, 0);
CheckTextCellChecked(false, 0, 0); CheckTextCellChecked(false, 0, 0);
CheckTextCellTitle(@"prepopulated-2", 0, 1); CheckTextCellTextAndDetailText(@"prepopulated-2", @"p2.com", 0, 1);
CheckTextCellChecked(true, 0, 1); CheckTextCellChecked(true, 0, 1);
CheckTextCellTitle(@"prepopulated-3", 0, 2); CheckTextCellTextAndDetailText(@"prepopulated-3", @"p3.com", 0, 2);
CheckTextCellChecked(false, 0, 2); CheckTextCellChecked(false, 0, 2);
ASSERT_EQ(3, NumberOfItemsInSection(1)); ASSERT_EQ(3, NumberOfItemsInSection(1));
CheckTextCellTitle(@"custom-1", 1, 0); CheckTextCellTextAndDetailText(@"custom-1", @"c1.com", 1, 0);
CheckTextCellChecked(false, 1, 0); CheckTextCellChecked(false, 1, 0);
CheckTextCellTitle(@"custom-2", 1, 1); CheckTextCellTextAndDetailText(@"custom-2", @"c2.com", 1, 1);
CheckTextCellChecked(false, 1, 1); CheckTextCellChecked(false, 1, 1);
CheckTextCellTitle(@"custom-3", 1, 2); CheckTextCellTextAndDetailText(@"custom-3", @"c3.com", 1, 2);
CheckTextCellChecked(false, 1, 2); CheckTextCellChecked(false, 1, 2);
} }
// Tests that items are displayed correctly when TemplateURLService is filled // Tests that items are displayed correctly when TemplateURLService is filled
// and a custom search engine is selected as default. // and a custom search engine is selected as default.
TEST_F(SearchEngineSettingsCollectionViewControllerTest, TEST_F(SearchEngineTableViewControllerTest,
TestUrlsLoadedWithCustomSearchEngineAsDefault) { TestUrlsLoadedWithCustomSearchEngineAsDefault) {
AddPriorSearchEngine("prepopulated-3", 3, false); AddPriorSearchEngine("prepopulated-3", "p3.com", 3, false);
AddPriorSearchEngine("prepopulated-1", 1, false); AddPriorSearchEngine("prepopulated-1", "p1.com", 1, false);
AddPriorSearchEngine("prepopulated-2", 2, false); AddPriorSearchEngine("prepopulated-2", "p2.com", 2, false);
AddCustomSearchEngine( AddCustomSearchEngine("custom-4", "c4.com",
"custom-4", base::Time::Now() - base::TimeDelta::FromDays(10), false); base::Time::Now() - base::TimeDelta::FromDays(10),
AddCustomSearchEngine( false);
"custom-1", base::Time::Now() - base::TimeDelta::FromSeconds(10), false); AddCustomSearchEngine("custom-1", "c1.com",
AddCustomSearchEngine( base::Time::Now() - base::TimeDelta::FromSeconds(10),
"custom-3", base::Time::Now() - base::TimeDelta::FromHours(10), false); false);
AddCustomSearchEngine( AddCustomSearchEngine("custom-3", "c3.com",
"custom-2", base::Time::Now() - base::TimeDelta::FromMinutes(10), true); base::Time::Now() - base::TimeDelta::FromHours(10),
false);
AddCustomSearchEngine("custom-2", "c2.com",
base::Time::Now() - base::TimeDelta::FromMinutes(10),
true);
CreateController(); CreateController();
CheckController(); CheckController();
ASSERT_EQ(2, NumberOfSections()); ASSERT_EQ(2, NumberOfSections());
ASSERT_EQ(4, NumberOfItemsInSection(0)); ASSERT_EQ(4, NumberOfItemsInSection(0));
CheckTextCellTitle(@"prepopulated-1", 0, 0); CheckTextCellTextAndDetailText(@"prepopulated-1", @"p1.com", 0, 0);
CheckTextCellChecked(false, 0, 0); CheckTextCellChecked(false, 0, 0);
CheckTextCellTitle(@"prepopulated-2", 0, 1); CheckTextCellTextAndDetailText(@"prepopulated-2", @"p2.com", 0, 1);
CheckTextCellChecked(false, 0, 1); CheckTextCellChecked(false, 0, 1);
CheckTextCellTitle(@"prepopulated-3", 0, 2); CheckTextCellTextAndDetailText(@"prepopulated-3", @"p3.com", 0, 2);
CheckTextCellChecked(false, 0, 2); CheckTextCellChecked(false, 0, 2);
CheckTextCellTitle(@"custom-2", 0, 3); CheckTextCellTextAndDetailText(@"custom-2", @"c2.com", 0, 3);
CheckTextCellChecked(true, 0, 3); CheckTextCellChecked(true, 0, 3);
ASSERT_EQ(2, NumberOfItemsInSection(1)); ASSERT_EQ(2, NumberOfItemsInSection(1));
CheckTextCellTitle(@"custom-1", 1, 0); CheckTextCellTextAndDetailText(@"custom-1", @"c1.com", 1, 0);
CheckTextCellChecked(false, 1, 0); CheckTextCellChecked(false, 1, 0);
CheckTextCellTitle(@"custom-3", 1, 1); CheckTextCellTextAndDetailText(@"custom-3", @"c3.com", 1, 1);
CheckTextCellChecked(false, 1, 1); CheckTextCellChecked(false, 1, 1);
} }
// Tests that when TemplateURLService add or remove TemplateURLs, or update // Tests that when TemplateURLService add or remove TemplateURLs, or update
// default search engine, the controller will update the displayed items. // default search engine, the controller will update the displayed items.
TEST_F(SearchEngineSettingsCollectionViewControllerTest, TEST_F(SearchEngineTableViewControllerTest, TestUrlModifiedByService) {
TestUrlModifiedByService) { TemplateURL* url_p1 =
TemplateURL* url_p1 = AddPriorSearchEngine("prepopulated-1", 1, true); AddPriorSearchEngine("prepopulated-1", "p1.com", 1, true);
CreateController(); CreateController();
CheckController(); CheckController();
ASSERT_EQ(1, NumberOfSections()); ASSERT_EQ(1, NumberOfSections());
ASSERT_EQ(1, NumberOfItemsInSection(0)); ASSERT_EQ(1, NumberOfItemsInSection(0));
CheckTextCellTitle(@"prepopulated-1", 0, 0); CheckTextCellTextAndDetailText(@"prepopulated-1", @"p1.com", 0, 0);
CheckTextCellChecked(true, 0, 0); CheckTextCellChecked(true, 0, 0);
TemplateURL* url_p2 = AddPriorSearchEngine("prepopulated-2", 2, false); TemplateURL* url_p2 =
AddPriorSearchEngine("prepopulated-2", "p2.com", 2, false);
ASSERT_EQ(1, NumberOfSections()); ASSERT_EQ(1, NumberOfSections());
ASSERT_EQ(2, NumberOfItemsInSection(0)); ASSERT_EQ(2, NumberOfItemsInSection(0));
CheckTextCellTitle(@"prepopulated-1", 0, 0); CheckTextCellTextAndDetailText(@"prepopulated-1", @"p1.com", 0, 0);
CheckTextCellChecked(true, 0, 0); CheckTextCellChecked(true, 0, 0);
CheckTextCellTitle(@"prepopulated-2", 0, 1); CheckTextCellTextAndDetailText(@"prepopulated-2", @"p2.com", 0, 1);
CheckTextCellChecked(false, 0, 1); CheckTextCellChecked(false, 0, 1);
template_url_service_->SetUserSelectedDefaultSearchProvider(url_p2); template_url_service_->SetUserSelectedDefaultSearchProvider(url_p2);
ASSERT_EQ(1, NumberOfSections()); ASSERT_EQ(1, NumberOfSections());
ASSERT_EQ(2, NumberOfItemsInSection(0)); ASSERT_EQ(2, NumberOfItemsInSection(0));
CheckTextCellTitle(@"prepopulated-1", 0, 0); CheckTextCellTextAndDetailText(@"prepopulated-1", @"p1.com", 0, 0);
CheckTextCellChecked(false, 0, 0); CheckTextCellChecked(false, 0, 0);
CheckTextCellTitle(@"prepopulated-2", 0, 1); CheckTextCellTextAndDetailText(@"prepopulated-2", @"p2.com", 0, 1);
CheckTextCellChecked(true, 0, 1); CheckTextCellChecked(true, 0, 1);
template_url_service_->SetUserSelectedDefaultSearchProvider(url_p1); template_url_service_->SetUserSelectedDefaultSearchProvider(url_p1);
...@@ -223,13 +236,13 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest, ...@@ -223,13 +236,13 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest,
ASSERT_EQ(1, NumberOfSections()); ASSERT_EQ(1, NumberOfSections());
ASSERT_EQ(1, NumberOfItemsInSection(0)); ASSERT_EQ(1, NumberOfItemsInSection(0));
CheckTextCellTitle(@"prepopulated-1", 0, 0); CheckTextCellTextAndDetailText(@"prepopulated-1", @"p1.com", 0, 0);
CheckTextCellChecked(true, 0, 0); CheckTextCellChecked(true, 0, 0);
} }
// Tests that when user change default search engine, all items can be displayed // Tests that when user change default search engine, all items can be displayed
// correctly and the change can be synced to the prefs. // correctly and the change can be synced to the prefs.
TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestChangeProvider) { TEST_F(SearchEngineTableViewControllerTest, TestChangeProvider) {
// This test also needs to test the UMA, so load some real prepopulated search // This test also needs to test the UMA, so load some real prepopulated search
// engines to ensure the SearchEngineType is logged correctly. Don't use any // engines to ensure the SearchEngineType is logged correctly. Don't use any
// literal symbol(e.g. "google" or "AOL") from // literal symbol(e.g. "google" or "AOL") from
...@@ -256,32 +269,35 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestChangeProvider) { ...@@ -256,32 +269,35 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestChangeProvider) {
// Also add some custom search engines. // Also add some custom search engines.
TemplateURL* url_c1 = TemplateURL* url_c1 =
AddCustomSearchEngine("custom-1", base::Time::Now(), false); AddCustomSearchEngine("custom-1", "c1.com", base::Time::Now(), false);
AddCustomSearchEngine( AddCustomSearchEngine("custom-2", "c2.com",
"custom-2", base::Time::Now() - base::TimeDelta::FromSeconds(10), false); base::Time::Now() - base::TimeDelta::FromSeconds(10),
false);
CreateController(); CreateController();
CheckController(); CheckController();
// Choose url_p1 as default. // Choose url_p1 as default.
[controller() collectionView:[controller() collectionView] [controller() tableView:[controller() tableView]
didSelectItemAtIndexPath:[NSIndexPath indexPathForRow:url_p1_index didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:url_p1_index
inSection:0]]; inSection:0]];
ASSERT_EQ(2, NumberOfSections()); ASSERT_EQ(2, NumberOfSections());
// Check first list. // Check first list.
ASSERT_EQ(2, NumberOfItemsInSection(0)); ASSERT_EQ(2, NumberOfItemsInSection(0));
CheckTextCellTitle(base::SysUTF16ToNSString(url_p1->short_name()), 0, CheckTextCellTextAndDetailText(base::SysUTF16ToNSString(url_p1->short_name()),
base::SysUTF16ToNSString(url_p1->keyword()), 0,
url_p1_index); url_p1_index);
CheckTextCellChecked(true, 0, url_p1_index); CheckTextCellChecked(true, 0, url_p1_index);
CheckTextCellTitle(base::SysUTF16ToNSString(url_p2->short_name()), 0, CheckTextCellTextAndDetailText(base::SysUTF16ToNSString(url_p2->short_name()),
base::SysUTF16ToNSString(url_p2->keyword()), 0,
url_p2_index); url_p2_index);
CheckTextCellChecked(false, 0, url_p2_index); CheckTextCellChecked(false, 0, url_p2_index);
// Check second list. // Check second list.
ASSERT_EQ(2, NumberOfItemsInSection(1)); ASSERT_EQ(2, NumberOfItemsInSection(1));
CheckTextCellTitle(@"custom-1", 1, 0); CheckTextCellTextAndDetailText(@"custom-1", @"c1.com", 1, 0);
CheckTextCellChecked(false, 1, 0); CheckTextCellChecked(false, 1, 0);
CheckTextCellTitle(@"custom-2", 1, 1); CheckTextCellTextAndDetailText(@"custom-2", @"c2.com", 1, 1);
CheckTextCellChecked(false, 1, 1); CheckTextCellChecked(false, 1, 1);
// Check default search engine. // Check default search engine.
EXPECT_EQ(url_p1, template_url_service_->GetDefaultSearchProvider()); EXPECT_EQ(url_p1, template_url_service_->GetDefaultSearchProvider());
...@@ -291,24 +307,26 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestChangeProvider) { ...@@ -291,24 +307,26 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestChangeProvider) {
url_p1->GetEngineType(template_url_service_->search_terms_data()), 1); url_p1->GetEngineType(template_url_service_->search_terms_data()), 1);
// Choose url_p2 as default. // Choose url_p2 as default.
[controller() collectionView:[controller() collectionView] [controller() tableView:[controller() tableView]
didSelectItemAtIndexPath:[NSIndexPath indexPathForRow:url_p2_index didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:url_p2_index
inSection:0]]; inSection:0]];
ASSERT_EQ(2, NumberOfSections()); ASSERT_EQ(2, NumberOfSections());
// Check first list. // Check first list.
ASSERT_EQ(2, NumberOfItemsInSection(0)); ASSERT_EQ(2, NumberOfItemsInSection(0));
CheckTextCellTitle(base::SysUTF16ToNSString(url_p1->short_name()), 0, CheckTextCellTextAndDetailText(base::SysUTF16ToNSString(url_p1->short_name()),
base::SysUTF16ToNSString(url_p1->keyword()), 0,
url_p1_index); url_p1_index);
CheckTextCellChecked(false, 0, url_p1_index); CheckTextCellChecked(false, 0, url_p1_index);
CheckTextCellTitle(base::SysUTF16ToNSString(url_p2->short_name()), 0, CheckTextCellTextAndDetailText(base::SysUTF16ToNSString(url_p2->short_name()),
base::SysUTF16ToNSString(url_p2->keyword()), 0,
url_p2_index); url_p2_index);
CheckTextCellChecked(true, 0, url_p2_index); CheckTextCellChecked(true, 0, url_p2_index);
// Check second list. // Check second list.
ASSERT_EQ(2, NumberOfItemsInSection(1)); ASSERT_EQ(2, NumberOfItemsInSection(1));
CheckTextCellTitle(@"custom-1", 1, 0); CheckTextCellTextAndDetailText(@"custom-1", @"c1.com", 1, 0);
CheckTextCellChecked(false, 1, 0); CheckTextCellChecked(false, 1, 0);
CheckTextCellTitle(@"custom-2", 1, 1); CheckTextCellTextAndDetailText(@"custom-2", @"c2.com", 1, 1);
CheckTextCellChecked(false, 1, 1); CheckTextCellChecked(false, 1, 1);
// Check default search engine. // Check default search engine.
EXPECT_EQ(url_p2, template_url_service_->GetDefaultSearchProvider()); EXPECT_EQ(url_p2, template_url_service_->GetDefaultSearchProvider());
...@@ -322,23 +340,25 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestChangeProvider) { ...@@ -322,23 +340,25 @@ TEST_F(SearchEngineSettingsCollectionViewControllerTest, TestChangeProvider) {
histogram_tester_.ExpectTotalCount(kUmaSelectDefaultSearchEngine, 2); histogram_tester_.ExpectTotalCount(kUmaSelectDefaultSearchEngine, 2);
// Choose url_c1 as default. // Choose url_c1 as default.
[controller() collectionView:[controller() collectionView] [controller() tableView:[controller() tableView]
didSelectItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]]; didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]];
ASSERT_EQ(2, NumberOfSections()); ASSERT_EQ(2, NumberOfSections());
// Check first list. // Check first list.
ASSERT_EQ(2, NumberOfItemsInSection(0)); ASSERT_EQ(2, NumberOfItemsInSection(0));
CheckTextCellTitle(base::SysUTF16ToNSString(url_p1->short_name()), 0, CheckTextCellTextAndDetailText(base::SysUTF16ToNSString(url_p1->short_name()),
base::SysUTF16ToNSString(url_p1->keyword()), 0,
url_p1_index); url_p1_index);
CheckTextCellChecked(false, 0, url_p1_index); CheckTextCellChecked(false, 0, url_p1_index);
CheckTextCellTitle(base::SysUTF16ToNSString(url_p2->short_name()), 0, CheckTextCellTextAndDetailText(base::SysUTF16ToNSString(url_p2->short_name()),
base::SysUTF16ToNSString(url_p2->keyword()), 0,
url_p2_index); url_p2_index);
CheckTextCellChecked(false, 0, url_p2_index); CheckTextCellChecked(false, 0, url_p2_index);
// Check second list. // Check second list.
ASSERT_EQ(2, NumberOfItemsInSection(1)); ASSERT_EQ(2, NumberOfItemsInSection(1));
CheckTextCellTitle(@"custom-1", 1, 0); CheckTextCellTextAndDetailText(@"custom-1", @"c1.com", 1, 0);
CheckTextCellChecked(true, 1, 0); CheckTextCellChecked(true, 1, 0);
CheckTextCellTitle(@"custom-2", 1, 1); CheckTextCellTextAndDetailText(@"custom-2", @"c2.com", 1, 1);
CheckTextCellChecked(false, 1, 1); CheckTextCellChecked(false, 1, 1);
// Check default search engine. // Check default search engine.
EXPECT_EQ(url_c1, template_url_service_->GetDefaultSearchProvider()); EXPECT_EQ(url_c1, template_url_service_->GetDefaultSearchProvider());
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#import "ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.h" #import "ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.h"
#import "ios/chrome/browser/ui/settings/privacy_table_view_controller.h" #import "ios/chrome/browser/ui/settings/privacy_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/save_passwords_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/save_passwords_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/search_engine_settings_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/search_engine_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/sync_utils/sync_util.h" #import "ios/chrome/browser/ui/settings/sync_utils/sync_util.h"
#import "ios/chrome/browser/ui/settings/table_cell_catalog_view_controller.h" #import "ios/chrome/browser/ui/settings/table_cell_catalog_view_controller.h"
#import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h"
...@@ -855,7 +855,7 @@ void IdentityObserverBridge::OnPrimaryAccountCleared( ...@@ -855,7 +855,7 @@ void IdentityObserverBridge::OnPrimaryAccountCleared(
[self showSyncGoogleService]; [self showSyncGoogleService];
break; break;
case ItemTypeSearchEngine: case ItemTypeSearchEngine:
controller = [[SearchEngineSettingsCollectionViewController alloc] controller = [[SearchEngineTableViewController alloc]
initWithBrowserState:_browserState]; initWithBrowserState:_browserState];
break; break;
case ItemTypeSavedPasswords: case ItemTypeSavedPasswords:
......
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
// using shouldHideDoneButton to know if it should display the edit button. // using shouldHideDoneButton to know if it should display the edit button.
- (void)updateEditButton; - (void)updateEditButton;
// Reloads the table view model with |loadModel| and then reloads the
// table view data.
- (void)reloadData;
@end @end
// Subclasses of SettingsRootTableViewController should implement the // Subclasses of SettingsRootTableViewController should implement the
......
...@@ -47,6 +47,11 @@ ...@@ -47,6 +47,11 @@
} }
} }
- (void)reloadData {
[self loadModel];
[self.tableView reloadData];
}
#pragma mark - Property #pragma mark - Property
- (UIBarButtonItem*)deleteButton { - (UIBarButtonItem*)deleteButton {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment