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 if (navigation_handle()->GetPageTransition() != ui::PAGE_TRANSITION_LINK) { |
68 // If this navigation event wasn't spawned by the user clicking on a link. | |
67 return content::NavigationThrottle::PROCEED; | 69 return content::NavigationThrottle::PROCEED; |
68 | 70 |
Luis Héctor Chávez
2016/07/21 15:51:09
This seems to be missing a closing brace. Can you
Ben Kwa
2016/07/21 16:33:48
What th... >.<
Sorry about that. Fixed.
| |
69 if (!ShouldOverrideUrlLoading(navigation_handle())) | 71 if (!ShouldOverrideUrlLoading(navigation_handle())) |
70 return content::NavigationThrottle::PROCEED; | 72 return content::NavigationThrottle::PROCEED; |
71 | 73 |
72 const GURL& url = navigation_handle()->GetURL(); | 74 const GURL& url = navigation_handle()->GetURL(); |
73 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper(); | 75 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper(); |
74 if (!bridge_instance) | 76 if (!bridge_instance) |
75 return content::NavigationThrottle::PROCEED; | 77 return content::NavigationThrottle::PROCEED; |
76 bridge_instance->RequestUrlHandlerList( | 78 bridge_instance->RequestUrlHandlerList( |
77 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived, | 79 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived, |
78 weak_ptr_factory_.GetWeakPtr())); | 80 weak_ptr_factory_.GetWeakPtr())); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( | 227 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( |
226 content::NavigationHandle* navigation_handle) { | 228 content::NavigationHandle* navigation_handle) { |
227 GURL previous_url = navigation_handle->GetReferrer().url; | 229 GURL previous_url = navigation_handle->GetReferrer().url; |
228 GURL current_url = navigation_handle->GetURL(); | 230 GURL current_url = navigation_handle->GetURL(); |
229 return !net::registry_controlled_domains::SameDomainOrHost( | 231 return !net::registry_controlled_domains::SameDomainOrHost( |
230 current_url, previous_url, | 232 current_url, previous_url, |
231 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 233 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
232 } | 234 } |
233 | 235 |
234 } // namespace arc | 236 } // namespace arc |
OLD | NEW |