| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/arc/intent_helper/arc_navigation_throttle.h" | 5 #include "chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 } | 366 } |
| 367 case CloseReason::INVALID: { | 367 case CloseReason::INVALID: { |
| 368 NOTREACHED(); | 368 NOTREACHED(); |
| 369 return; | 369 return; |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", | 373 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", |
| 374 static_cast<int>(close_reason), | 374 static_cast<int>(close_reason), |
| 375 static_cast<int>(CloseReason::SIZE)); | 375 static_cast<int>(CloseReason::SIZE)); |
| 376 |
| 377 Platform platform = |
| 378 GetDestinationPlatform(selected_app_package, close_reason); |
| 379 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerDestinationPlatform", |
| 380 static_cast<int>(platform), |
| 381 static_cast<int>(Platform::SIZE)); |
| 376 } | 382 } |
| 377 | 383 |
| 378 // static | 384 // static |
| 379 size_t ArcNavigationThrottle::GetAppIndex( | 385 size_t ArcNavigationThrottle::GetAppIndex( |
| 380 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, | 386 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, |
| 381 const std::string& selected_app_package) { | 387 const std::string& selected_app_package) { |
| 382 for (size_t i = 0; i < handlers.size(); ++i) { | 388 for (size_t i = 0; i < handlers.size(); ++i) { |
| 383 if (handlers[i]->package_name == selected_app_package) | 389 if (handlers[i]->package_name == selected_app_package) |
| 384 return i; | 390 return i; |
| 385 } | 391 } |
| 386 return handlers.size(); | 392 return handlers.size(); |
| 387 } | 393 } |
| 388 | 394 |
| 389 // static | 395 // static |
| 396 ArcNavigationThrottle::Platform ArcNavigationThrottle::GetDestinationPlatform( |
| 397 const std::string& selected_app_package, |
| 398 CloseReason close_reason) { |
| 399 return (close_reason != CloseReason::ERROR && |
| 400 close_reason != CloseReason::DIALOG_DEACTIVATED && |
| 401 !ArcIntentHelperBridge::IsIntentHelperPackage(selected_app_package)) |
| 402 ? Platform::ARC |
| 403 : Platform::CHROME; |
| 404 } |
| 405 |
| 406 // static |
| 390 bool ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( | 407 bool ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( |
| 391 const GURL& previous_url, | 408 const GURL& previous_url, |
| 392 const GURL& current_url) { | 409 const GURL& current_url) { |
| 393 return ShouldOverrideUrlLoading(previous_url, current_url); | 410 return ShouldOverrideUrlLoading(previous_url, current_url); |
| 394 } | 411 } |
| 395 | 412 |
| 396 // static | 413 // static |
| 397 bool ArcNavigationThrottle::IsAppAvailableForTesting( | 414 bool ArcNavigationThrottle::IsAppAvailableForTesting( |
| 398 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers) { | 415 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers) { |
| 399 return IsAppAvailable(handlers); | 416 return IsAppAvailable(handlers); |
| 400 } | 417 } |
| 401 | 418 |
| 402 // static | 419 // static |
| 403 size_t ArcNavigationThrottle::FindPreferredAppForTesting( | 420 size_t ArcNavigationThrottle::FindPreferredAppForTesting( |
| 404 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers) { | 421 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers) { |
| 405 return FindPreferredApp(handlers, GURL()); | 422 return FindPreferredApp(handlers, GURL()); |
| 406 } | 423 } |
| 407 | 424 |
| 408 // static | 425 // static |
| 409 bool ArcNavigationThrottle::IsSwapElementsNeededForTesting( | 426 bool ArcNavigationThrottle::IsSwapElementsNeededForTesting( |
| 410 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, | 427 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, |
| 411 std::pair<size_t, size_t>* out_indices) { | 428 std::pair<size_t, size_t>* out_indices) { |
| 412 return IsSwapElementsNeeded(handlers, out_indices); | 429 return IsSwapElementsNeeded(handlers, out_indices); |
| 413 } | 430 } |
| 414 | 431 |
| 415 } // namespace arc | 432 } // namespace arc |
| OLD | NEW |