OLD | NEW |
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 "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // application is launched. | 60 // application is launched. |
61 // Must run on the UI thread. | 61 // Must run on the UI thread. |
62 // Allowing use of a delegate to facilitate unit testing. | 62 // Allowing use of a delegate to facilitate unit testing. |
63 static void LaunchUrlWithDelegate(const GURL& url, | 63 static void LaunchUrlWithDelegate(const GURL& url, |
64 int render_process_host_id, | 64 int render_process_host_id, |
65 int tab_contents_id, | 65 int tab_contents_id, |
66 ui::PageTransition page_transition, | 66 ui::PageTransition page_transition, |
67 bool has_user_gesture, | 67 bool has_user_gesture, |
68 Delegate* delegate); | 68 Delegate* delegate); |
69 | 69 |
70 // Creates and runs a External Protocol dialog box. | |
71 // |url| - The url of the request. | |
72 // |render_process_host_id| and |routing_id| are used by | |
73 // tab_util::GetWebContentsByID to aquire the tab contents associated with | |
74 // this dialog. | |
75 // NOTE: There is a race between the Time of Check and the Time Of Use for | |
76 // the command line. Since the caller (web page) does not have access | |
77 // to change the command line by itself, we do not do anything special | |
78 // to protect against this scenario. | |
79 // This is implemented separately on each platform. | |
80 static void RunExternalProtocolDialog(const GURL& url, | |
81 int render_process_host_id, | |
82 int routing_id, | |
83 ui::PageTransition page_transition, | |
84 bool has_user_gesture); | |
85 | |
86 // Register the ExcludedSchemes preference. | |
87 static void RegisterPrefs(PrefRegistrySimple* registry); | |
88 | |
89 // Starts a url using the external protocol handler with the help | 70 // Starts a url using the external protocol handler with the help |
90 // of shellexecute. Should only be called if the protocol is whitelisted | 71 // of shellexecute. Should only be called if the protocol is whitelisted |
91 // (checked in LaunchUrl) or if the user explicitly allows it. (By selecting | 72 // (checked in LaunchUrl) or if the user explicitly allows it. (By selecting |
92 // "Launch Application" in an ExternalProtocolDialog.) It is assumed that the | 73 // "Launch Application" in an ExternalProtocolDialog.) It is assumed that the |
93 // url has already been escaped, which happens in LaunchUrl. | 74 // url has already been escaped, which happens in LaunchUrl. |
94 // NOTE: You should Not call this function directly unless you are sure the | 75 // NOTE: You should Not call this function directly unless you are sure the |
95 // url you have has been checked against the blacklist, and has been escaped. | 76 // url you have has been checked against the blacklist, and has been escaped. |
96 // All calls to this function should originate in some way from LaunchUrl. | 77 // All calls to this function should originate in some way from LaunchUrl. |
97 static void LaunchUrlWithoutSecurityCheck(const GURL& url, | 78 static void LaunchUrlWithoutSecurityCheck(const GURL& url, |
98 int render_process_host_id, | 79 int render_process_host_id, |
99 int tab_contents_id); | 80 int tab_contents_id); |
100 | 81 |
101 // Prepopulates the dictionary with known protocols to deny or allow, if | |
102 // preferences for them do not already exist. | |
103 static void PrepopulateDictionary(base::DictionaryValue* win_pref); | |
104 | |
105 // Allows LaunchUrl to proceed with launching an external protocol handler. | 82 // Allows LaunchUrl to proceed with launching an external protocol handler. |
106 // This is typically triggered by a user gesture, but is also called for | 83 // This is typically triggered by a user gesture, but is also called for |
107 // each extension API function. Note that each call to LaunchUrl resets | 84 // each extension API function. Note that each call to LaunchUrl resets |
108 // the state to false (not allowed). | 85 // the state to false (not allowed). |
109 static void PermitLaunchUrl(); | 86 static void PermitLaunchUrl(); |
110 | 87 |
| 88 // Prepopulates the dictionary with known protocols to deny or allow, if |
| 89 // preferences for them do not already exist. |
| 90 static void PrepopulateDictionary(base::DictionaryValue* win_pref); |
| 91 |
| 92 // Records an UMA metric for the state of the checkbox in the dialog, i.e. |
| 93 // whether |selected| is true (checked) or false (unchecked). |
| 94 static void RecordMetrics(bool selected); |
| 95 |
| 96 // Register the ExcludedSchemes preference. |
| 97 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 98 |
| 99 // Creates and runs a External Protocol dialog box. |
| 100 // |url| - The url of the request. |
| 101 // |render_process_host_id| and |routing_id| are used by |
| 102 // tab_util::GetWebContentsByID to aquire the tab contents associated with |
| 103 // this dialog. |
| 104 // NOTE: There is a race between the Time of Check and the Time Of Use for |
| 105 // the command line. Since the caller (web page) does not have access |
| 106 // to change the command line by itself, we do not do anything special |
| 107 // to protect against this scenario. |
| 108 // This is implemented separately on each platform. |
| 109 static void RunExternalProtocolDialog(const GURL& url, |
| 110 int render_process_host_id, |
| 111 int routing_id, |
| 112 ui::PageTransition page_transition, |
| 113 bool has_user_gesture); |
| 114 |
111 private: | 115 private: |
112 DISALLOW_COPY_AND_ASSIGN(ExternalProtocolHandler); | 116 DISALLOW_COPY_AND_ASSIGN(ExternalProtocolHandler); |
113 }; | 117 }; |
114 | 118 |
115 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ | 119 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ |
OLD | NEW |