summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc8
-rw-r--r--android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h3
-rw-r--r--apps/shell/browser/shell_extensions_browser_client.cc3
-rw-r--r--apps/shell/browser/shell_extensions_browser_client.h1
-rw-r--r--chrome/browser/autocomplete/autocomplete_input.cc5
-rw-r--r--chrome/browser/extensions/active_tab_permission_granter.cc3
-rw-r--r--chrome/browser/extensions/chrome_extensions_browser_client.cc4
-rw-r--r--chrome/browser/extensions/chrome_extensions_browser_client.h1
-rw-r--r--chrome/browser/external_protocol/external_protocol_handler.cc40
-rw-r--r--chrome/browser/external_protocol/external_protocol_handler.h28
-rw-r--r--chrome/browser/external_protocol/external_protocol_handler_unittest.cc10
-rw-r--r--chrome/browser/external_protocol/external_protocol_observer.cc22
-rw-r--r--chrome/browser/external_protocol/external_protocol_observer.h29
-rw-r--r--chrome/browser/prerender/prerender_browsertest.cc3
-rw-r--r--chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc14
-rw-r--r--chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h3
-rw-r--r--chrome/browser/ui/tab_helpers.cc2
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--content/browser/loader/resource_dispatcher_host_impl.cc11
-rw-r--r--content/public/browser/resource_dispatcher_host_delegate.cc8
-rw-r--r--content/public/browser/resource_dispatcher_host_delegate.h5
-rw-r--r--extensions/browser/extension_function_dispatcher.cc2
-rw-r--r--extensions/browser/extensions_browser_client.h4
-rw-r--r--extensions/browser/test_extensions_browser_client.cc2
-rw-r--r--extensions/browser/test_extensions_browser_client.h1
25 files changed, 73 insertions, 142 deletions
diff --git a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
index 00b6e60..05eb520 100644
--- a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
+++ b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
@@ -298,9 +298,11 @@ content::ResourceDispatcherHostLoginDelegate*
return new AwLoginDelegate(auth_info, request);
}
-bool AwResourceDispatcherHostDelegate::HandleExternalProtocol(const GURL& url,
- int child_id,
- int route_id) {
+bool AwResourceDispatcherHostDelegate::HandleExternalProtocol(
+ const GURL& url,
+ int child_id,
+ int route_id,
+ bool initiated_by_user_gesture) {
// The AwURLRequestJobFactory implementation should ensure this method never
// gets called.
NOTREACHED();
diff --git a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h
index e584c40..8702b09 100644
--- a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h
+++ b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h
@@ -51,7 +51,8 @@ class AwResourceDispatcherHostDelegate
net::URLRequest* request) OVERRIDE;
virtual bool HandleExternalProtocol(const GURL& url,
int child_id,
- int route_id) OVERRIDE;
+ int route_id,
+ bool initiated_by_user_gesture) OVERRIDE;
virtual void OnResponseStarted(
net::URLRequest* request,
content::ResourceContext* resource_context,
diff --git a/apps/shell/browser/shell_extensions_browser_client.cc b/apps/shell/browser/shell_extensions_browser_client.cc
index bfa44d7..9207f77 100644
--- a/apps/shell/browser/shell_extensions_browser_client.cc
+++ b/apps/shell/browser/shell_extensions_browser_client.cc
@@ -178,9 +178,6 @@ bool ShellExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
return false;
}
-void ShellExtensionsBrowserClient::PermitExternalProtocolHandler() {
-}
-
scoped_ptr<AppSorting> ShellExtensionsBrowserClient::CreateAppSorting() {
return scoped_ptr<AppSorting>(new apps::ShellAppSorting);
}
diff --git a/apps/shell/browser/shell_extensions_browser_client.h b/apps/shell/browser/shell_extensions_browser_client.h
index d7aed6b..c2a2130 100644
--- a/apps/shell/browser/shell_extensions_browser_client.h
+++ b/apps/shell/browser/shell_extensions_browser_client.h
@@ -54,7 +54,6 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {
virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate()
OVERRIDE;
virtual bool DidVersionUpdate(content::BrowserContext* context) OVERRIDE;
- virtual void PermitExternalProtocolHandler() OVERRIDE;
virtual scoped_ptr<AppSorting> CreateAppSorting() OVERRIDE;
virtual bool IsRunningInForcedAppMode() OVERRIDE;
virtual ApiActivityMonitor* GetApiActivityMonitor(
diff --git a/chrome/browser/autocomplete/autocomplete_input.cc b/chrome/browser/autocomplete/autocomplete_input.cc
index ea42851..4672f0c 100644
--- a/chrome/browser/autocomplete/autocomplete_input.cc
+++ b/chrome/browser/autocomplete/autocomplete_input.cc
@@ -198,9 +198,12 @@ AutocompleteInput::Type AutocompleteInput::Parse(
// handlable schemes (e.g. "javascript") may be treated as "blocked" by the
// external protocol handler because we don't want pages to open them, but
// users still can.
+ // Note that the protocol handler needs to be informed that omnibox input
+ // should always be considered "user gesture-triggered", lest it always
+ // return BLOCK.
ExternalProtocolHandler::BlockState block_state =
ExternalProtocolHandler::GetBlockState(
- base::UTF16ToUTF8(parsed_scheme));
+ base::UTF16ToUTF8(parsed_scheme), true);
switch (block_state) {
case ExternalProtocolHandler::DONT_BLOCK:
return return_value_for_non_http_url;
diff --git a/chrome/browser/extensions/active_tab_permission_granter.cc b/chrome/browser/extensions/active_tab_permission_granter.cc
index ecedd34..756007e 100644
--- a/chrome/browser/extensions/active_tab_permission_granter.cc
+++ b/chrome/browser/extensions/active_tab_permission_granter.cc
@@ -37,6 +37,9 @@ ActiveTabPermissionGranter::ActiveTabPermissionGranter(
ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {}
void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
+ // Active tab grant request implies there was a user gesture.
+ web_contents()->UserGestureDone();
+
if (granted_extensions_.Contains(extension->id()))
return;
diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.cc b/chrome/browser/extensions/chrome_extensions_browser_client.cc
index ffa47b0f..2b4a850 100644
--- a/chrome/browser/extensions/chrome_extensions_browser_client.cc
+++ b/chrome/browser/extensions/chrome_extensions_browser_client.cc
@@ -192,10 +192,6 @@ bool ChromeExtensionsBrowserClient::DidVersionUpdate(
return last_version.IsOlderThan(current_version);
}
-void ChromeExtensionsBrowserClient::PermitExternalProtocolHandler() {
- ExternalProtocolHandler::PermitLaunchUrl();
-}
-
scoped_ptr<AppSorting> ChromeExtensionsBrowserClient::CreateAppSorting() {
return scoped_ptr<AppSorting>(new ChromeAppSorting());
}
diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.h b/chrome/browser/extensions/chrome_extensions_browser_client.h
index 6db01dc..80e8fbd 100644
--- a/chrome/browser/extensions/chrome_extensions_browser_client.h
+++ b/chrome/browser/extensions/chrome_extensions_browser_client.h
@@ -68,7 +68,6 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient {
virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate()
OVERRIDE;
virtual bool DidVersionUpdate(content::BrowserContext* context) OVERRIDE;
- virtual void PermitExternalProtocolHandler() OVERRIDE;
virtual scoped_ptr<AppSorting> CreateAppSorting() OVERRIDE;
virtual bool IsRunningInForcedAppMode() OVERRIDE;
virtual ApiActivityMonitor* GetApiActivityMonitor(
diff --git a/chrome/browser/external_protocol/external_protocol_handler.cc b/chrome/browser/external_protocol/external_protocol_handler.cc
index b414261..78334d9 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;
-}
diff --git a/chrome/browser/external_protocol/external_protocol_handler.h b/chrome/browser/external_protocol/external_protocol_handler.h
index 7c934c5..6780d10 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.h
+++ b/chrome/browser/external_protocol/external_protocol_handler.h
@@ -30,7 +30,8 @@ class ExternalProtocolHandler {
virtual ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
ShellIntegration::DefaultWebClientObserver* observer,
const std::string& protocol) = 0;
- virtual BlockState GetBlockState(const std::string& scheme) = 0;
+ virtual BlockState GetBlockState(const std::string& scheme,
+ bool initiated_by_user_gesture) = 0;
virtual void BlockRequest() = 0;
virtual void RunExternalProtocolDialog(const GURL& url,
int render_process_host_id,
@@ -41,27 +42,17 @@ class ExternalProtocolHandler {
};
// Returns whether we should block a given scheme.
- static BlockState GetBlockState(const std::string& scheme);
+ static BlockState GetBlockState(const std::string& scheme,
+ bool initiated_by_user_gesture);
// Sets whether we should block a given scheme.
static void SetBlockState(const std::string& scheme, BlockState state);
- // Checks to see if the protocol is allowed, if it is whitelisted,
- // the application associated with the protocol is launched on the io thread,
- // if it is blacklisted, returns silently. Otherwise, an
- // ExternalProtocolDialog is created asking the user. If the user accepts,
- // LaunchUrlWithoutSecurityCheck is called on the io thread and the
- // application is launched.
- // Must run on the UI thread.
- static void LaunchUrl(const GURL& url, int render_process_host_id,
- int tab_contents_id) {
- LaunchUrlWithDelegate(url, render_process_host_id, tab_contents_id, NULL);
- }
-
// Version of LaunchUrl allowing use of a delegate to facilitate unit
// testing.
static void LaunchUrlWithDelegate(const GURL& url, int render_process_host_id,
- int tab_contents_id, Delegate* delegate);
+ int tab_contents_id, Delegate* delegate,
+ bool initiated_by_user_gesture);
// Creates and runs a External Protocol dialog box.
// |url| - The url of the request.
@@ -96,11 +87,8 @@ class ExternalProtocolHandler {
// preferences for them do not already exist.
static void PrepopulateDictionary(base::DictionaryValue* win_pref);
- // Allows LaunchUrl to proceed with launching an external protocol handler.
- // This is typically triggered by a user gesture, but is also called for
- // each extension API function. Note that each call to LaunchUrl resets
- // the state to false (not allowed).
- static void PermitLaunchUrl();
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ExternalProtocolHandler);
};
#endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_
diff --git a/chrome/browser/external_protocol/external_protocol_handler_unittest.cc b/chrome/browser/external_protocol/external_protocol_handler_unittest.cc
index 57a6db6..0b27465 100644
--- a/chrome/browser/external_protocol/external_protocol_handler_unittest.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler_unittest.cc
@@ -51,7 +51,8 @@ class FakeExternalProtocolHandlerDelegate
}
virtual ExternalProtocolHandler::BlockState GetBlockState(
- const std::string& scheme) OVERRIDE { return block_state_; }
+ const std::string& scheme,
+ bool initiated_by_user_gesture) OVERRIDE { return block_state_; }
virtual void BlockRequest() OVERRIDE {
ASSERT_TRUE(block_state_ == ExternalProtocolHandler::BLOCK ||
@@ -107,11 +108,6 @@ class ExternalProtocolHandlerTest : public testing::Test {
file_thread_.Start();
}
- virtual void TearDown() {
- // Ensure that g_accept_requests gets set back to true after test execution.
- ExternalProtocolHandler::PermitLaunchUrl();
- }
-
void DoTest(ExternalProtocolHandler::BlockState block_state,
ShellIntegration::DefaultWebClientState os_state,
bool should_prompt, bool should_launch, bool should_block) {
@@ -122,7 +118,7 @@ class ExternalProtocolHandlerTest : public testing::Test {
delegate_.set_block_state(block_state);
delegate_.set_os_state(os_state);
- ExternalProtocolHandler::LaunchUrlWithDelegate(url, 0, 0, &delegate_);
+ ExternalProtocolHandler::LaunchUrlWithDelegate(url, 0, 0, &delegate_, true);
if (block_state != ExternalProtocolHandler::BLOCK)
base::MessageLoop::current()->Run();
diff --git a/chrome/browser/external_protocol/external_protocol_observer.cc b/chrome/browser/external_protocol/external_protocol_observer.cc
deleted file mode 100644
index 8f69517..0000000
--- a/chrome/browser/external_protocol/external_protocol_observer.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/external_protocol/external_protocol_observer.h"
-
-#include "chrome/browser/external_protocol/external_protocol_handler.h"
-
-using content::WebContents;
-
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(ExternalProtocolObserver);
-
-ExternalProtocolObserver::ExternalProtocolObserver(WebContents* web_contents)
- : content::WebContentsObserver(web_contents) {
-}
-
-ExternalProtocolObserver::~ExternalProtocolObserver() {
-}
-
-void ExternalProtocolObserver::DidGetUserGesture() {
- ExternalProtocolHandler::PermitLaunchUrl();
-}
diff --git a/chrome/browser/external_protocol/external_protocol_observer.h b/chrome/browser/external_protocol/external_protocol_observer.h
deleted file mode 100644
index 8249c3d..0000000
--- a/chrome/browser/external_protocol/external_protocol_observer.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_OBSERVER_H_
-#define CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_OBSERVER_H_
-
-#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/web_contents_user_data.h"
-
-// ExternalProtocolObserver is responsible for handling messages from
-// WebContents relating to external protocols.
-class ExternalProtocolObserver
- : public content::WebContentsObserver,
- public content::WebContentsUserData<ExternalProtocolObserver> {
- public:
- virtual ~ExternalProtocolObserver();
-
- // content::WebContentsObserver overrides.
- virtual void DidGetUserGesture() OVERRIDE;
-
- private:
- explicit ExternalProtocolObserver(content::WebContents* web_contents);
- friend class content::WebContentsUserData<ExternalProtocolObserver>;
-
- DISALLOW_COPY_AND_ASSIGN(ExternalProtocolObserver);
-};
-
-#endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_OBSERVER_H_
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index af8e09e..68841b8 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -972,7 +972,8 @@ class NeverRunsExternalProtocolHandlerDelegate
return NULL;
}
virtual ExternalProtocolHandler::BlockState GetBlockState(
- const std::string& scheme) OVERRIDE {
+ const std::string& scheme,
+ bool initiated_by_user_gesture) OVERRIDE {
// Block everything and fail the test.
ADD_FAILURE();
return ExternalProtocolHandler::BLOCK;
diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
index 268e374..8fe2144 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
@@ -198,7 +198,8 @@ void SendExecuteMimeTypeHandlerEvent(scoped_ptr<content::StreamHandle> stream,
extension_id, web_contents, stream.Pass(), expected_content_size);
}
-void LaunchURL(const GURL& url, int render_process_id, int render_view_id) {
+void LaunchURL(const GURL& url, int render_process_id, int render_view_id,
+ bool user_gesture) {
// If there is no longer a WebContents, the request may have raced with tab
// closing. Don't fire the external request. (It may have been a prerender.)
content::WebContents* web_contents =
@@ -217,7 +218,8 @@ void LaunchURL(const GURL& url, int render_process_id, int render_view_id) {
ExternalProtocolHandler::LaunchUrlWithDelegate(
url, render_process_id, render_view_id,
- g_external_protocol_handler_delegate);
+ g_external_protocol_handler_delegate,
+ user_gesture);
}
#endif // !defined(OS_ANDROID)
@@ -441,7 +443,10 @@ ResourceDispatcherHostLoginDelegate*
}
bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol(
- const GURL& url, int child_id, int route_id) {
+ const GURL& url,
+ int child_id,
+ int route_id,
+ bool initiated_by_user_gesture) {
#if defined(OS_ANDROID)
// Android use a resource throttle to handle external as well as internal
// protocols.
@@ -457,7 +462,8 @@ bool ChromeResourceDispatcherHostDelegate::HandleExternalProtocol(
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(&LaunchURL, url, child_id, route_id));
+ base::Bind(&LaunchURL, url, child_id, route_id,
+ initiated_by_user_gesture));
return true;
#endif
}
diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h
index 8bcf06a..b154b5b 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h
@@ -65,7 +65,8 @@ class ChromeResourceDispatcherHostDelegate
net::AuthChallengeInfo* auth_info, net::URLRequest* request) OVERRIDE;
virtual bool HandleExternalProtocol(const GURL& url,
int child_id,
- int route_id) OVERRIDE;
+ int route_id,
+ bool initiated_by_user_gesture) OVERRIDE;
virtual bool ShouldForceDownloadResource(
const GURL& url, const std::string& mime_type) OVERRIDE;
virtual bool ShouldInterceptResourceAsStream(
diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc
index 5fd4fef..45853cd 100644
--- a/chrome/browser/ui/tab_helpers.cc
+++ b/chrome/browser/ui/tab_helpers.cc
@@ -40,7 +40,6 @@
#else
#include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
-#include "chrome/browser/external_protocol/external_protocol_observer.h"
#include "chrome/browser/net/predictor_tab_helper.h"
#include "chrome/browser/network_time/navigation_time_helper.h"
#include "chrome/browser/plugins/plugin_observer.h"
@@ -152,7 +151,6 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
web_contents);
extensions::WebNavigationTabObserver::CreateForWebContents(web_contents);
- ExternalProtocolObserver::CreateForWebContents(web_contents);
HungPluginTabHelper::CreateForWebContents(web_contents);
ManagePasswordsBubbleUIController::CreateForWebContents(web_contents);
NavigationTimeHelper::CreateForWebContents(web_contents);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index ca6a63f..329c646 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -654,8 +654,6 @@
'browser/extensions/token_cache/token_cache_service_factory.h',
'browser/external_protocol/external_protocol_handler.cc',
'browser/external_protocol/external_protocol_handler.h',
- 'browser/external_protocol/external_protocol_observer.cc',
- 'browser/external_protocol/external_protocol_observer.h',
'browser/favicon/favicon_changed_details.cc',
'browser/favicon/favicon_changed_details.h',
'browser/favicon/favicon_handler.cc',
@@ -3336,7 +3334,6 @@
'browser/download/download_shelf.cc',
'browser/download/download_shelf_context_menu.cc',
'browser/drive/drive_switches.cc',
- 'browser/external_protocol/external_protocol_observer.cc',
'browser/feedback/proto/annotations.proto',
'browser/feedback/proto/chrome.proto',
'browser/feedback/proto/common.proto',
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index 61fc35b..c5e067d 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -679,8 +679,15 @@ bool ResourceDispatcherHostImpl::HandleExternalProtocol(ResourceLoader* loader,
if (job_factory->IsHandledURL(url))
return false;
- return delegate_->HandleExternalProtocol(url, info->GetChildID(),
- info->GetRouteID());
+ bool initiated_by_user_gesture =
+ (loader->request()->load_flags() & net::LOAD_MAYBE_USER_GESTURE) != 0;
+ bool handled = delegate_->HandleExternalProtocol(url, info->GetChildID(),
+ info->GetRouteID(),
+ initiated_by_user_gesture);
+ // Consume the user gesture if the external protocol dialog is shown.
+ if (handled)
+ last_user_gesture_time_ = base::TimeTicks();
+ return handled;
}
void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoader* loader) {
diff --git a/content/public/browser/resource_dispatcher_host_delegate.cc b/content/public/browser/resource_dispatcher_host_delegate.cc
index bf92b25..ccd358f 100644
--- a/content/public/browser/resource_dispatcher_host_delegate.cc
+++ b/content/public/browser/resource_dispatcher_host_delegate.cc
@@ -46,9 +46,11 @@ ResourceDispatcherHostLoginDelegate*
return NULL;
}
-bool ResourceDispatcherHostDelegate::HandleExternalProtocol(const GURL& url,
- int child_id,
- int route_id) {
+bool ResourceDispatcherHostDelegate::HandleExternalProtocol(
+ const GURL& url,
+ int child_id,
+ int route_id,
+ bool initiated_by_user_gesture) {
return true;
}
diff --git a/content/public/browser/resource_dispatcher_host_delegate.h b/content/public/browser/resource_dispatcher_host_delegate.h
index 0d0eebc..598cffb 100644
--- a/content/public/browser/resource_dispatcher_host_delegate.h
+++ b/content/public/browser/resource_dispatcher_host_delegate.h
@@ -84,9 +84,12 @@ class CONTENT_EXPORT ResourceDispatcherHostDelegate {
// Launches the url for the given tab. Returns true if an attempt to handle
// the url was made, e.g. by launching an app. Note that this does not
// guarantee that the app successfully handled it.
+ // Some external protocol handlers only run in the context of a user gesture,
+ // so initiated_by_user_gesture should be passed accordingly.
virtual bool HandleExternalProtocol(const GURL& url,
int child_id,
- int route_id);
+ int route_id,
+ bool initiated_by_user_gesture);
// Returns true if we should force the given resource to be downloaded.
// Otherwise, the content layer decides.
diff --git a/extensions/browser/extension_function_dispatcher.cc b/extensions/browser/extension_function_dispatcher.cc
index 5e0cffe..d6420e3 100644
--- a/extensions/browser/extension_function_dispatcher.cc
+++ b/extensions/browser/extension_function_dispatcher.cc
@@ -375,8 +375,6 @@ void ExtensionFunctionDispatcher::DispatchWithCallbackInternal(
if (violation_error.empty()) {
scoped_ptr<base::ListValue> args(params.arguments.DeepCopy());
- // See crbug.com/39178.
- ExtensionsBrowserClient::Get()->PermitExternalProtocolHandler();
NotifyApiFunctionCalled(
extension->id(), params.name, args.Pass(), browser_context_);
function->Run();
diff --git a/extensions/browser/extensions_browser_client.h b/extensions/browser/extensions_browser_client.h
index f9e63e5..c7542a7 100644
--- a/extensions/browser/extensions_browser_client.h
+++ b/extensions/browser/extensions_browser_client.h
@@ -115,10 +115,6 @@ class ExtensionsBrowserClient {
// version for later comparison.
virtual bool DidVersionUpdate(content::BrowserContext* context) = 0;
- // Permits an external protocol handler to be launched. See
- // ExternalProtocolHandler::PermitLaunchUrl() in Chrome.
- virtual void PermitExternalProtocolHandler() = 0;
-
// Creates a new AppSorting instance.
virtual scoped_ptr<AppSorting> CreateAppSorting() = 0;
diff --git a/extensions/browser/test_extensions_browser_client.cc b/extensions/browser/test_extensions_browser_client.cc
index 14816cc..f1d3cc9 100644
--- a/extensions/browser/test_extensions_browser_client.cc
+++ b/extensions/browser/test_extensions_browser_client.cc
@@ -111,8 +111,6 @@ bool TestExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
return false;
}
-void TestExtensionsBrowserClient::PermitExternalProtocolHandler() {}
-
scoped_ptr<AppSorting> TestExtensionsBrowserClient::CreateAppSorting() {
return scoped_ptr<AppSorting>();
}
diff --git a/extensions/browser/test_extensions_browser_client.h b/extensions/browser/test_extensions_browser_client.h
index c0e83c3..4db3270 100644
--- a/extensions/browser/test_extensions_browser_client.h
+++ b/extensions/browser/test_extensions_browser_client.h
@@ -54,7 +54,6 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate()
OVERRIDE;
virtual bool DidVersionUpdate(content::BrowserContext* context) OVERRIDE;
- virtual void PermitExternalProtocolHandler() OVERRIDE;
virtual scoped_ptr<AppSorting> CreateAppSorting() OVERRIDE;
virtual bool IsRunningInForcedAppMode() OVERRIDE;
virtual ApiActivityMonitor* GetApiActivityMonitor(