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

Side by Side Diff: chrome/browser/external_protocol/external_protocol_handler.h

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, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ 5 #ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_
6 #define CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ 6 #define CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/shell_integration.h" 10 #include "chrome/browser/shell_integration.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Checks to see if the protocol is allowed, if it is whitelisted, 49 // Checks to see if the protocol is allowed, if it is whitelisted,
50 // the application associated with the protocol is launched on the io thread, 50 // the application associated with the protocol is launched on the io thread,
51 // if it is blacklisted, returns silently. Otherwise, an 51 // if it is blacklisted, returns silently. Otherwise, an
52 // ExternalProtocolDialog is created asking the user. If the user accepts, 52 // ExternalProtocolDialog is created asking the user. If the user accepts,
53 // LaunchUrlWithoutSecurityCheck is called on the io thread and the 53 // LaunchUrlWithoutSecurityCheck is called on the io thread and the
54 // application is launched. 54 // application is launched.
55 // Must run on the UI thread. 55 // Must run on the UI thread.
56 static void LaunchUrl(const GURL& url, int render_process_host_id, 56 static void LaunchUrl(const GURL& url, int render_process_host_id,
57 int tab_contents_id) { 57 int tab_contents_id) {
58 LaunchUrlWithDelegate(url, render_process_host_id, tab_contents_id, NULL); 58 LaunchUrlWithDelegate(
59 url, render_process_host_id, tab_contents_id, NULL);
not at google - send to devlin 2014/03/28 18:54:23 doesn't seem like a necessary change, but "git cl
meacer 2014/03/28 19:53:11 Yes, this remained from the previous patchset.
59 } 60 }
60 61
61 // Version of LaunchUrl allowing use of a delegate to facilitate unit 62 // Version of LaunchUrl allowing use of a delegate to facilitate unit
62 // testing. 63 // testing.
63 static void LaunchUrlWithDelegate(const GURL& url, int render_process_host_id, 64 static void LaunchUrlWithDelegate(const GURL& url, int render_process_host_id,
64 int tab_contents_id, Delegate* delegate); 65 int tab_contents_id, Delegate* delegate);
65 66
66 // Creates and runs a External Protocol dialog box. 67 // Creates and runs a External Protocol dialog box.
67 // |url| - The url of the request. 68 // |url| - The url of the request.
68 // |render_process_host_id| and |routing_id| are used by 69 // |render_process_host_id| and |routing_id| are used by
(...skipping 20 matching lines...) Expand all
89 // url you have has been checked against the blacklist, and has been escaped. 90 // url you have has been checked against the blacklist, and has been escaped.
90 // All calls to this function should originate in some way from LaunchUrl. 91 // All calls to this function should originate in some way from LaunchUrl.
91 static void LaunchUrlWithoutSecurityCheck(const GURL& url, 92 static void LaunchUrlWithoutSecurityCheck(const GURL& url,
92 int render_process_host_id, 93 int render_process_host_id,
93 int tab_contents_id); 94 int tab_contents_id);
94 95
95 // Prepopulates the dictionary with known protocols to deny or allow, if 96 // Prepopulates the dictionary with known protocols to deny or allow, if
96 // preferences for them do not already exist. 97 // preferences for them do not already exist.
97 static void PrepopulateDictionary(base::DictionaryValue* win_pref); 98 static void PrepopulateDictionary(base::DictionaryValue* win_pref);
98 99
99 // Allows LaunchUrl to proceed with launching an external protocol handler. 100 class ScopedUserGesture {
100 // This is typically triggered by a user gesture, but is also called for 101 public:
101 // each extension API function. Note that each call to LaunchUrl resets 102 ScopedUserGesture() {
102 // the state to false (not allowed). 103 ExternalProtocolHandler::EnableUserGesture();
103 static void PermitLaunchUrl(); 104 }
105 ~ScopedUserGesture() {
106 ExternalProtocolHandler::DisableUserGesture();
not at google - send to devlin 2014/03/28 18:54:23 that's not quite right, it would break nested scop
meacer 2014/03/28 19:53:11 Done.
107 }
108 private:
109 DISALLOW_COPY_AND_ASSIGN(ScopedUserGesture);
110 };
111
112 private:
113 static void EnableUserGesture();
114 static void DisableUserGesture();
115 DISALLOW_COPY_AND_ASSIGN(ExternalProtocolHandler);
104 }; 116 };
105 117
118
106 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ 119 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698