Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6238)

Unified Diff: chrome/browser/ui/intents/web_intent_picker_controller.cc

Issue 10204010: Handling default service in the web intents picker controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 88b3e4e8710baca3d4c62b3b3f9f464e7d99483f..a80f46d5c17a0fb97cbc1eeb0fd08f6e9a93ad30 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),
@@ -217,11 +218,24 @@ void WebIntentPickerController::ShowDialog(const string16& action,
}
}
- 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,
@@ -413,11 +427,8 @@ void WebIntentPickerController::OnWebIntentServicesAvailable(
favicon_consumer_.SetClientData(favicon_service, handle, i);
}
+ RegistryCallsCompleted();
AsyncOperationFinished();
-
- CreatePicker();
- picker_->SetActionString(GetIntentActionString(
- UTF16ToUTF8(picker_model_->action())));
}
void WebIntentPickerController::WebIntentServicesForExplicitIntent(
@@ -445,6 +456,43 @@ 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(GURL(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().is_valid()) {
+ // If there's a default service, dispatch to it immediately
+ // without showing the picker.
+ const WebIntentPickerModel::InstalledService* default_service =
+ 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())));
+}
+
void WebIntentPickerController::OnFaviconDataAvailable(
FaviconService::Handle handle, history::FaviconData favicon_data) {
size_t index = favicon_consumer_.GetClientDataForCurrentRequest();

Powered by Google App Engine
This is Rietveld 408576698