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

Unified Diff: chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc

Issue 2229943003: Reusing Ok/Cancel buttons for intent picker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Temporary fix to force Layout enabling within contents_viewport_ Created 4 years, 2 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/chromeos/arc/arc_external_protocol_dialog.cc
diff --git a/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc b/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
index 6b0aaaaaec6da66f29e648e86c67af5ba1988bf7..1c55086bb3ff3a7ea4540bb63a9900a9ab315dfb 100644
--- a/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
+++ b/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
@@ -70,15 +70,32 @@ void OnIntentPickerClosed(int render_process_host_id,
int routing_id,
const GURL& url,
mojo::Array<mojom::IntentHandlerInfoPtr> handlers,
- size_t selected_app_index,
+ std::string selected_app_package,
ArcNavigationThrottle::CloseReason close_reason) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ size_t selected_app_index = handlers.size();
// Make sure that the instance at least supports HandleUrl.
auto* instance = ArcIntentHelperBridge::GetIntentHelperInstance(
"HandleUrl", kMinVersionForHandleUrl);
- if (!instance || selected_app_index >= handlers.size())
+ if (!instance) {
close_reason = ArcNavigationThrottle::CloseReason::ERROR;
+ } else if (close_reason ==
+ ArcNavigationThrottle::CloseReason::JUST_ONCE_PRESSED ||
+ close_reason ==
+ ArcNavigationThrottle::CloseReason::ALWAYS_PRESSED) {
+ // If the user selected an app to continue the navigation, confirm that the
+ // |package_name| matches a valid option and return the index.
+ 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 = ArcNavigationThrottle::CloseReason::ERROR;
+ }
switch (close_reason) {
case ArcNavigationThrottle::CloseReason::ALWAYS_PRESSED: {
@@ -127,15 +144,16 @@ void OnAppIconsReceived(
std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- using NameAndIcon = std::pair<std::string, gfx::Image>;
- std::vector<NameAndIcon> app_info;
+ using AppInfo = arc::ArcNavigationThrottle::AppInfo;
+ std::vector<AppInfo> app_info;
for (const auto& handler : handlers) {
const ActivityIconLoader::ActivityName activity(handler->package_name,
handler->activity_name);
const auto it = icons->find(activity);
app_info.emplace_back(
- handler->name, it != icons->end() ? it->second.icon20 : gfx::Image());
+ AppInfo(it != icons->end() ? it->second.icon20 : gfx::Image(),
+ handler->package_name, handler->name));
}
auto show_bubble_cb = base::Bind(ShowIntentPickerBubble());

Powered by Google App Engine
This is Rietveld 408576698