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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 handle->GetWebContents()->Close(); | 363 handle->GetWebContents()->Close(); |
364 } | 364 } |
365 break; | 365 break; |
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 Platform platform = |
374 static_cast<int>(close_reason), | 374 GetDestinationPlatform(selected_app_package, close_reason); |
375 static_cast<int>(CloseReason::SIZE)); | 375 RecordUma(close_reason, platform); |
376 } | 376 } |
377 | 377 |
378 // static | 378 // static |
379 size_t ArcNavigationThrottle::GetAppIndex( | 379 size_t ArcNavigationThrottle::GetAppIndex( |
380 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, | 380 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, |
381 const std::string& selected_app_package) { | 381 const std::string& selected_app_package) { |
382 for (size_t i = 0; i < handlers.size(); ++i) { | 382 for (size_t i = 0; i < handlers.size(); ++i) { |
383 if (handlers[i]->package_name == selected_app_package) | 383 if (handlers[i]->package_name == selected_app_package) |
384 return i; | 384 return i; |
385 } | 385 } |
386 return handlers.size(); | 386 return handlers.size(); |
387 } | 387 } |
388 | 388 |
389 // static | 389 // static |
| 390 ArcNavigationThrottle::Platform ArcNavigationThrottle::GetDestinationPlatform( |
| 391 const std::string& selected_app_package, |
| 392 CloseReason close_reason) { |
| 393 return (close_reason != CloseReason::ERROR && |
| 394 close_reason != CloseReason::DIALOG_DEACTIVATED && |
| 395 !ArcIntentHelperBridge::IsIntentHelperPackage(selected_app_package)) |
| 396 ? Platform::ARC |
| 397 : Platform::CHROME; |
| 398 } |
| 399 |
| 400 // static |
| 401 void ArcNavigationThrottle::RecordUma(CloseReason close_reason, |
| 402 Platform platform) { |
| 403 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", |
| 404 static_cast<int>(close_reason), |
| 405 static_cast<int>(CloseReason::SIZE)); |
| 406 |
| 407 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerDestinationPlatform", |
| 408 static_cast<int>(platform), |
| 409 static_cast<int>(Platform::SIZE)); |
| 410 } |
| 411 |
| 412 // static |
390 bool ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( | 413 bool ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( |
391 const GURL& previous_url, | 414 const GURL& previous_url, |
392 const GURL& current_url) { | 415 const GURL& current_url) { |
393 return ShouldOverrideUrlLoading(previous_url, current_url); | 416 return ShouldOverrideUrlLoading(previous_url, current_url); |
394 } | 417 } |
395 | 418 |
396 // static | 419 // static |
397 bool ArcNavigationThrottle::IsAppAvailableForTesting( | 420 bool ArcNavigationThrottle::IsAppAvailableForTesting( |
398 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers) { | 421 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers) { |
399 return IsAppAvailable(handlers); | 422 return IsAppAvailable(handlers); |
400 } | 423 } |
401 | 424 |
402 // static | 425 // static |
403 size_t ArcNavigationThrottle::FindPreferredAppForTesting( | 426 size_t ArcNavigationThrottle::FindPreferredAppForTesting( |
404 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers) { | 427 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers) { |
405 return FindPreferredApp(handlers, GURL()); | 428 return FindPreferredApp(handlers, GURL()); |
406 } | 429 } |
407 | 430 |
408 // static | 431 // static |
409 bool ArcNavigationThrottle::IsSwapElementsNeededForTesting( | 432 bool ArcNavigationThrottle::IsSwapElementsNeededForTesting( |
410 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, | 433 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, |
411 std::pair<size_t, size_t>* out_indices) { | 434 std::pair<size_t, size_t>* out_indices) { |
412 return IsSwapElementsNeeded(handlers, out_indices); | 435 return IsSwapElementsNeeded(handlers, out_indices); |
413 } | 436 } |
414 | 437 |
415 } // namespace arc | 438 } // namespace arc |
OLD | NEW |