Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Unified Diff: chrome/browser/external_protocol/external_protocol_handler.cc

Issue 131783012: Fix the handling of user gestures for external protocol handler dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..25ca460e5247f5ceb01838ba080bbc9322e1b688 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler.cc
@@ -27,10 +27,10 @@
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;
+// Whether there is an existing user gesture. A user gesture is required to
+// launch external protocols. This variable should only be accessed from the UI
+// thread.
+static bool g_user_gesture = false;
namespace {
@@ -204,8 +204,7 @@ 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)
+ if (!g_user_gesture)
return BLOCK;
if (scheme.length() == 1) {
@@ -270,8 +269,6 @@ void ExternalProtocolHandler::LaunchUrlWithDelegate(const GURL& url,
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.
@@ -310,7 +307,13 @@ void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) {
}
// static
-void ExternalProtocolHandler::PermitLaunchUrl() {
- DCHECK(base::MessageLoopForUI::IsCurrent());
- g_accept_requests = true;
+void ExternalProtocolHandler::EnableUserGesture() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ g_user_gesture = true;
+}
+
+// static
+void ExternalProtocolHandler::DisableUserGesture() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ g_user_gesture = false;
}

Powered by Google App Engine
This is Rietveld 408576698