Chromium Code Reviews| 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 "components/arc/intent_helper/local_activity_resolver.h" | 16 #include "components/arc/intent_helper/local_activity_resolver.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/navigation_controller.h" | |
| 18 #include "content/public/browser/navigation_handle.h" | 19 #include "content/public/browser/navigation_handle.h" |
| 20 #include "content/public/browser/web_contents.h" | |
| 19 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 21 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 20 #include "ui/base/page_transition_types.h" | 22 #include "ui/base/page_transition_types.h" |
| 21 | 23 |
| 22 namespace arc { | 24 namespace arc { |
| 23 | 25 |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 26 constexpr int kMinInstanceVersion = 7; | 28 constexpr int kMinInstanceVersion = 7; |
| 27 | 29 |
| 28 scoped_refptr<ActivityIconLoader> GetIconLoader() { | 30 scoped_refptr<ActivityIconLoader> GetIconLoader() { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 case CloseReason::JUST_ONCE_PRESSED: | 242 case CloseReason::JUST_ONCE_PRESSED: |
| 241 case CloseReason::PREFERRED_ACTIVITY_FOUND: { | 243 case CloseReason::PREFERRED_ACTIVITY_FOUND: { |
| 242 if (ArcIntentHelperBridge::IsIntentHelperPackage( | 244 if (ArcIntentHelperBridge::IsIntentHelperPackage( |
| 243 handlers[selected_app_index]->package_name)) { | 245 handlers[selected_app_index]->package_name)) { |
| 244 handle->Resume(); | 246 handle->Resume(); |
| 245 } else { | 247 } else { |
| 246 bridge->HandleUrl(url.spec(), | 248 bridge->HandleUrl(url.spec(), |
| 247 handlers[selected_app_index]->package_name); | 249 handlers[selected_app_index]->package_name); |
| 248 handle->CancelDeferredNavigation( | 250 handle->CancelDeferredNavigation( |
| 249 content::NavigationThrottle::CANCEL_AND_IGNORE); | 251 content::NavigationThrottle::CANCEL_AND_IGNORE); |
| 252 if (handle->GetWebContents()->GetController().IsInitialNavigation()) | |
|
Yusuke Sato
2016/09/16 22:42:04
Does handle->GetWebContents() always return a non-
djacobo_
2016/09/16 23:01:49
the intent picker has an observer for the WebConte
| |
| 253 handle->GetWebContents()->Close(); | |
| 250 } | 254 } |
| 251 break; | 255 break; |
| 252 } | 256 } |
| 253 case CloseReason::INVALID: { | 257 case CloseReason::INVALID: { |
| 254 NOTREACHED(); | 258 NOTREACHED(); |
| 255 return; | 259 return; |
| 256 } | 260 } |
| 257 } | 261 } |
| 258 | 262 |
| 259 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", | 263 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", |
| 260 static_cast<int>(close_reason), | 264 static_cast<int>(close_reason), |
| 261 static_cast<int>(CloseReason::SIZE)); | 265 static_cast<int>(CloseReason::SIZE)); |
| 262 } | 266 } |
| 263 | 267 |
| 264 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( | 268 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( |
| 265 content::NavigationHandle* navigation_handle) { | 269 content::NavigationHandle* navigation_handle) { |
| 266 GURL previous_url = navigation_handle->GetReferrer().url; | 270 GURL previous_url = navigation_handle->GetReferrer().url; |
| 267 GURL current_url = navigation_handle->GetURL(); | 271 GURL current_url = navigation_handle->GetURL(); |
| 268 return !net::registry_controlled_domains::SameDomainOrHost( | 272 return !net::registry_controlled_domains::SameDomainOrHost( |
| 269 current_url, previous_url, | 273 current_url, previous_url, |
| 270 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 274 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 271 } | 275 } |
| 272 | 276 |
| 273 } // namespace arc | 277 } // namespace arc |
| OLD | NEW |