Commit 1c42fa01 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Chromium LUCI CQ
parent dee00e24
......@@ -325,6 +325,12 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_SIGN_IN_TO_CHROME_SETTING_TITLE" desc="The title for the setting item to Sign in to Chromium [iOS only]">
Sign in to Chromium
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_TITLE_WITH_MANAGED_ACCOUNT" desc="The signout dialog title. This dialog is used when the user have a managed account (other than gmail account). Related to IDS_IOS_SIGNOUT_DIALOG_MESSAGE_WITH_MANAGED_ACCOUNT [iOS only].">
Clear your Chromium data from this device?
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_MESSAGE_WITH_MANAGED_ACCOUNT" desc="The signout dialog message. This dialog is used when the user have a managed account (other than gmail account). Related to IDS_IOS_SIGNOUT_DIALOG_TITLE_WITH_MANAGED_ACCOUNT [iOS only].">
Because your account is managed by <ph name="HOSTED_DOMAIN">$1<ex>google.com</ex></ph>, your Chromium data will be deleted from this device when signing out. Your synced data will remain in your Google Account.
</message>
<message name="IDS_IOS_TAB_SWITCHER_NO_TABS_TO_SYNC_PROMO" desc="The title of the paragraph IDS_OPEN_TABS_NO_SESSION_INSTRUCTIONS_IOS. The paragraph explains that tabs opened on other devices where the user is signed in will appear here, in the Tab Switcher. [iOS only]">
Use Chromium Everywhere
</message>
......
......@@ -325,6 +325,12 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_SIGN_IN_TO_CHROME_SETTING_TITLE" desc="The title for the setting item to Sign in to Chrome [iOS only]">
Sign in to Chrome
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_TITLE_WITH_MANAGED_ACCOUNT" desc="The signout dialog title. This dialog is used when the user have a managed account (other than gmail account). Related to IDS_IOS_SIGNOUT_DIALOG_MESSAGE_WITH_MANAGED_ACCOUNT [iOS only].">
Clear your Chrome data from this device?
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_MESSAGE_WITH_MANAGED_ACCOUNT" desc="The signout dialog message. This dialog is used when the user have a managed account (other than gmail account). Related to IDS_IOS_SIGNOUT_DIALOG_TITLE_WITH_MANAGED_ACCOUNT [iOS only].">
Because your account is managed by <ph name="HOSTED_DOMAIN">$1<ex>google.com</ex></ph>, your Chrome data will be deleted from this device when signing out. Your synced data will remain in your Google Account.
</message>
<message name="IDS_IOS_TAB_SWITCHER_NO_TABS_TO_SYNC_PROMO" desc="The title of the paragraph IDS_OPEN_TABS_NO_SESSION_INSTRUCTIONS_IOS. The paragraph explains that tabs opened on other devices where the user is signed in will appear here, in the Tab Switcher. [iOS only]">
Use Chrome Everywhere
</message>
......
......@@ -2160,6 +2160,24 @@ Try to use a unique password for every site.
<message name="IDS_IOS_SIGNIN_ACCOUNT_NOTIFICATION_TITLE_WITH_USERNAME" desc="Notification title for the user's signed-in state that includes the user's full name [iOS only]">
Signed in as <ph name="USER">$1<ex>Jane Doe</ex></ph>
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_CLEAR_DATA_BUTTON" desc="This button signs the user out and clear all the data from the user device. The data is still remain in their Google account. Related to IDS_IOS_SIGNOUT_DIALOG_TITLE [iOS only].">
Clear from this Device
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_KEEP_DATA_BUTTON" desc="This button signs the user out and all its data stays on the device. Related to IDS_IOS_SIGNOUT_DIALOG_TITLE [iOS only].">
Keep on this Device
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_MESSAGE_WITH_SYNC" desc="The signout dialog message. This dialog is used when the user have a gmail account and sync is turned on. Related to IDS_IOS_SIGNOUT_DIALOG_TITLE [iOS only].">
Your synced data will remain in your Google Account.
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_TITLE_WITH_SYNC" desc="The signout dialog title. This dialog is used when the user have a gmail account and sync is turned on. Related to IDS_IOS_SIGNOUT_DIALOG_MESSAGE [iOS only].">
What would you like to do with your bookmarks, history and other data on this device?
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_TITLE_WITHOUT_SYNC" desc="The signout dialog title. This dialog is used when the user have a gmail account and sync is turned on. Related to IDS_IOS_SIGNOUT_DIALOG_MESSAGE [iOS only].">
Sign Out?
</message>
<message name="IDS_IOS_SIGNOUT_DIALOG_SIGN_OUT_BUTTON" desc="This button signs the user out. Related to IDS_IOS_SIGNOUT_DIALOG_TITLE [iOS only].">
Sign Out
</message>
<message name="IDS_IOS_SPOTLIGHT_KEYWORD_EIGHT" desc="Keyword used in Spotlight that will be linked to the Chrome App. [iOS only]">
Online
</message>
......
875c95fb6efb766f12d51f4574ed92a4b4db574a
\ No newline at end of file
875c95fb6efb766f12d51f4574ed92a4b4db574a
\ No newline at end of file
875c95fb6efb766f12d51f4574ed92a4b4db574a
\ No newline at end of file
47b2a8ec1b96d02ba7904a903d533fefef803c9a
\ No newline at end of file
47b2a8ec1b96d02ba7904a903d533fefef803c9a
\ No newline at end of file
875c95fb6efb766f12d51f4574ed92a4b4db574a
\ No newline at end of file
......@@ -29,7 +29,6 @@ source_set("authentication") {
"resources:signin_confirmation_more",
"resources:signin_promo_close_gray",
"unified_consent",
"//base",
"//components/consent_auditor",
"//components/infobars/core",
"//components/prefs",
......@@ -67,6 +66,7 @@ source_set("authentication") {
"//ui/gfx",
]
public_deps = [
"//base",
"//ios/chrome/browser/ui/authentication/signin:constants",
"//ios/chrome/browser/ui/collection_view",
]
......
......@@ -8,10 +8,44 @@
#import <UIKit/UIKit.h>
#include "base/ios/block_types.h"
#include "base/strings/string16.h"
@class AlertCoordinator;
@class ActionSheetCoordinator;
class Browser;
// Sign-out result, related to SignoutActionSheetCoordinator().
typedef NS_ENUM(NSUInteger, SignoutActionSheetCoordinatorResult) {
// The user canceled the sign-out confirmation dialog.
SignoutActionSheetCoordinatorResultCanceled,
// The user chose to sign-out and clear their data from the device.
SignoutActionSheetCoordinatorResultClearFromDevice,
// The user chose to sign-out and keep their data on the device.
SignoutActionSheetCoordinatorResultKeepOnDevice,
};
// Sign-out completion block.
using SignoutActionSheetCoordinatorCompletion =
void (^)(SignoutActionSheetCoordinatorResult result);
// Returns the hosted domain for the primary account.
base::string16 HostedDomainForPrimaryAccount(Browser* browser);
// Returns ActionSheetCoordinator to ask the sign-out confirmation from the
// user. The alert sheet dialog choices are based if the primary account is
// managed account or not, and if the user turned on sync or not.
// The caller is in charge to start the coordinator.
// The caller is in charge to sign-out the user and wipe the data from the
// device according to |signout_completion| value.
// |view_controller| view controller to present the action sheet.
// |view| to position the action sheet for iPad.
// |signout_completion| invoked when the user confirms or cancels sign-out.
ActionSheetCoordinator* SignoutActionSheetCoordinator(
UIViewController* view_controller,
Browser* browser,
UIView* view,
SignoutActionSheetCoordinatorCompletion signout_completion);
// Returns the sign in alert coordinator for |error|. |dismissAction| is called
// when the dialog is dismissed (the user taps on the Ok button) or cancelled
// (the alert coordinator is cancelled programatically).
......
......@@ -4,17 +4,161 @@
#import "ios/chrome/browser/ui/authentication/authentication_ui_util.h"
#include "base/check.h"
#include "base/format_macros.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
#import "base/check.h"
#import "base/format_macros.h"
#import "base/strings/utf_string_conversions.h"
#import "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/signin/authentication_service.h"
#import "ios/chrome/browser/signin/authentication_service_factory.h"
#import "ios/chrome/browser/signin/identity_manager_factory.h"
#import "ios/chrome/browser/sync/sync_setup_service.h"
#import "ios/chrome/browser/sync/sync_setup_service_factory.h"
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
#import "ios/chrome/grit/ios_chromium_strings.h"
#import "ios/chrome/grit/ios_strings.h"
#import "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Enum to described all 4 cases for a user being signed-in. This enum is used
// internaly by SignoutActionSheetCoordinator().
typedef NS_ENUM(NSUInteger, SignedInUserState) {
// Sign-in with a managed account and sync is turned on.
SignedInUserStateWithManagedAccountAndSyncing,
// Sign-in with a managed account and sync is turned off.
SignedInUserStateWithManagedAccountAndNotSyncing,
// Sign-in with a regular account and sync is turned on.
SignedInUserStateWithNonManagedAccountAndSyncing,
// Sign-in with a regular account and sync is turned off.
SignedInUserStateWithNoneManagedAccountAndNotSyncing
};
base::string16 HostedDomainForPrimaryAccount(Browser* browser) {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForBrowserState(browser->GetBrowserState());
base::Optional<AccountInfo> account_info =
identity_manager->FindExtendedAccountInfoForAccountWithRefreshToken(
identity_manager->GetPrimaryAccountInfo());
std::string hosted_domain = account_info.has_value()
? account_info.value().hosted_domain
: std::string();
return base::UTF8ToUTF16(hosted_domain);
}
ActionSheetCoordinator* SignoutActionSheetCoordinator(
UIViewController* view_controller,
Browser* browser,
UIView* view,
SignoutActionSheetCoordinatorCompletion signout_completion) {
DCHECK(signout_completion);
AuthenticationService* authentication_service =
AuthenticationServiceFactory::GetForBrowserState(
browser->GetBrowserState());
NSString* title = nil;
NSString* message = nil;
SyncSetupService* sync_setup_service =
SyncSetupServiceFactory::GetForBrowserState(browser->GetBrowserState());
BOOL sync_enabled = sync_setup_service->IsFirstSetupComplete();
SignedInUserState signed_in_user_state;
if (authentication_service->IsAuthenticatedIdentityManaged()) {
signed_in_user_state =
sync_enabled ? SignedInUserStateWithManagedAccountAndSyncing
: SignedInUserStateWithManagedAccountAndNotSyncing;
} else {
signed_in_user_state =
sync_enabled ? SignedInUserStateWithNonManagedAccountAndSyncing
: SignedInUserStateWithNoneManagedAccountAndNotSyncing;
}
switch (signed_in_user_state) {
case SignedInUserStateWithManagedAccountAndSyncing:
case SignedInUserStateWithManagedAccountAndNotSyncing: {
title = l10n_util::GetNSString(
IDS_IOS_SIGNOUT_DIALOG_TITLE_WITH_MANAGED_ACCOUNT);
base::string16 hosted_domain = HostedDomainForPrimaryAccount(browser);
message = l10n_util::GetNSStringF(
IDS_IOS_SIGNOUT_DIALOG_MESSAGE_WITH_MANAGED_ACCOUNT, hosted_domain);
break;
}
case SignedInUserStateWithNonManagedAccountAndSyncing: {
title = l10n_util::GetNSString(IDS_IOS_SIGNOUT_DIALOG_TITLE_WITH_SYNC);
message =
l10n_util::GetNSString(IDS_IOS_SIGNOUT_DIALOG_MESSAGE_WITH_SYNC);
break;
}
case SignedInUserStateWithNoneManagedAccountAndNotSyncing: {
title = l10n_util::GetNSString(IDS_IOS_SIGNOUT_DIALOG_TITLE_WITHOUT_SYNC);
break;
}
}
ActionSheetCoordinator* alertCoordinator =
[[ActionSheetCoordinator alloc] initWithBaseViewController:view_controller
browser:browser
title:title
message:message
rect:view.frame
view:view];
switch (signed_in_user_state) {
case SignedInUserStateWithManagedAccountAndSyncing:
case SignedInUserStateWithManagedAccountAndNotSyncing: {
NSString* const clear_from_this_device =
l10n_util::GetNSString(IDS_IOS_SIGNOUT_DIALOG_CLEAR_DATA_BUTTON);
[alertCoordinator
addItemWithTitle:clear_from_this_device
action:^{
signout_completion(
SignoutActionSheetCoordinatorResultClearFromDevice);
}
style:UIAlertActionStyleDestructive];
break;
}
case SignedInUserStateWithNonManagedAccountAndSyncing: {
NSString* const clear_from_this_device =
l10n_util::GetNSString(IDS_IOS_SIGNOUT_DIALOG_CLEAR_DATA_BUTTON);
NSString* const keep_on_this_device =
l10n_util::GetNSString(IDS_IOS_SIGNOUT_DIALOG_KEEP_DATA_BUTTON);
[alertCoordinator
addItemWithTitle:clear_from_this_device
action:^{
signout_completion(
SignoutActionSheetCoordinatorResultClearFromDevice);
}
style:UIAlertActionStyleDestructive];
[alertCoordinator
addItemWithTitle:keep_on_this_device
action:^{
signout_completion(
SignoutActionSheetCoordinatorResultKeepOnDevice);
}
style:UIAlertActionStyleDefault];
break;
}
case SignedInUserStateWithNoneManagedAccountAndNotSyncing: {
NSString* const sign_out =
l10n_util::GetNSString(IDS_IOS_SIGNOUT_DIALOG_SIGN_OUT_BUTTON);
[alertCoordinator
addItemWithTitle:sign_out
action:^{
signout_completion(
SignoutActionSheetCoordinatorResultKeepOnDevice);
}
style:UIAlertActionStyleDestructive];
break;
}
}
[alertCoordinator
addItemWithTitle:l10n_util::GetNSString(IDS_CANCEL)
action:^{
signout_completion(
SignoutActionSheetCoordinatorResultCanceled);
}
style:UIAlertActionStyleCancel];
return alertCoordinator;
}
AlertCoordinator* ErrorCoordinator(NSError* error,
ProceduralBlock dismissAction,
UIViewController* viewController,
......
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