| 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/accounts_collection_view_controller.h" | 5 #import "ios/chrome/browser/ui/settings/accounts_collection_view_controller.h" |
| 6 | 6 |
| 7 #import "base/mac/foundation_util.h" | 7 #import "base/mac/foundation_util.h" |
| 8 #include "base/metrics/user_metrics.h" | 8 #include "base/metrics/user_metrics.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 } | 440 } |
| 441 | 441 |
| 442 - (void)showGoogleActivitySettings { | 442 - (void)showGoogleActivitySettings { |
| 443 if ([_alertCoordinator isVisible]) | 443 if ([_alertCoordinator isVisible]) |
| 444 return; | 444 return; |
| 445 base::RecordAction(base::UserMetricsAction( | 445 base::RecordAction(base::UserMetricsAction( |
| 446 "Signin_AccountSettings_GoogleActivityControlsClicked")); | 446 "Signin_AccountSettings_GoogleActivityControlsClicked")); |
| 447 UINavigationController* settingsDetails = | 447 UINavigationController* settingsDetails = |
| 448 ios::GetChromeBrowserProvider() | 448 ios::GetChromeBrowserProvider() |
| 449 ->GetChromeIdentityService() | 449 ->GetChromeIdentityService() |
| 450 ->CreateWebAndAppSettingDetailsController( | 450 ->NewWebAndAppSettingDetails( |
| 451 [self authService]->GetAuthenticatedIdentity(), self); | 451 [self authService]->GetAuthenticatedIdentity(), self); |
| 452 UIImage* closeIcon = [ChromeIcon closeIcon]; | 452 UIImage* closeIcon = [ChromeIcon closeIcon]; |
| 453 SEL action = @selector(closeGoogleActivitySettings:); | 453 SEL action = @selector(closeGoogleActivitySettings:); |
| 454 [settingsDetails.topViewController navigationItem].leftBarButtonItem = | 454 [settingsDetails.topViewController navigationItem].leftBarButtonItem = |
| 455 [ChromeIcon templateBarButtonItemWithImage:closeIcon | 455 [ChromeIcon templateBarButtonItemWithImage:closeIcon |
| 456 target:self | 456 target:self |
| 457 action:action]; | 457 action:action]; |
| 458 [self presentViewController:settingsDetails animated:YES completion:nil]; | 458 [self presentViewController:settingsDetails animated:YES completion:nil]; |
| 459 | 459 |
| 460 // Keep a weak reference on the settings details, to be able to dismiss it | 460 // Keep a weak reference on the settings details, to be able to dismiss it |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 if (success && _closeSettingsOnAddAccount) { | 502 if (success && _closeSettingsOnAddAccount) { |
| 503 GenericChromeCommand* closeSettingsCommand = | 503 GenericChromeCommand* closeSettingsCommand = |
| 504 [[GenericChromeCommand alloc] initWithTag:IDC_CLOSE_SETTINGS]; | 504 [[GenericChromeCommand alloc] initWithTag:IDC_CLOSE_SETTINGS]; |
| 505 [self chromeExecuteCommand:closeSettingsCommand]; | 505 [self chromeExecuteCommand:closeSettingsCommand]; |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 | 508 |
| 509 - (void)showAccountDetails:(ChromeIdentity*)identity { | 509 - (void)showAccountDetails:(ChromeIdentity*)identity { |
| 510 if ([_alertCoordinator isVisible]) | 510 if ([_alertCoordinator isVisible]) |
| 511 return; | 511 return; |
| 512 UIViewController* accountDetails = | 512 UIViewController* accountDetails = ios::GetChromeBrowserProvider() |
| 513 ios::GetChromeBrowserProvider() | 513 ->GetChromeIdentityService() |
| 514 ->GetChromeIdentityService() | 514 ->NewAccountDetails(identity, self); |
| 515 ->CreateAccountDetailsController(identity, self); | |
| 516 if (!accountDetails) { | 515 if (!accountDetails) { |
| 517 // Failed to create a new account details. Ignored. | 516 // Failed to create a new account details. Ignored. |
| 518 return; | 517 return; |
| 519 } | 518 } |
| 520 [self presentViewController:accountDetails animated:YES completion:nil]; | 519 [self presentViewController:accountDetails animated:YES completion:nil]; |
| 521 | 520 |
| 522 // Keep a weak reference on the account details, to be able to dismiss it | 521 // Keep a weak reference on the account details, to be able to dismiss it |
| 523 // when the primary account is removed. | 522 // when the primary account is removed. |
| 524 _settingsDetails = accountDetails; | 523 _settingsDetails = accountDetails; |
| 525 } | 524 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 [self updateAccountItem:item withIdentity:identity]; | 653 [self updateAccountItem:item withIdentity:identity]; |
| 655 NSIndexPath* indexPath = [self.collectionViewModel indexPathForItem:item]; | 654 NSIndexPath* indexPath = [self.collectionViewModel indexPathForItem:item]; |
| 656 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; | 655 [self.collectionView reloadItemsAtIndexPaths:@[ indexPath ]]; |
| 657 } | 656 } |
| 658 | 657 |
| 659 - (void)onChromeIdentityServiceWillBeDestroyed { | 658 - (void)onChromeIdentityServiceWillBeDestroyed { |
| 660 _identityServiceObserver.reset(); | 659 _identityServiceObserver.reset(); |
| 661 } | 660 } |
| 662 | 661 |
| 663 @end | 662 @end |
| OLD | NEW |