| Index: chrome/browser/external_protocol/external_protocol_handler.cc
|
| diff --git a/chrome/browser/external_protocol/external_protocol_handler.cc b/chrome/browser/external_protocol/external_protocol_handler.cc
|
| index b414261cb32dd576f655e6e8529eba46d817e917..78334d9e362f9eb323201965f96a44430301fb9e 100644
|
| --- a/chrome/browser/external_protocol/external_protocol_handler.cc
|
| +++ b/chrome/browser/external_protocol/external_protocol_handler.cc
|
| @@ -27,11 +27,6 @@
|
|
|
| using content::BrowserThread;
|
|
|
| -// Whether we accept requests for launching external protocols. This is set to
|
| -// false every time an external protocol is requested, and set back to true on
|
| -// each user gesture. This variable should only be accessed from the UI thread.
|
| -static bool g_accept_requests = true;
|
| -
|
| namespace {
|
|
|
| // Functions enabling unit testing. Using a NULL delegate will use the default
|
| @@ -49,11 +44,13 @@ ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
|
|
|
| ExternalProtocolHandler::BlockState GetBlockStateWithDelegate(
|
| const std::string& scheme,
|
| - ExternalProtocolHandler::Delegate* delegate) {
|
| + ExternalProtocolHandler::Delegate* delegate,
|
| + bool initiated_by_user_gesture) {
|
| if (!delegate)
|
| - return ExternalProtocolHandler::GetBlockState(scheme);
|
| + return ExternalProtocolHandler::GetBlockState(scheme,
|
| + initiated_by_user_gesture);
|
|
|
| - return delegate->GetBlockState(scheme);
|
| + return delegate->GetBlockState(scheme, initiated_by_user_gesture);
|
| }
|
|
|
| void RunExternalProtocolDialogWithDelegate(
|
| @@ -203,9 +200,9 @@ void ExternalProtocolHandler::PrepopulateDictionary(
|
|
|
| // static
|
| ExternalProtocolHandler::BlockState ExternalProtocolHandler::GetBlockState(
|
| - const std::string& scheme) {
|
| - // If we are being carpet bombed, block the request.
|
| - if (!g_accept_requests)
|
| + const std::string& scheme,
|
| + bool initiated_by_user_gesture) {
|
| + if (!initiated_by_user_gesture)
|
| return BLOCK;
|
|
|
| if (scheme.length() == 1) {
|
| @@ -252,10 +249,12 @@ void ExternalProtocolHandler::SetBlockState(const std::string& scheme,
|
| }
|
|
|
| // static
|
| -void ExternalProtocolHandler::LaunchUrlWithDelegate(const GURL& url,
|
| - int render_process_host_id,
|
| - int tab_contents_id,
|
| - Delegate* delegate) {
|
| +void ExternalProtocolHandler::LaunchUrlWithDelegate(
|
| + const GURL& url,
|
| + int render_process_host_id,
|
| + int tab_contents_id,
|
| + Delegate* delegate,
|
| + bool initiated_by_user_gesture) {
|
| DCHECK(base::MessageLoopForUI::IsCurrent());
|
|
|
| // Escape the input scheme to be sure that the command does not
|
| @@ -263,15 +262,14 @@ void ExternalProtocolHandler::LaunchUrlWithDelegate(const GURL& url,
|
| std::string escaped_url_string = net::EscapeExternalHandlerValue(url.spec());
|
| GURL escaped_url(escaped_url_string);
|
| BlockState block_state = GetBlockStateWithDelegate(escaped_url.scheme(),
|
| - delegate);
|
| + delegate,
|
| + initiated_by_user_gesture);
|
| if (block_state == BLOCK) {
|
| if (delegate)
|
| delegate->BlockRequest();
|
| return;
|
| }
|
|
|
| - g_accept_requests = false;
|
| -
|
| // The worker creates tasks with references to itself and puts them into
|
| // message loops. When no tasks are left it will delete the observer and
|
| // eventually be deleted itself.
|
| @@ -308,9 +306,3 @@ void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(
|
| void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) {
|
| registry->RegisterDictionaryPref(prefs::kExcludedSchemes);
|
| }
|
| -
|
| -// static
|
| -void ExternalProtocolHandler::PermitLaunchUrl() {
|
| - DCHECK(base::MessageLoopForUI::IsCurrent());
|
| - g_accept_requests = true;
|
| -}
|
|
|