Commit 05159fe7 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Adding Google services settings screen

Adding coordinator and an empty view controller for the Google services
settings. This work is related Unity.

Screenshots:
https://drive.google.com/open?id=175ZmSyXJQsz_EJMezwu0WhnUuGJM-xxZ
https://drive.google.com/open?id=1kHqvfmCxoN6IsDfsj9TR0VxdqzoBff-M

Mock:
https://docs.google.com/presentation/d/1cZfr5FGWGSy0PNaQ8uzik0alLAH-5glh1vsb030vha8/edit?ts=5aba5455#slide=id.g3b9ec33d4d_17_39

Test target added with: crrev.com/i/640917

Bug: 827072
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I7eb7ff3018a5bcef75e6c7ffddf79497a8a2fa38
Reviewed-on: https://chromium-review.googlesource.com/1096599Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568017}
parent a95dc41c
......@@ -693,6 +693,9 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_GOOGLE_APPS_SM_SETTINGS" desc="Title for the view in Settings for managing Google apps specific settings. Translate 'Google Apps'. [Length: 15em] [iOS only]">
Google Apps
</message>
<message name="IDS_IOS_GOOGLE_SERVICES_SETTINGS_TITLE" desc="Title for the view in the Settings for enabling/disabling Sync and all the Google services. [Length: 15em] [iOS only]">
Sync and Google Services
</message>
<message name="IDS_IOS_HISTORY_OTHER_FORMS_OF_HISTORY" desc="The notification at the top of the history page indicating that deleting Chrome browsing history will not delete other forms of history stored at Google My Activity.">
Your Google Account may have other forms of browsing history at <ph name="BEGIN_LINK">BEGIN_LINK</ph>history.google.com<ph name="END_LINK">END_LINK</ph>.
</message>
......
......@@ -42,6 +42,10 @@ initWithBaseViewController:(nullable UIViewController*)viewController
@property(weak, nonatomic, nullable, readonly)
UIViewController* baseViewController;
// The navigation controller this coordinator was initialized with.
@property(weak, nonatomic, nullable, readwrite)
UINavigationController* navigationController;
// The coordinator's BrowserState.
@property(assign, nonatomic, nullable, readonly)
ios::ChromeBrowserState* browserState;
......
......@@ -11,8 +11,10 @@
#endif
@implementation ChromeCoordinator
@synthesize childCoordinators = _childCoordinators;
@synthesize baseViewController = _baseViewController;
@synthesize navigationController = _navigationController;
@synthesize browserState = _browserState;
- (nullable instancetype)initWithBaseViewController:
......
......@@ -41,6 +41,10 @@ source_set("settings") {
"dataplan_usage_collection_view_controller.mm",
"do_not_track_collection_view_controller.h",
"do_not_track_collection_view_controller.mm",
"google_services_settings_coordinator.h",
"google_services_settings_coordinator.mm",
"google_services_settings_view_controller.h",
"google_services_settings_view_controller.mm",
"handoff_collection_view_controller.h",
"handoff_collection_view_controller.mm",
"import_data_collection_view_controller.h",
......@@ -401,3 +405,25 @@ source_set("eg_tests") {
"XCTest.framework",
]
}
source_set("unified_consent_eg_tests") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"google_services_settings_egtest.mm",
]
deps = [
":settings",
"//base",
"//base/test:test_support",
"//components/signin/core/browser",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/test/earl_grey:test_support",
"//ui/base",
]
libs = [
"UIKit.framework",
"XCTest.framework",
]
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_SETTINGS_COORDINATOR_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_SETTINGS_COORDINATOR_H_
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
@class GoogleServicesSettingsCoordinator;
// Delegate for GoogleServicesSettingsCoordinator.
@protocol GoogleServicesSettingsCoordinatorDelegate
// Called when the view controller is removed from navigation controller.
- (void)googleServicesSettingsCoordinatorDidRemove:
(GoogleServicesSettingsCoordinator*)coordinator;
@end
// Coordinator for the Google services settings view.
@interface GoogleServicesSettingsCoordinator : ChromeCoordinator
// View controller for the Google services settings.
@property(nonatomic, strong) UIViewController* viewController;
// Delegate.
@property(nonatomic, weak) id<GoogleServicesSettingsCoordinatorDelegate>
delegate;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_SETTINGS_COORDINATOR_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/google_services_settings_coordinator.h"
#import "ios/chrome/browser/ui/settings/google_services_settings_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface GoogleServicesSettingsCoordinator ()<
GoogleServicesSettingsViewControllerPresentationDelegate>
@end
@implementation GoogleServicesSettingsCoordinator
@synthesize delegate = _delegate;
@synthesize viewController = _viewController;
- (void)start {
UICollectionViewLayout* layout = [[MDCCollectionViewFlowLayout alloc] init];
GoogleServicesSettingsViewController* controller =
[[GoogleServicesSettingsViewController alloc]
initWithLayout:layout
style:CollectionViewControllerStyleAppBar];
controller.presentationDelegate = self;
self.viewController = controller;
DCHECK(self.navigationController);
[self.navigationController pushViewController:self.viewController
animated:YES];
}
#pragma mark - GoogleServicesSettingsViewControllerPresentationDelegate
- (void)googleServicesSettingsViewControllerDidRemove:
(GoogleServicesSettingsViewController*)controller {
DCHECK_EQ(self.viewController, controller);
[self.delegate googleServicesSettingsCoordinatorDidRemove:self];
}
@end
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <EarlGrey/EarlGrey.h>
#import <XCTest/XCTest.h>
#include "ios/chrome/grit/ios_strings.h"
#include "ios/chrome/test/earl_grey/accessibility_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using chrome_test_util::GoogleServicesSettingsButton;
using chrome_test_util::SettingsMenuBackButton;
using chrome_test_util::SettingsDoneButton;
// Integration tests using the Google services settings screen.
@interface GoogleServicesSettingsTestCase : ChromeTestCase
@end
@implementation GoogleServicesSettingsTestCase
// Opens the Google services settings view, and closes it.
- (void)testOpenGoogleServicesSettings {
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:GoogleServicesSettingsButton()];
// Assert title and accessibility.
[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(
@"google_services_settings_view_controller")]
assertWithMatcher:grey_notNil()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
// Close settings.
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
}
@end
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_SETTINGS_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_SETTINGS_VIEW_CONTROLLER_H_
#import "ios/chrome/browser/ui/settings/settings_root_collection_view_controller.h"
@class GoogleServicesSettingsViewController;
// Delegate for presentation events related to
// GoogleServicesSettingsViewController.
@protocol GoogleServicesSettingsViewControllerPresentationDelegate<NSObject>
// Called when the view controller is removed from its parent.
- (void)googleServicesSettingsViewControllerDidRemove:
(GoogleServicesSettingsViewController*)controller;
@end
// View controller to related to Google services settings.
@interface GoogleServicesSettingsViewController
: SettingsRootCollectionViewController
// Presentation delegate.
@property(nonatomic, weak)
id<GoogleServicesSettingsViewControllerPresentationDelegate>
presentationDelegate;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_SETTINGS_VIEW_CONTROLLER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/google_services_settings_view_controller.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation GoogleServicesSettingsViewController
@synthesize presentationDelegate = _presentationDelegate;
- (instancetype)initWithLayout:(UICollectionViewLayout*)layout
style:(CollectionViewControllerStyle)style {
self = [super initWithLayout:layout style:style];
if (self) {
self.collectionViewAccessibilityIdentifier =
@"google_services_settings_view_controller";
self.title = l10n_util::GetNSString(IDS_IOS_GOOGLE_SERVICES_SETTINGS_TITLE);
}
return self;
}
- (void)didMoveToParentViewController:(UIViewController*)parent {
[super didMoveToParentViewController:parent];
if (!parent) {
[self.presentationDelegate
googleServicesSettingsViewControllerDidRemove:self];
}
}
@end
......@@ -6,6 +6,7 @@
#include <memory>
#include "base/feature_list.h"
#import "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "components/autofill/core/common/autofill_pref_names.h"
......@@ -22,6 +23,7 @@
#include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/experimental_flags.h"
#include "ios/chrome/browser/ios_chrome_flag_descriptions.h"
#include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h"
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h"
......@@ -49,6 +51,7 @@
#import "ios/chrome/browser/ui/settings/bandwidth_management_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/cells/account_signin_item.h"
#import "ios/chrome/browser/ui/settings/content_settings_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/google_services_settings_coordinator.h"
#import "ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.h"
#import "ios/chrome/browser/ui/settings/privacy_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/save_passwords_collection_view_controller.h"
......@@ -101,6 +104,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeSignInButton = kItemTypeEnumZero,
ItemTypeSigninPromo,
ItemTypeAccount,
ItemGoogleServices,
ItemTypeHeader,
ItemTypeSearchEngine,
ItemTypeSavedPasswords,
......@@ -168,14 +172,16 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
#pragma mark - SettingsCollectionViewController
@interface SettingsCollectionViewController ()<BooleanObserver,
ChromeIdentityServiceObserver,
PrefObserverDelegate,
SettingsControllerProtocol,
SettingsMainPageCommands,
SigninPresenter,
SigninPromoViewConsumer,
SyncObserverModelBridge> {
@interface SettingsCollectionViewController ()<
BooleanObserver,
ChromeIdentityServiceObserver,
GoogleServicesSettingsCoordinatorDelegate,
PrefObserverDelegate,
SettingsControllerProtocol,
SettingsMainPageCommands,
SigninPresenter,
SigninPromoViewConsumer,
SyncObserverModelBridge> {
// The current browser state that hold the settings. Never off the record.
ios::ChromeBrowserState* _browserState; // weak
......@@ -195,6 +201,7 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
// Mediator to configure the sign-in promo cell. Also used to received
// identity update notifications.
SigninPromoViewMediator* _signinPromoViewMediator;
GoogleServicesSettingsCoordinator* _googleServicesSettingsCoordinator;
// Cached resized profile image.
UIImage* _resizedImage;
......@@ -362,6 +369,10 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
[model addItem:[self accountCellItem]
toSectionWithIdentifier:SectionIdentifierSignIn];
}
if (base::FeatureList::IsEnabled(signin::kUnifiedConsent)) {
[model addItem:[self googleServicesCellItem]
toSectionWithIdentifier:SectionIdentifierSignIn];
}
// Basics section
[model addSectionWithIdentifier:SectionIdentifierBasics];
......@@ -462,6 +473,13 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
return signInTextItem;
}
- (CollectionViewItem*)googleServicesCellItem {
return [self detailItemWithType:ItemGoogleServices
text:l10n_util::GetNSString(
IDS_IOS_GOOGLE_SERVICES_SETTINGS_TITLE)
detailText:nil];
}
- (CollectionViewItem*)accountCellItem {
CollectionViewAccountItem* identityAccountItem =
[[CollectionViewAccountItem alloc] initWithType:ItemTypeAccount];
......@@ -763,15 +781,17 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
initWithBrowserState:_browserState
closeSettingsOnAddAccount:NO];
break;
case ItemGoogleServices:
[self showSyncGoogleService];
break;
case ItemTypeSearchEngine:
controller = [[SearchEngineSettingsCollectionViewController alloc]
initWithBrowserState:_browserState];
break;
case ItemTypeSavedPasswords: {
case ItemTypeSavedPasswords:
controller = [[SavePasswordsCollectionViewController alloc]
initWithBrowserState:_browserState];
break;
}
case ItemTypeAutofill:
controller = [[AutofillCollectionViewController alloc]
initWithBrowserState:_browserState];
......@@ -919,6 +939,17 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
#pragma mark Private methods
- (void)showSyncGoogleService {
DCHECK(!_googleServicesSettingsCoordinator);
_googleServicesSettingsCoordinator =
[[GoogleServicesSettingsCoordinator alloc]
initWithBaseViewController:self.navigationController];
_googleServicesSettingsCoordinator.navigationController =
self.navigationController;
_googleServicesSettingsCoordinator.delegate = self;
[_googleServicesSettingsCoordinator start];
}
// Sets the NSUserDefaults BOOL |value| for |key|.
- (void)setBooleanNSUserDefaultsValue:(BOOL)value forKey:(NSString*)key {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
......@@ -1213,4 +1244,12 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
[self reloadData];
}
#pragma mark - GoogleServicesSettingsCoordinatorDelegate
- (void)googleServicesSettingsCoordinatorDidRemove:
(GoogleServicesSettingsCoordinator*)coordinator {
DCHECK_EQ(_googleServicesSettingsCoordinator, coordinator);
_googleServicesSettingsCoordinator = nil;
}
@end
......@@ -22,6 +22,7 @@ group("all_tests") {
":ios_chrome_smoke_egtests",
":ios_chrome_tab_grid_egtests",
":ios_chrome_ui_egtests",
":ios_chrome_unified_consent_egtests",
":ios_chrome_web_egtests",
]
}
......@@ -205,6 +206,12 @@ chrome_ios_eg_test("ios_chrome_external_url_egtests") {
]
}
chrome_ios_eg_test("ios_chrome_unified_consent_egtests") {
deps = [
"//ios/chrome/browser/ui/settings:unified_consent_eg_tests",
]
}
source_set("test_support") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
......
......@@ -166,6 +166,10 @@ id<GREYMatcher> AccountsSyncButton();
// Returns matcher for the Content Settings button on the main Settings screen.
id<GREYMatcher> ContentSettingsButton();
// Returns matcher for the Google Services Settings button on the main Settings
// screen.
id<GREYMatcher> GoogleServicesSettingsButton();
// Returns matcher for the back button on a settings menu.
id<GREYMatcher> SettingsMenuBackButton();
......
......@@ -358,6 +358,10 @@ id<GREYMatcher> ContentSettingsButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_CONTENT_SETTINGS_TITLE);
}
id<GREYMatcher> GoogleServicesSettingsButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_GOOGLE_SERVICES_SETTINGS_TITLE);
}
id<GREYMatcher> SettingsMenuBackButton() {
return grey_allOf(grey_accessibilityID(@"ic_arrow_back"),
grey_accessibilityTrait(UIAccessibilityTraitButton), nil);
......
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