Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/browser/chromeos/arc/arc_navigation_throttle.cc

Issue 2348673002: Add an external protocol dialog for ARC (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/chromeos/arc/page_transition_util.h"
13 #include "components/arc/arc_bridge_service.h" 14 #include "components/arc/arc_bridge_service.h"
14 #include "components/arc/arc_service_manager.h" 15 #include "components/arc/arc_service_manager.h"
15 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" 16 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
16 #include "components/arc/intent_helper/local_activity_resolver.h" 17 #include "components/arc/intent_helper/local_activity_resolver.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/navigation_handle.h" 19 #include "content/public/browser/navigation_handle.h"
19 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
20 #include "ui/base/page_transition_types.h" 21 #include "ui/base/page_transition_types.h"
21 22
22 namespace arc { 23 namespace arc {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // No picker has previously been popped up for this - continue. 72 // No picker has previously been popped up for this - continue.
72 break; 73 break;
73 } 74 }
74 return HandleRequest(); 75 return HandleRequest();
75 } 76 }
76 77
77 content::NavigationThrottle::ThrottleCheckResult 78 content::NavigationThrottle::ThrottleCheckResult
78 ArcNavigationThrottle::HandleRequest() { 79 ArcNavigationThrottle::HandleRequest() {
79 const GURL& url = navigation_handle()->GetURL(); 80 const GURL& url = navigation_handle()->GetURL();
80 81
81 // Mask out any redirect qualifiers - this method handles navigation from
82 // redirect and non-redirect navigations equivalently.
83 const ui::PageTransition transition =
Luis Héctor Chávez 2016/09/15 22:42:11 Naïve question: shouldn't there be a if (ShouldIgn
Yusuke Sato 2016/09/15 23:08:24 Done. I moved it to line 247 but it was probably
84 ui::PageTransitionFromInt(navigation_handle()->GetPageTransition() &
85 ~ui::PAGE_TRANSITION_IS_REDIRECT_MASK);
86
87 if (!ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK)) {
88 // Allow navigation to proceed if this event wasn't spawned by the user
89 // clicking on a link.
90 return content::NavigationThrottle::PROCEED;
91 }
92
93 if (ui::PageTransitionGetQualifier(transition) != 0) {
94 // Qualifiers indicate that this navigation was the result of a click on a
95 // forward/back button, or typing in the URL bar, etc. Don't pass any of
96 // those types of navigations to the intent helper (see crbug.com/630072).
97 // Note that redirects, which we do pass on, are masked out above.
98 return content::NavigationThrottle::PROCEED;
99 }
100
101 if (!ShouldOverrideUrlLoading(navigation_handle())) 82 if (!ShouldOverrideUrlLoading(navigation_handle()))
102 return content::NavigationThrottle::PROCEED; 83 return content::NavigationThrottle::PROCEED;
103 84
104 arc::ArcServiceManager* arc_service_manager = arc::ArcServiceManager::Get(); 85 arc::ArcServiceManager* arc_service_manager = arc::ArcServiceManager::Get();
105 DCHECK(arc_service_manager); 86 DCHECK(arc_service_manager);
106 scoped_refptr<arc::LocalActivityResolver> local_resolver = 87 scoped_refptr<arc::LocalActivityResolver> local_resolver =
107 arc_service_manager->activity_resolver(); 88 arc_service_manager->activity_resolver();
108 if (local_resolver->ShouldChromeHandleUrl(url)) { 89 if (local_resolver->ShouldChromeHandleUrl(url)) {
109 // Allow navigation to proceed if there isn't an android app that handles 90 // Allow navigation to proceed if there isn't an android app that handles
110 // the given URL. 91 // the given URL.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 237 }
257 } 238 }
258 239
259 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", 240 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction",
260 static_cast<int>(close_reason), 241 static_cast<int>(close_reason),
261 static_cast<int>(CloseReason::SIZE)); 242 static_cast<int>(CloseReason::SIZE));
262 } 243 }
263 244
264 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( 245 bool ArcNavigationThrottle::ShouldOverrideUrlLoading(
265 content::NavigationHandle* navigation_handle) { 246 content::NavigationHandle* navigation_handle) {
247 if (ShouldIgnoreNavigation(navigation_handle->GetPageTransition()))
248 return false;
249
266 GURL previous_url = navigation_handle->GetReferrer().url; 250 GURL previous_url = navigation_handle->GetReferrer().url;
267 GURL current_url = navigation_handle->GetURL(); 251 GURL current_url = navigation_handle->GetURL();
268 return !net::registry_controlled_domains::SameDomainOrHost( 252 return !net::registry_controlled_domains::SameDomainOrHost(
269 current_url, previous_url, 253 current_url, previous_url,
270 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 254 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
271 } 255 }
272 256
273 } // namespace arc 257 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698