Chromium Code Reviews| 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 | |
|
alexmos
2016/12/12 21:11:40
Did you remove the blank line here by accident?
davidsac (gone - try alexmos)
2016/12/13 23:02:33
Done.
| |
| 9 #include <set> | 8 #include <set> |
| 10 | 9 |
| 11 #include "base/bind.h" | 10 #include "base/bind.h" |
| 12 #include "base/logging.h" | 11 #include "base/logging.h" |
| 13 #include "base/macros.h" | 12 #include "base/macros.h" |
| 14 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 15 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 17 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 18 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 url, render_process_host_id, routing_id, page_transition, | 74 url, render_process_host_id, routing_id, page_transition, |
| 76 has_user_gesture); | 75 has_user_gesture); |
| 77 } | 76 } |
| 78 } | 77 } |
| 79 | 78 |
| 80 void LaunchUrlWithoutSecurityCheckWithDelegate( | 79 void LaunchUrlWithoutSecurityCheckWithDelegate( |
| 81 const GURL& url, | 80 const GURL& url, |
| 82 int render_process_host_id, | 81 int render_process_host_id, |
| 83 int tab_contents_id, | 82 int tab_contents_id, |
| 84 ExternalProtocolHandler::Delegate* delegate) { | 83 ExternalProtocolHandler::Delegate* delegate) { |
| 84 content::WebContents* web_contents = | |
| 85 tab_util::GetWebContentsByID(render_process_host_id, tab_contents_id); | |
| 86 | |
| 85 if (!delegate) { | 87 if (!delegate) { |
| 86 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( | 88 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents); |
| 87 url, render_process_host_id, tab_contents_id); | |
| 88 } else { | 89 } else { |
| 89 delegate->LaunchUrlWithoutSecurityCheck(url); | 90 delegate->LaunchUrlWithoutSecurityCheck(url, web_contents); |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 | 93 |
| 93 // When we are about to launch a URL with the default OS level application, we | 94 // 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 | 95 // check if the external application will be us. If it is we just ignore the |
| 95 // request. | 96 // request. |
| 96 void OnDefaultProtocolClientWorkerFinished( | 97 void OnDefaultProtocolClientWorkerFinished( |
| 97 const GURL& escaped_url, | 98 const GURL& escaped_url, |
| 98 int render_process_host_id, | 99 int render_process_host_id, |
| 99 int tab_contents_id, | 100 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 | 216 // 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 | 217 // and when the answer is known will send the result back to |
| 217 // OnDefaultProtocolClientWorkerFinished(). | 218 // OnDefaultProtocolClientWorkerFinished(). |
| 218 CreateShellWorker(callback, escaped_url.scheme(), delegate) | 219 CreateShellWorker(callback, escaped_url.scheme(), delegate) |
| 219 ->StartCheckIsDefault(); | 220 ->StartCheckIsDefault(); |
| 220 } | 221 } |
| 221 | 222 |
| 222 // static | 223 // static |
| 223 void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( | 224 void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck( |
| 224 const GURL& url, | 225 const GURL& url, |
| 225 int render_process_host_id, | 226 content::WebContents* web_contents) { |
| 226 int tab_contents_id) { | |
| 227 content::WebContents* web_contents = tab_util::GetWebContentsByID( | |
| 228 render_process_host_id, tab_contents_id); | |
| 229 if (!web_contents) | 227 if (!web_contents) |
| 230 return; | 228 return; |
| 231 | 229 |
| 232 platform_util::OpenExternal( | 230 platform_util::OpenExternal( |
| 233 Profile::FromBrowserContext(web_contents->GetBrowserContext()), url); | 231 Profile::FromBrowserContext(web_contents->GetBrowserContext()), url); |
| 234 } | 232 } |
| 235 | 233 |
| 236 // static | 234 // static |
| 237 void ExternalProtocolHandler::PermitLaunchUrl() { | 235 void ExternalProtocolHandler::PermitLaunchUrl() { |
| 238 DCHECK(base::MessageLoopForUI::IsCurrent()); | 236 DCHECK(base::MessageLoopForUI::IsCurrent()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 // static | 291 // static |
| 294 void ExternalProtocolHandler::RecordMetrics(bool selected) { | 292 void ExternalProtocolHandler::RecordMetrics(bool selected) { |
| 295 UMA_HISTOGRAM_BOOLEAN("BrowserDialogs.ExternalProtocol.RememberCheckbox", | 293 UMA_HISTOGRAM_BOOLEAN("BrowserDialogs.ExternalProtocol.RememberCheckbox", |
| 296 selected); | 294 selected); |
| 297 } | 295 } |
| 298 | 296 |
| 299 // static | 297 // static |
| 300 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) { | 298 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
| 301 registry->RegisterDictionaryPref(prefs::kExcludedSchemes); | 299 registry->RegisterDictionaryPref(prefs::kExcludedSchemes); |
| 302 } | 300 } |
| OLD | NEW |