| 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 <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" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "components/arc/arc_bridge_service.h" | 13 #include "components/arc/arc_bridge_service.h" |
| 14 #include "components/arc/arc_service_manager.h" | 14 #include "components/arc/arc_service_manager.h" |
| 15 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" | 15 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/navigation_handle.h" | 17 #include "content/public/browser/navigation_handle.h" |
| 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 19 #include "ui/base/page_transition_types.h" |
| 19 | 20 |
| 20 namespace arc { | 21 namespace arc { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 constexpr int kMinInstanceVersion = 7; | 25 constexpr int kMinInstanceVersion = 7; |
| 25 | 26 |
| 26 scoped_refptr<ActivityIconLoader> GetIconLoader() { | 27 scoped_refptr<ActivityIconLoader> GetIconLoader() { |
| 27 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 28 ArcServiceManager* arc_service_manager = ArcServiceManager::Get(); | 29 ArcServiceManager* arc_service_manager = ArcServiceManager::Get(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 56 const ShowDisambigDialogCallback& show_disambig_dialog_cb) | 57 const ShowDisambigDialogCallback& show_disambig_dialog_cb) |
| 57 : content::NavigationThrottle(navigation_handle), | 58 : content::NavigationThrottle(navigation_handle), |
| 58 show_disambig_dialog_callback_(show_disambig_dialog_cb), | 59 show_disambig_dialog_callback_(show_disambig_dialog_cb), |
| 59 weak_ptr_factory_(this) {} | 60 weak_ptr_factory_(this) {} |
| 60 | 61 |
| 61 ArcNavigationThrottle::~ArcNavigationThrottle() = default; | 62 ArcNavigationThrottle::~ArcNavigationThrottle() = default; |
| 62 | 63 |
| 63 content::NavigationThrottle::ThrottleCheckResult | 64 content::NavigationThrottle::ThrottleCheckResult |
| 64 ArcNavigationThrottle::WillStartRequest() { | 65 ArcNavigationThrottle::WillStartRequest() { |
| 65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 66 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 66 if (!navigation_handle()->HasUserGesture()) | 67 |
| 68 const ui::PageTransition transition = |
| 69 navigation_handle()->GetPageTransition(); |
| 70 |
| 71 if (!ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK)) { |
| 72 // If this navigation event wasn't spawned by the user clicking on a link. |
| 67 return content::NavigationThrottle::PROCEED; | 73 return content::NavigationThrottle::PROCEED; |
| 74 } |
| 75 |
| 76 if (ui::PageTransitionGetQualifier(transition) != 0) { |
| 77 // Qualifiers indicate that this navigation was the result of a click on a |
| 78 // forward/back button, or a redirect, or typing in the URL bar, etc. Don't |
| 79 // pass any of those types of navigations to the intent helper (see |
| 80 // crbug.com/630072). |
| 81 return content::NavigationThrottle::PROCEED; |
| 82 } |
| 68 | 83 |
| 69 if (!ShouldOverrideUrlLoading(navigation_handle())) | 84 if (!ShouldOverrideUrlLoading(navigation_handle())) |
| 70 return content::NavigationThrottle::PROCEED; | 85 return content::NavigationThrottle::PROCEED; |
| 71 | 86 |
| 72 const GURL& url = navigation_handle()->GetURL(); | 87 const GURL& url = navigation_handle()->GetURL(); |
| 73 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper(); | 88 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper(); |
| 74 if (!bridge_instance) | 89 if (!bridge_instance) |
| 75 return content::NavigationThrottle::PROCEED; | 90 return content::NavigationThrottle::PROCEED; |
| 76 bridge_instance->RequestUrlHandlerList( | 91 bridge_instance->RequestUrlHandlerList( |
| 77 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived, | 92 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( | 240 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( |
| 226 content::NavigationHandle* navigation_handle) { | 241 content::NavigationHandle* navigation_handle) { |
| 227 GURL previous_url = navigation_handle->GetReferrer().url; | 242 GURL previous_url = navigation_handle->GetReferrer().url; |
| 228 GURL current_url = navigation_handle->GetURL(); | 243 GURL current_url = navigation_handle->GetURL(); |
| 229 return !net::registry_controlled_domains::SameDomainOrHost( | 244 return !net::registry_controlled_domains::SameDomainOrHost( |
| 230 current_url, previous_url, | 245 current_url, previous_url, |
| 231 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 246 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 232 } | 247 } |
| 233 | 248 |
| 234 } // namespace arc | 249 } // namespace arc |
| OLD | NEW |