| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/views/clear_server_data.h" | 5 #include "chrome/browser/views/clear_server_data.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // sync disabled) | 269 // sync disabled) |
| 270 UpdateControlEnabledState(); | 270 UpdateControlEnabledState(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 //////////////////////////////////////////////////////////////////////////////// | 273 //////////////////////////////////////////////////////////////////////////////// |
| 274 // ClearServerDataView, private: | 274 // ClearServerDataView, private: |
| 275 | 275 |
| 276 void ClearServerDataView::UpdateControlEnabledState() { | 276 void ClearServerDataView::UpdateControlEnabledState() { |
| 277 bool delete_in_progress = false; | 277 bool delete_in_progress = false; |
| 278 | 278 |
| 279 // We only want to call Suceeded/FailedClearingServerData once, not every | 279 // Succeeded/FailedClearingServerData should only be called once, not every |
| 280 // time the view is refreshed. As such, on success/failure we handle that | 280 // time the view is refreshed. As such, on success/failure handle that state |
| 281 // state and immediately reset things back to CLEAR_NOT_STARTED. | 281 // and immediately reset things back to CLEAR_NOT_STARTED. |
| 282 ProfileSyncService::ClearServerDataState clear_state = | 282 ProfileSyncService::ClearServerDataState clear_state = |
| 283 profile_->GetProfileSyncService()->GetClearServerDataState(); | 283 profile_->GetProfileSyncService()->GetClearServerDataState(); |
| 284 profile_->GetProfileSyncService()->ResetClearServerDataState(); | 284 profile_->GetProfileSyncService()->ResetClearServerDataState(); |
| 285 | 285 |
| 286 switch (clear_state) { | 286 switch (clear_state) { |
| 287 case ProfileSyncService::CLEAR_NOT_STARTED: | 287 case ProfileSyncService::CLEAR_NOT_STARTED: |
| 288 // We can get here when we first start and after a failed clear (which | 288 // This can occur on a first start and after a failed clear (which does |
| 289 // does not close the tab), do nothing. | 289 // not close the tab). Do nothing. |
| 290 break; | 290 break; |
| 291 case ProfileSyncService::CLEAR_CLEARING: | 291 case ProfileSyncService::CLEAR_CLEARING: |
| 292 // Clearing buttons on all tabs are disabled at this | 292 // Clearing buttons on all tabs are disabled at this point, throbber is |
| 293 // point, throbber is going | 293 // going. |
| 294 status_label_->SetText(l10n_util::GetString(IDS_CLEAR_DATA_SENDING)); | 294 status_label_->SetText(l10n_util::GetString(IDS_CLEAR_DATA_SENDING)); |
| 295 status_label_->SetVisible(true); | 295 status_label_->SetVisible(true); |
| 296 delete_in_progress = true; | 296 delete_in_progress = true; |
| 297 break; | 297 break; |
| 298 case ProfileSyncService::CLEAR_FAILED: | 298 case ProfileSyncService::CLEAR_FAILED: |
| 299 // Show an error and reallow clearing | 299 // Show an error and reallow clearing. |
| 300 clear_data_parent_window_->FailedClearingServerData(); | 300 clear_data_parent_window_->FailedClearingServerData(); |
| 301 status_label_->SetText(l10n_util::GetString(IDS_CLEAR_DATA_ERROR)); | 301 status_label_->SetText(l10n_util::GetString(IDS_CLEAR_DATA_ERROR)); |
| 302 status_label_->SetVisible(true); | 302 status_label_->SetVisible(true); |
| 303 delete_in_progress = false; | 303 delete_in_progress = false; |
| 304 break; | 304 break; |
| 305 case ProfileSyncService::CLEAR_SUCCEEDED: | 305 case ProfileSyncService::CLEAR_SUCCEEDED: |
| 306 // Close the dialog box, success! | 306 // Close the dialog box, success! |
| 307 status_label_->SetVisible(false); | 307 status_label_->SetVisible(false); |
| 308 delete_in_progress = false; | 308 delete_in_progress = false; |
| 309 clear_data_parent_window_->SucceededClearingServerData(); | 309 clear_data_parent_window_->SucceededClearingServerData(); |
| 310 break; | 310 break; |
| 311 } | 311 } |
| 312 | 312 |
| 313 // allow_clear can be false when a local browsing data clear is happening | 313 // allow_clear can be false when a local browsing data clear is happening |
| 314 // from the neighboring tab. delete_in_progress means that a clear is | 314 // from the neighboring tab. delete_in_progress means that a clear is |
| 315 // pending in the current tab. | 315 // pending in the current tab. |
| 316 this->clear_server_data_button_->SetEnabled( | 316 this->clear_server_data_button_->SetEnabled( |
| 317 profile_->GetProfileSyncService()->HasSyncSetupCompleted() && | 317 profile_->GetProfileSyncService()->HasSyncSetupCompleted() && |
| 318 !delete_in_progress && allow_clear_); | 318 !delete_in_progress && allow_clear_); |
| 319 | 319 |
| 320 throbber_->SetVisible(delete_in_progress); | 320 throbber_->SetVisible(delete_in_progress); |
| 321 if (delete_in_progress) | 321 if (delete_in_progress) |
| 322 throbber_->Start(); | 322 throbber_->Start(); |
| 323 else | 323 else |
| 324 throbber_->Stop(); | 324 throbber_->Stop(); |
| 325 } | 325 } |
| 326 | 326 |
| OLD | NEW |