| 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/arc_navigation_throttle.h" | 5 #include "chrome/browser/chromeos/arc/arc_navigation_throttle.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "components/arc/arc_bridge_service.h" | 11 #include "components/arc/arc_bridge_service.h" |
| 12 #include "components/arc/arc_service_manager.h" | 12 #include "components/arc/arc_service_manager.h" |
| 13 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" | 13 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/navigation_handle.h" | 15 #include "content/public/browser/navigation_handle.h" |
| 16 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 16 | 17 |
| 17 namespace arc { | 18 namespace arc { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 constexpr int kMinInstanceVersion = 7; | 22 constexpr int kMinInstanceVersion = 7; |
| 22 | 23 |
| 23 scoped_refptr<ActivityIconLoader> GetIconLoader() { | 24 scoped_refptr<ActivityIconLoader> GetIconLoader() { |
| 24 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 25 ArcServiceManager* arc_service_manager = ArcServiceManager::Get(); | 26 ArcServiceManager* arc_service_manager = ArcServiceManager::Get(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 weak_ptr_factory_(this) {} | 59 weak_ptr_factory_(this) {} |
| 59 | 60 |
| 60 ArcNavigationThrottle::~ArcNavigationThrottle() = default; | 61 ArcNavigationThrottle::~ArcNavigationThrottle() = default; |
| 61 | 62 |
| 62 content::NavigationThrottle::ThrottleCheckResult | 63 content::NavigationThrottle::ThrottleCheckResult |
| 63 ArcNavigationThrottle::WillStartRequest() { | 64 ArcNavigationThrottle::WillStartRequest() { |
| 64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 65 if (!navigation_handle()->HasUserGesture()) | 66 if (!navigation_handle()->HasUserGesture()) |
| 66 return content::NavigationThrottle::PROCEED; | 67 return content::NavigationThrottle::PROCEED; |
| 67 | 68 |
| 69 if (!ShouldOverrideUrlLoading(navigation_handle())) |
| 70 return content::NavigationThrottle::PROCEED; |
| 71 |
| 68 const GURL& url = navigation_handle()->GetURL(); | 72 const GURL& url = navigation_handle()->GetURL(); |
| 69 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper(); | 73 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper(); |
| 70 if (!bridge_instance) | 74 if (!bridge_instance) |
| 71 return content::NavigationThrottle::PROCEED; | 75 return content::NavigationThrottle::PROCEED; |
| 72 bridge_instance->RequestUrlHandlerList( | 76 bridge_instance->RequestUrlHandlerList( |
| 73 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived, | 77 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived, |
| 74 weak_ptr_factory_.GetWeakPtr())); | 78 weak_ptr_factory_.GetWeakPtr())); |
| 75 return content::NavigationThrottle::DEFER; | 79 return content::NavigationThrottle::DEFER; |
| 76 } | 80 } |
| 77 | 81 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 NOTREACHED(); | 204 NOTREACHED(); |
| 201 return; | 205 return; |
| 202 } | 206 } |
| 203 } | 207 } |
| 204 | 208 |
| 205 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", | 209 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", |
| 206 static_cast<int>(close_reason), | 210 static_cast<int>(close_reason), |
| 207 static_cast<int>(CloseReason::SIZE)); | 211 static_cast<int>(CloseReason::SIZE)); |
| 208 } | 212 } |
| 209 | 213 |
| 214 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( |
| 215 content::NavigationHandle* navigation_handle) { |
| 216 GURL previous_url = navigation_handle->GetReferrer().url; |
| 217 GURL current_url = navigation_handle->GetURL(); |
| 218 if (net::registry_controlled_domains::SameDomainOrHost( |
| 219 current_url, previous_url, |
| 220 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) |
| 221 return false; |
| 222 return true; |
| 223 } |
| 224 |
| 210 } // namespace arc | 225 } // namespace arc |
| OLD | NEW |