Chromium Code Reviews| Index: chrome/browser/ui/intents/web_intent_picker_controller.cc |
| diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc |
| index 08541a169c0390ec5aabc991688a1f737d6fcb48..a8c156f1b899754ce5d8d5c4ed4ff7e39fa63b36 100644 |
| --- a/chrome/browser/ui/intents/web_intent_picker_controller.cc |
| +++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc |
| @@ -138,6 +138,7 @@ WebIntentPickerController::WebIntentPickerController( |
| picker_(NULL), |
| picker_model_(new WebIntentPickerModel()), |
| pending_async_count_(0), |
| + pending_registry_calls_count_(0), |
| picker_shown_(false), |
| intents_dispatcher_(NULL), |
| service_tab_(NULL), |
| @@ -162,6 +163,7 @@ void WebIntentPickerController::SetIntentsDispatcher( |
| weak_ptr_factory_.GetWeakPtr())); |
| } |
| +// TODO(gbillock): remove the browser arg; unused. |
| void WebIntentPickerController::ShowDialog(Browser* browser, |
| const string16& action, |
| const string16& type) { |
| @@ -218,11 +220,24 @@ void WebIntentPickerController::ShowDialog(Browser* browser, |
| } |
| } |
| - pending_async_count_+= 2; |
| + pending_async_count_ += 2; |
| + pending_registry_calls_count_ += 1; |
| + |
| GetWebIntentsRegistry(wrapper_)->GetIntentServices( |
| action, type, |
| base::Bind(&WebIntentPickerController::OnWebIntentServicesAvailable, |
| weak_ptr_factory_.GetWeakPtr())); |
| + |
| + GURL invoking_url = wrapper_->web_contents()->GetURL(); |
| + if (invoking_url.is_valid()) { |
| + pending_async_count_++; |
| + pending_registry_calls_count_++; |
| + GetWebIntentsRegistry(wrapper_)->GetDefaultIntentService( |
| + action, type, invoking_url, |
| + base::Bind(&WebIntentPickerController::OnWebIntentDefaultsAvailable, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| + |
| GetCWSIntentsRegistry(wrapper_)->GetIntentServices( |
| action, type, |
| base::Bind(&WebIntentPickerController::OnCWSIntentServicesAvailable, |
| @@ -414,11 +429,8 @@ void WebIntentPickerController::OnWebIntentServicesAvailable( |
| favicon_consumer_.SetClientData(favicon_service, handle, i); |
| } |
| + RegistryCallsCompleted(); |
| AsyncOperationFinished(); |
| - |
| - CreatePicker(); |
| - picker_->SetActionString(GetIntentActionString( |
| - UTF16ToUTF8(picker_model_->action()))); |
| } |
| void WebIntentPickerController::WebIntentServicesForExplicitIntent( |
| @@ -446,6 +458,46 @@ void WebIntentPickerController::WebIntentServicesForExplicitIntent( |
| AsyncOperationFinished(); |
| } |
| +void WebIntentPickerController::OnWebIntentDefaultsAvailable( |
| + const DefaultWebIntentService& default_service) { |
| + if (!default_service.service_url.empty()) { |
| + DCHECK(default_service.suppression == 0); |
| + picker_model_->set_default_service_url(default_service.service_url); |
| + } |
| + |
| + RegistryCallsCompleted(); |
| + AsyncOperationFinished(); |
| +} |
| + |
| +void WebIntentPickerController::RegistryCallsCompleted() { |
| + pending_registry_calls_count_--; |
| + if (pending_registry_calls_count_ != 0) return; |
| + |
| + if (!picker_model_->default_service_url().empty()) { |
| + // If there's a default service, dispatch to it immediately |
| + // without showing the picker. |
| + const WebIntentPickerModel::InstalledService* default_service = |
|
groby-ooo-7-16
2012/05/01 15:28:33
I'm wondering if we should just keep a InstalledSe
Greg Billock
2012/05/01 19:17:54
That makes sense. Let's refactor that separately?
|
| + picker_model_->GetInstalledServiceWithURL( |
| + GURL(picker_model_->default_service_url())); |
| + |
| + if (default_service != NULL) { |
| + if (default_service->disposition == |
| + WebIntentPickerModel::DISPOSITION_INLINE) |
| + CreatePicker(); |
| + |
| + OnServiceChosen(default_service->url, default_service->disposition); |
| + return; |
| + } |
| + } |
| + |
| + CreatePicker(); |
| + picker_->SetActionString(GetIntentActionString( |
| + UTF16ToUTF8(picker_model_->action()))); |
| + |
| + // TODO(gbillock): handle the case of having only one service -- set |
| + // the make-default checkbox to "true" upon display. |
|
groby-ooo-7-16
2012/05/01 15:28:33
Probably belongs on the model
Greg Billock
2012/05/01 19:17:54
Done.
|
| +} |
| + |
| void WebIntentPickerController::OnFaviconDataAvailable( |
| FaviconService::Handle handle, history::FaviconData favicon_data) { |
| size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); |