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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 url, render_process_host_id, routing_id, page_transition, | 75 url, render_process_host_id, routing_id, page_transition, |
76 has_user_gesture); | 76 has_user_gesture); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 void LaunchUrlWithoutSecurityCheckWithDelegate( | 80 void LaunchUrlWithoutSecurityCheckWithDelegate( |
81 const GURL& url, | 81 const GURL& url, |
82 int render_process_host_id, | 82 int render_process_host_id, |
83 int tab_contents_id, | 83 int tab_contents_id, |
84 ExternalProtocolHandler::Delegate* delegate) { | 84 ExternalProtocolHandler::Delegate* delegate) { |
| 85 content::WebContents* web_contents = |
| 86 tab_util::GetWebContentsByID(render_process_host_id, tab_contents_id); |
| 87 |
85 if (!delegate) { | 88 if (!delegate) { |
86 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( | 89 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents); |
87 url, render_process_host_id, tab_contents_id); | |
88 } else { | 90 } else { |
89 delegate->LaunchUrlWithoutSecurityCheck(url); | 91 delegate->LaunchUrlWithoutSecurityCheck(url, web_contents); |
90 } | 92 } |
91 } | 93 } |
92 | 94 |
93 // When we are about to launch a URL with the default OS level application, we | 95 // When we are about to launch a URL with the default OS level application, we |
94 // check if the external application will be us. If it is we just ignore the | 96 // check if the external application will be us. If it is we just ignore the |
95 // request. | 97 // request. |
96 void OnDefaultProtocolClientWorkerFinished( | 98 void OnDefaultProtocolClientWorkerFinished( |
97 const GURL& escaped_url, | 99 const GURL& escaped_url, |
98 int render_process_host_id, | 100 int render_process_host_id, |
99 int tab_contents_id, | 101 int tab_contents_id, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // Start the check process running. This will send tasks to the FILE thread | 217 // Start the check process running. This will send tasks to the FILE thread |
216 // and when the answer is known will send the result back to | 218 // and when the answer is known will send the result back to |
217 // OnDefaultProtocolClientWorkerFinished(). | 219 // OnDefaultProtocolClientWorkerFinished(). |
218 CreateShellWorker(callback, escaped_url.scheme(), delegate) | 220 CreateShellWorker(callback, escaped_url.scheme(), delegate) |
219 ->StartCheckIsDefault(); | 221 ->StartCheckIsDefault(); |
220 } | 222 } |
221 | 223 |
222 // static | 224 // static |
223 void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( | 225 void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( |
224 const GURL& url, | 226 const GURL& url, |
225 int render_process_host_id, | 227 content::WebContents* web_contents) { |
226 int tab_contents_id) { | 228 // |web_contents| is only passed in to find browser context. Do not assume |
227 content::WebContents* web_contents = tab_util::GetWebContentsByID( | 229 // that the external protocol request came from the main frame. |
228 render_process_host_id, tab_contents_id); | |
229 if (!web_contents) | 230 if (!web_contents) |
230 return; | 231 return; |
231 | 232 |
232 platform_util::OpenExternal( | 233 platform_util::OpenExternal( |
233 Profile::FromBrowserContext(web_contents->GetBrowserContext()), url); | 234 Profile::FromBrowserContext(web_contents->GetBrowserContext()), url); |
234 } | 235 } |
235 | 236 |
236 // static | 237 // static |
237 void ExternalProtocolHandler::PermitLaunchUrl() { | 238 void ExternalProtocolHandler::PermitLaunchUrl() { |
238 DCHECK(base::MessageLoopForUI::IsCurrent()); | 239 DCHECK(base::MessageLoopForUI::IsCurrent()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // static | 294 // static |
294 void ExternalProtocolHandler::RecordMetrics(bool selected) { | 295 void ExternalProtocolHandler::RecordMetrics(bool selected) { |
295 UMA_HISTOGRAM_BOOLEAN("BrowserDialogs.ExternalProtocol.RememberCheckbox", | 296 UMA_HISTOGRAM_BOOLEAN("BrowserDialogs.ExternalProtocol.RememberCheckbox", |
296 selected); | 297 selected); |
297 } | 298 } |
298 | 299 |
299 // static | 300 // static |
300 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) { | 301 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
301 registry->RegisterDictionaryPref(prefs::kExcludedSchemes); | 302 registry->RegisterDictionaryPref(prefs::kExcludedSchemes); |
302 } | 303 } |
OLD | NEW |