Index: chrome/browser/chromeos/arc/arc_navigation_throttle.cc |
diff --git a/chrome/browser/chromeos/arc/arc_navigation_throttle.cc b/chrome/browser/chromeos/arc/arc_navigation_throttle.cc |
index 87f1acb451a0f044afe495e3a9a57568cd5010f9..d2d290b20c8664f8081e47e08077b600f870dc2a 100644 |
--- a/chrome/browser/chromeos/arc/arc_navigation_throttle.cc |
+++ b/chrome/browser/chromeos/arc/arc_navigation_throttle.cc |
@@ -173,8 +173,7 @@ void ArcNavigationThrottle::OnAppCandidatesReceived( |
<< "Chrome browser is selected as the preferred app for this URL: " |
<< navigation_handle()->GetURL().spec(); |
} |
- std::string package_name = handlers[i]->package_name; |
- OnIntentPickerClosed(std::move(handlers), package_name, |
+ OnIntentPickerClosed(std::move(handlers), i, |
CloseReason::PREFERRED_ACTIVITY_FOUND); |
return; |
} |
@@ -213,7 +212,7 @@ void ArcNavigationThrottle::OnAppIconsReceived( |
mojo::Array<mojom::IntentHandlerInfoPtr> handlers, |
std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
- std::vector<AppInfo> app_info; |
+ std::vector<NameAndIcon> app_info; |
for (const auto& handler : handlers) { |
gfx::Image icon; |
@@ -222,8 +221,7 @@ void ArcNavigationThrottle::OnAppIconsReceived( |
const auto it = icons->find(activity); |
app_info.emplace_back( |
- AppInfo(it != icons->end() ? it->second.icon20 : gfx::Image(), |
- handler->package_name, handler->name)); |
+ handler->name, it != icons->end() ? it->second.icon20 : gfx::Image()); |
} |
show_intent_picker_callback_.Run( |
@@ -234,34 +232,19 @@ void ArcNavigationThrottle::OnAppIconsReceived( |
void ArcNavigationThrottle::OnIntentPickerClosed( |
mojo::Array<mojom::IntentHandlerInfoPtr> handlers, |
- std::string selected_app_package, |
+ size_t selected_app_index, |
CloseReason close_reason) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
const GURL& url = navigation_handle()->GetURL(); |
content::NavigationHandle* handle = navigation_handle(); |
+ |
previous_user_action_ = close_reason; |
// Make sure that the instance at least supports HandleUrl. |
auto* instance = ArcIntentHelperBridge::GetIntentHelperInstance( |
"HandleUrl", kMinVersionForHandleUrl); |
- size_t selected_app_index = handlers.size(); |
- if (!instance) { |
+ if (!instance || selected_app_index >= handlers.size()) |
close_reason = CloseReason::ERROR; |
- } else if (close_reason == CloseReason::JUST_ONCE_PRESSED || |
- close_reason == CloseReason::ALWAYS_PRESSED || |
- close_reason == CloseReason::PREFERRED_ACTIVITY_FOUND) { |
- // Since we are selecting an app by its package name, we need to locate it |
- // on the |handlers| structure before sending the IPC to ARC. |
- for (size_t i = 0; i < handlers.size(); ++i) { |
- if (handlers[i]->package_name == selected_app_package) { |
- selected_app_index = i; |
- break; |
- } |
- } |
- |
- if (selected_app_index == handlers.size()) |
- close_reason = CloseReason::ERROR; |
- } |
switch (close_reason) { |
case CloseReason::ERROR: |
@@ -289,7 +272,8 @@ void ArcNavigationThrottle::OnIntentPickerClosed( |
handlers[selected_app_index]->package_name)) { |
handle->Resume(); |
} else { |
- instance->HandleUrl(url.spec(), selected_app_package); |
+ instance->HandleUrl(url.spec(), |
+ handlers[selected_app_index]->package_name); |
handle->CancelDeferredNavigation( |
content::NavigationThrottle::CANCEL_AND_IGNORE); |
if (handle->GetWebContents()->GetController().IsInitialNavigation()) |