| 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" |
| 6 |
| 5 #include "base/logging.h" | 7 #include "base/logging.h" |
| 6 #include "chrome/browser/component/navigation_interception/intercept_navigation_
delegate.h" | |
| 7 #include "chrome/browser/external_protocol/external_protocol_handler.h" | |
| 8 #include "chrome/browser/tab_contents/tab_util.h" | |
| 9 #include "content/public/browser/web_contents.h" | |
| 10 | |
| 11 using content::WebContents; | |
| 12 | 8 |
| 13 // static | 9 // static |
| 14 void ExternalProtocolHandler::RunExternalProtocolDialog( | 10 void ExternalProtocolHandler::RunExternalProtocolDialog( |
| 15 const GURL& url, int render_process_host_id, int routing_id) { | 11 const GURL& url, int render_process_host_id, int routing_id) { |
| 16 WebContents* web_contents = tab_util::GetWebContentsByID( | 12 // Chrome on Android uses a throttle-based mechansim to intercept links |
| 17 render_process_host_id, routing_id); | 13 // so that the user may choose to run an Android application instead of |
| 18 if (!web_contents) | 14 // loading the link in the browser. The throttle is also used to handle |
| 19 return; | 15 // external protocols, so this code should not be reachable. |
| 20 navigation_interception::InterceptNavigationDelegate* delegate = | 16 NOTREACHED(); |
| 21 navigation_interception::InterceptNavigationDelegate::Get(web_contents); | |
| 22 if (!delegate) | |
| 23 return; | |
| 24 | |
| 25 // TODO(jknotten): The call to ShouldIgnoreNavigation returns false if there | |
| 26 // are no applications that can handle the given URL. In this case, an error | |
| 27 // page should be displayed to the user. | |
| 28 delegate->ShouldIgnoreNavigation(url, true /* has_user_gesture */ ); | |
| 29 } | 17 } |
| OLD | NEW |