OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/external_protocol/external_protocol_handler.h" | 5 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 9 #include "chrome/browser/tab_contents/tab_util.h" |
| 10 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 11 #include "components/navigation_interception/navigation_params.h" |
| 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/common/referrer.h" |
| 14 #include "ui/base/page_transition_types.h" |
| 15 |
| 16 using content::WebContents; |
8 | 17 |
9 // static | 18 // static |
10 void ExternalProtocolHandler::RunExternalProtocolDialog( | 19 void ExternalProtocolHandler::RunExternalProtocolDialog( |
11 const GURL& url, int render_process_host_id, int routing_id) { | 20 const GURL& url, |
12 // Chrome on Android uses a throttle-based mechansim to intercept links | 21 int render_process_host_id, |
13 // so that the user may choose to run an Android application instead of | 22 int routing_id, |
14 // loading the link in the browser. The throttle is also used to handle | 23 ui::PageTransition page_transition, |
15 // external protocols, so this code should not be reachable. | 24 bool has_user_gesture) { |
16 NOTREACHED(); | 25 WebContents* web_contents = tab_util::GetWebContentsByID( |
| 26 render_process_host_id, routing_id); |
| 27 if (!web_contents) |
| 28 return; |
| 29 navigation_interception::InterceptNavigationDelegate* delegate = |
| 30 navigation_interception::InterceptNavigationDelegate::Get(web_contents); |
| 31 if (!delegate) |
| 32 return; |
| 33 |
| 34 navigation_interception::NavigationParams navigation_params( |
| 35 url, |
| 36 content::Referrer(), |
| 37 has_user_gesture, // has_user_gesture |
| 38 false, // is_post, doesn't matter here. |
| 39 page_transition, |
| 40 false, // is_redirect, doesn't matter here. |
| 41 true, // is_external_protocol |
| 42 false); // is_main_frame |
| 43 delegate->ShouldIgnoreNavigation(navigation_params); |
17 } | 44 } |
OLD | NEW |