| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/ui/intents/web_intent_picker_controller.h" | 5 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 ClosePicker(); | 412 ClosePicker(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 void WebIntentPickerController::OnChooseAnotherService() { | 415 void WebIntentPickerController::OnChooseAnotherService() { |
| 416 DCHECK(intents_dispatcher_); | 416 DCHECK(intents_dispatcher_); |
| 417 | 417 |
| 418 intents_dispatcher_->ResetDispatch(); | 418 intents_dispatcher_->ResetDispatch(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void WebIntentPickerController::OnClosing() { | 421 void WebIntentPickerController::OnClosing() { |
| 422 picker_shown_ = false; | 422 SetDialogState(kPickerHidden); |
| 423 picker_ = NULL; | 423 picker_ = NULL; |
| 424 } | 424 } |
| 425 | 425 |
| 426 void WebIntentPickerController::OnExtensionInstallSuccess( | 426 void WebIntentPickerController::OnExtensionInstallSuccess( |
| 427 const std::string& extension_id) { | 427 const std::string& extension_id) { |
| 428 // OnExtensionInstallSuccess is called via NotificationService::Notify before | 428 // OnExtensionInstallSuccess is called via NotificationService::Notify before |
| 429 // the extension is added to the ExtensionService. Dispatch via PostTask to | 429 // the extension is added to the ExtensionService. Dispatch via PostTask to |
| 430 // allow ExtensionService to update. | 430 // allow ExtensionService to update. |
| 431 MessageLoop::current()->PostTask( | 431 MessageLoop::current()->PostTask( |
| 432 FROM_HERE, | 432 FROM_HERE, |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 void WebIntentPickerController::SetDialogState(WebIntentPickerState state) { | 880 void WebIntentPickerController::SetDialogState(WebIntentPickerState state) { |
| 881 // Ignore events that don't change state. | 881 // Ignore events that don't change state. |
| 882 if (state == dialog_state_) | 882 if (state == dialog_state_) |
| 883 return; | 883 return; |
| 884 | 884 |
| 885 // Any pending timers are abandoned on state changes. | 885 // Any pending timers are abandoned on state changes. |
| 886 timer_factory_.InvalidateWeakPtrs(); | 886 timer_factory_.InvalidateWeakPtrs(); |
| 887 | 887 |
| 888 switch (state) { | 888 switch (state) { |
| 889 case kPickerSetup: | 889 case kPickerSetup: |
| 890 DCHECK(dialog_state_ == kPickerHidden); | 890 DCHECK_EQ(dialog_state_, kPickerHidden); |
| 891 | |
| 892 // Post timer CWS pending | 891 // Post timer CWS pending |
| 893 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 892 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 894 base::Bind(&WebIntentPickerController::OnPickerEvent, | 893 base::Bind(&WebIntentPickerController::OnPickerEvent, |
| 895 timer_factory_.GetWeakPtr(), | 894 timer_factory_.GetWeakPtr(), |
| 896 kPickerEventHiddenSetupTimeout), | 895 kPickerEventHiddenSetupTimeout), |
| 897 base::TimeDelta::FromMilliseconds(kMaxHiddenSetupTimeMs)); | 896 base::TimeDelta::FromMilliseconds(kMaxHiddenSetupTimeMs)); |
| 898 break; | 897 break; |
| 899 | 898 |
| 900 case kPickerWaiting: | 899 case kPickerWaiting: |
| 901 DCHECK(dialog_state_ == kPickerSetup); | 900 DCHECK_EQ(dialog_state_, kPickerSetup); |
| 902 // Waiting dialog can be dismissed after minimum wait time. | 901 // Waiting dialog can be dismissed after minimum wait time. |
| 903 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 902 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 904 base::Bind(&WebIntentPickerController::OnPickerEvent, | 903 base::Bind(&WebIntentPickerController::OnPickerEvent, |
| 905 timer_factory_.GetWeakPtr(), | 904 timer_factory_.GetWeakPtr(), |
| 906 kPickerEventMaxWaitTimeExceeded), | 905 kPickerEventMaxWaitTimeExceeded), |
| 907 base::TimeDelta::FromMilliseconds(kMinThrobberDisplayTimeMs)); | 906 base::TimeDelta::FromMilliseconds(kMinThrobberDisplayTimeMs)); |
| 908 break; | 907 break; |
| 909 | 908 |
| 910 case kPickerWaitLong: | 909 case kPickerWaitLong: |
| 911 DCHECK(dialog_state_ == kPickerWaiting); | 910 DCHECK_EQ(dialog_state_, kPickerWaiting); |
| 912 break; | 911 break; |
| 913 | 912 |
| 914 case kPickerMain: | 913 case kPickerMain: |
| 915 // No DCHECK - main state can be reached from any state. | 914 // No DCHECK - main state can be reached from any state. |
| 916 // Ready to display data. | 915 // Ready to display data. |
| 917 picker_model_->SetWaitingForSuggestions(false); | 916 picker_model_->SetWaitingForSuggestions(false); |
| 918 break; | 917 break; |
| 919 | 918 |
| 920 case kPickerHidden: | 919 case kPickerHidden: |
| 921 Reset(); | 920 Reset(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 942 picker_->SetActionString(GetIntentActionString( | 941 picker_->SetActionString(GetIntentActionString( |
| 943 UTF16ToUTF8(picker_model_->action()))); | 942 UTF16ToUTF8(picker_model_->action()))); |
| 944 picker_shown_ = true; | 943 picker_shown_ = true; |
| 945 } | 944 } |
| 946 | 945 |
| 947 void WebIntentPickerController::ClosePicker() { | 946 void WebIntentPickerController::ClosePicker() { |
| 948 SetDialogState(kPickerHidden); | 947 SetDialogState(kPickerHidden); |
| 949 if (picker_) | 948 if (picker_) |
| 950 picker_->Close(); | 949 picker_->Close(); |
| 951 } | 950 } |
| OLD | NEW |