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

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

Issue 2348673002: Add an external protocol dialog for ARC (Closed)
Patch Set: Address Xiyuan's comment 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 if (ShouldIgnoreNavigation(navigation_handle()->GetPageTransition()))
82 // redirect and non-redirect navigations equivalently.
83 const ui::PageTransition transition =
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; 83 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 84
101 if (!ShouldOverrideUrlLoading(navigation_handle())) 85 if (!ShouldOverrideUrlLoading(navigation_handle()))
102 return content::NavigationThrottle::PROCEED; 86 return content::NavigationThrottle::PROCEED;
103 87
104 arc::ArcServiceManager* arc_service_manager = arc::ArcServiceManager::Get(); 88 arc::ArcServiceManager* arc_service_manager = arc::ArcServiceManager::Get();
105 DCHECK(arc_service_manager); 89 DCHECK(arc_service_manager);
106 scoped_refptr<arc::LocalActivityResolver> local_resolver = 90 scoped_refptr<arc::LocalActivityResolver> local_resolver =
107 arc_service_manager->activity_resolver(); 91 arc_service_manager->activity_resolver();
108 if (local_resolver->ShouldChromeHandleUrl(url)) { 92 if (local_resolver->ShouldChromeHandleUrl(url)) {
109 // Allow navigation to proceed if there isn't an android app that handles 93 // Allow navigation to proceed if there isn't an android app that handles
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( 248 bool ArcNavigationThrottle::ShouldOverrideUrlLoading(
265 content::NavigationHandle* navigation_handle) { 249 content::NavigationHandle* navigation_handle) {
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
« no previous file with comments | « chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc ('k') | chrome/browser/chromeos/arc/page_transition_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698