| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_HANDLER_H__ | 5 #ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_HANDLER_H_ |
| 6 #define CHROME_BROWSER_EXTERNAL_PROTOCOL_HANDLER_H__ | 6 #define CHROME_BROWSER_EXTERNAL_PROTOCOL_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 class DictionaryValue; | 10 class DictionaryValue; |
| 11 class GURL; | 11 class GURL; |
| 12 class MessageLoop; | 12 class MessageLoop; |
| 13 class PrefService; | 13 class PrefService; |
| 14 | 14 |
| 15 class ExternalProtocolHandler { | 15 class ExternalProtocolHandler { |
| 16 public: | 16 public: |
| 17 enum BlockState { | 17 enum BlockState { |
| 18 DONT_BLOCK, | 18 DONT_BLOCK, |
| 19 BLOCK, | 19 BLOCK, |
| 20 UNKNOWN, | 20 UNKNOWN, |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 // Returns whether we should block a given scheme. | 23 // Returns whether we should block a given scheme. |
| 24 static BlockState GetBlockState(const std::wstring& scheme); | 24 static BlockState GetBlockState(const std::wstring& scheme); |
| 25 | 25 |
| 26 // Checks to see if the protocol is allowed, if it is whitelisted, | 26 // Checks to see if the protocol is allowed, if it is whitelisted, |
| 27 // the application associated with the protocol is launched on the io thread, | 27 // the application associated with the protocol is launched on the io thread, |
| 28 // if it is blacklisted, returns silently. Otherwise, an | 28 // if it is blacklisted, returns silently. Otherwise, an |
| 29 // ExternalProtocolDialog is created asking the user. If the user accepts, | 29 // ExternalProtocolDialog is created asking the user. If the user accepts, |
| 30 // LaunchUrlWithoutSecurityCheck is called on the io thread and the | 30 // LaunchUrlWithoutSecurityCheck is called on the io thread and the |
| 31 // application is launched. | 31 // application is launched. |
| 32 // Must run on the UI thread. | 32 // Must run on the UI thread. |
| 33 static void LaunchUrl(const GURL& url, int render_process_host_id, | 33 static void LaunchUrl(const GURL& url, int render_process_host_id, |
| 34 int tab_contents_id); | 34 int tab_contents_id); |
| 35 | 35 |
| 36 // Creates and runs a External Protocol dialog box. |
| 37 // |url| - The url of the request. |
| 38 // |render_process_host_id| and |routing_id| are used by |
| 39 // tab_util::GetTabContentsByID to aquire the tab contents associated with |
| 40 // this dialog. |
| 41 // NOTE: There is a race between the Time of Check and the Time Of Use for |
| 42 // the command line. Since the caller (web page) does not have access |
| 43 // to change the command line by itself, we do not do anything special |
| 44 // to protect against this scenario. |
| 45 // This is implemented separately on each platform. |
| 46 static void RunExternalProtocolDialog(const GURL& url, |
| 47 int render_process_host_id, |
| 48 int routing_id); |
| 49 |
| 36 // Register the ExcludedSchemes preference. | 50 // Register the ExcludedSchemes preference. |
| 37 static void RegisterPrefs(PrefService* prefs); | 51 static void RegisterPrefs(PrefService* prefs); |
| 38 | 52 |
| 39 // Starts a url using the external protocol handler with the help | 53 // Starts a url using the external protocol handler with the help |
| 40 // of shellexecute. Should only be called if the protocol is whitelisted | 54 // of shellexecute. Should only be called if the protocol is whitelisted |
| 41 // (checked in LaunchUrl) or if the user explicitly allows it. (By selecting | 55 // (checked in LaunchUrl) or if the user explicitly allows it. (By selecting |
| 42 // "Launch Application" in an ExternalProtocolDialog.) It is assumed that the | 56 // "Launch Application" in an ExternalProtocolDialog.) It is assumed that the |
| 43 // url has already been escaped, which happens in LaunchUrl. | 57 // url has already been escaped, which happens in LaunchUrl. |
| 44 // NOTE: You should Not call this function directly unless you are sure the | 58 // NOTE: You should Not call this function directly unless you are sure the |
| 45 // url you have has been checked against the blacklist, and has been escaped. | 59 // url you have has been checked against the blacklist, and has been escaped. |
| 46 // All calls to this function should originate in some way from LaunchUrl. | 60 // All calls to this function should originate in some way from LaunchUrl. |
| 47 // Must run on the file thread. | 61 // This will execute on the file thread. |
| 48 static void LaunchUrlWithoutSecurityCheck(const GURL& url); | 62 static void LaunchUrlWithoutSecurityCheck(const GURL& url); |
| 49 | 63 |
| 50 // Prepopulates the dictionary with known protocols to deny or allow, if | 64 // Prepopulates the dictionary with known protocols to deny or allow, if |
| 51 // preferences for them do not already exist. | 65 // preferences for them do not already exist. |
| 52 static void PrepopulateDictionary(DictionaryValue* win_pref); | 66 static void PrepopulateDictionary(DictionaryValue* win_pref); |
| 53 }; | 67 }; |
| 54 | 68 |
| 55 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_HANDLER_H__ | 69 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_HANDLER_H_ |
| OLD | NEW |