| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include "ios/chrome/browser/ui/sync/sync_error_infobar_delegate.h" | 5 #include "ios/chrome/browser/ui/sync/sync_error_infobar_delegate.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool SyncErrorInfoBarDelegate::Accept() { | 93 bool SyncErrorInfoBarDelegate::Accept() { |
| 94 DCHECK(command_); | 94 DCHECK(command_); |
| 95 UIWindow* main_window = [[UIApplication sharedApplication] keyWindow]; | 95 UIWindow* main_window = [[UIApplication sharedApplication] keyWindow]; |
| 96 DCHECK(main_window); | 96 DCHECK(main_window); |
| 97 [main_window chromeExecuteCommand:command_]; | 97 [main_window chromeExecuteCommand:command_]; |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void SyncErrorInfoBarDelegate::OnStateChanged() { | 101 void SyncErrorInfoBarDelegate::OnStateChanged(syncer::SyncService* sync) { |
| 102 // If the inforbar is in the process of being removed, nothing must be done. | 102 // If the inforbar is in the process of being removed, nothing must be done. |
| 103 infobars::InfoBar* infobar = this->infobar(); | 103 infobars::InfoBar* infobar = this->infobar(); |
| 104 if (!infobar) | 104 if (!infobar) |
| 105 return; | 105 return; |
| 106 SyncSetupService* sync_setup_service = | 106 SyncSetupService* sync_setup_service = |
| 107 SyncSetupServiceFactory::GetForBrowserState(browser_state_); | 107 SyncSetupServiceFactory::GetForBrowserState(browser_state_); |
| 108 SyncSetupService::SyncServiceState new_error_state = | 108 SyncSetupService::SyncServiceState new_error_state = |
| 109 sync_setup_service->GetSyncServiceState(); | 109 sync_setup_service->GetSyncServiceState(); |
| 110 if (error_state_ == new_error_state) | 110 if (error_state_ == new_error_state) |
| 111 return; | 111 return; |
| 112 error_state_ = new_error_state; | 112 error_state_ = new_error_state; |
| 113 if (ios_internal::sync::IsTransientSyncError(new_error_state)) { | 113 if (ios_internal::sync::IsTransientSyncError(new_error_state)) { |
| 114 infobar->RemoveSelf(); | 114 infobar->RemoveSelf(); |
| 115 } else { | 115 } else { |
| 116 infobars::InfoBarManager* infobar_manager = infobar->owner(); | 116 infobars::InfoBarManager* infobar_manager = infobar->owner(); |
| 117 if (infobar_manager) { | 117 if (infobar_manager) { |
| 118 std::unique_ptr<ConfirmInfoBarDelegate> new_infobar_delegate( | 118 std::unique_ptr<ConfirmInfoBarDelegate> new_infobar_delegate( |
| 119 new SyncErrorInfoBarDelegate(browser_state_)); | 119 new SyncErrorInfoBarDelegate(browser_state_)); |
| 120 infobar_manager->ReplaceInfoBar(infobar, | 120 infobar_manager->ReplaceInfoBar(infobar, |
| 121 infobar_manager->CreateConfirmInfoBar( | 121 infobar_manager->CreateConfirmInfoBar( |
| 122 std::move(new_infobar_delegate))); | 122 std::move(new_infobar_delegate))); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 } | 125 } |
| OLD | NEW |