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

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

Issue 2538353002: fix external protocol handling for OOPIFs (Closed)
Patch Set: remove unnecessary include Created 4 years 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
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 "base/macros.h" 10 #include "base/macros.h"
11 #include "chrome/browser/shell_integration.h" 11 #include "chrome/browser/shell_integration.h"
12 #include "content/public/browser/web_contents.h"
12 #include "ui/base/page_transition_types.h" 13 #include "ui/base/page_transition_types.h"
13 14
14 class GURL; 15 class GURL;
15 class PrefRegistrySimple; 16 class PrefRegistrySimple;
16 17
17 namespace base { 18 namespace base {
18 class DictionaryValue; 19 class DictionaryValue;
19 } 20 }
20 21
21 class ExternalProtocolHandler { 22 class ExternalProtocolHandler {
(...skipping 12 matching lines...) Expand all
34 const shell_integration::DefaultWebClientWorkerCallback& callback, 35 const shell_integration::DefaultWebClientWorkerCallback& callback,
35 const std::string& protocol) = 0; 36 const std::string& protocol) = 0;
36 virtual BlockState GetBlockState(const std::string& scheme) = 0; 37 virtual BlockState GetBlockState(const std::string& scheme) = 0;
37 virtual void BlockRequest() = 0; 38 virtual void BlockRequest() = 0;
38 virtual void RunExternalProtocolDialog( 39 virtual void RunExternalProtocolDialog(
39 const GURL& url, 40 const GURL& url,
40 int render_process_host_id, 41 int render_process_host_id,
41 int routing_id, 42 int routing_id,
42 ui::PageTransition page_transition, 43 ui::PageTransition page_transition,
43 bool has_user_gesture) = 0; 44 bool has_user_gesture) = 0;
44 virtual void LaunchUrlWithoutSecurityCheck(const GURL& url) = 0; 45 virtual void LaunchUrlWithoutSecurityCheck(
46 const GURL& url,
47 content::WebContents* web_contents) = 0;
45 virtual void FinishedProcessingCheck() = 0; 48 virtual void FinishedProcessingCheck() = 0;
46 virtual ~Delegate() {} 49 virtual ~Delegate() {}
47 }; 50 };
48 51
49 // Returns whether we should block a given scheme. 52 // Returns whether we should block a given scheme.
50 static BlockState GetBlockState(const std::string& scheme); 53 static BlockState GetBlockState(const std::string& scheme);
51 54
52 // Sets whether we should block a given scheme. 55 // Sets whether we should block a given scheme.
53 static void SetBlockState(const std::string& scheme, BlockState state); 56 static void SetBlockState(const std::string& scheme, BlockState state);
54 57
(...skipping 14 matching lines...) Expand all
69 72
70 // Starts a url using the external protocol handler with the help 73 // Starts a url using the external protocol handler with the help
71 // of shellexecute. Should only be called if the protocol is whitelisted 74 // of shellexecute. Should only be called if the protocol is whitelisted
72 // (checked in LaunchUrl) or if the user explicitly allows it. (By selecting 75 // (checked in LaunchUrl) or if the user explicitly allows it. (By selecting
73 // "Launch Application" in an ExternalProtocolDialog.) It is assumed that the 76 // "Launch Application" in an ExternalProtocolDialog.) It is assumed that the
74 // url has already been escaped, which happens in LaunchUrl. 77 // url has already been escaped, which happens in LaunchUrl.
75 // NOTE: You should Not call this function directly unless you are sure the 78 // NOTE: You should Not call this function directly unless you are sure the
76 // url you have has been checked against the blacklist, and has been escaped. 79 // url you have has been checked against the blacklist, and has been escaped.
77 // All calls to this function should originate in some way from LaunchUrl. 80 // All calls to this function should originate in some way from LaunchUrl.
78 static void LaunchUrlWithoutSecurityCheck(const GURL& url, 81 static void LaunchUrlWithoutSecurityCheck(const GURL& url,
79 int render_process_host_id, 82 content::WebContents* web_contents);
80 int tab_contents_id);
81 83
82 // Allows LaunchUrl to proceed with launching an external protocol handler. 84 // Allows LaunchUrl to proceed with launching an external protocol handler.
83 // This is typically triggered by a user gesture, but is also called for 85 // This is typically triggered by a user gesture, but is also called for
84 // each extension API function. Note that each call to LaunchUrl resets 86 // each extension API function. Note that each call to LaunchUrl resets
85 // the state to false (not allowed). 87 // the state to false (not allowed).
86 static void PermitLaunchUrl(); 88 static void PermitLaunchUrl();
87 89
88 // Prepopulates the dictionary with known protocols to deny or allow, if 90 // Prepopulates the dictionary with known protocols to deny or allow, if
89 // preferences for them do not already exist. 91 // preferences for them do not already exist.
90 static void PrepopulateDictionary(base::DictionaryValue* win_pref); 92 static void PrepopulateDictionary(base::DictionaryValue* win_pref);
91 93
92 // Records an UMA metric for the state of the checkbox in the dialog, i.e. 94 // Records an UMA metric for the state of the checkbox in the dialog, i.e.
93 // whether |selected| is true (checked) or false (unchecked). 95 // whether |selected| is true (checked) or false (unchecked).
94 static void RecordMetrics(bool selected); 96 static void RecordMetrics(bool selected);
95 97
96 // Register the ExcludedSchemes preference. 98 // Register the ExcludedSchemes preference.
97 static void RegisterPrefs(PrefRegistrySimple* registry); 99 static void RegisterPrefs(PrefRegistrySimple* registry);
98 100
99 // Creates and runs a External Protocol dialog box. 101 // Creates and runs a External Protocol dialog box.
100 // |url| - The url of the request. 102 // |url| - The url of the request.
101 // |render_process_host_id| and |routing_id| are used by 103 // |render_process_host_id| and |routing_id| are used by
102 // tab_util::GetWebContentsByID to aquire the tab contents associated with 104 // tab_util::GetWebContentsByID to aquire the tab contents associated with
103 // this dialog. 105 // this dialog.
104 // NOTE: There is a race between the Time of Check and the Time Of Use for 106 // 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 107 // 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 108 // to change the command line by itself, we do not do anything special
107 // to protect against this scenario. 109 // to protect against this scenario.
108 // This is implemented separately on each platform. 110 // This is implemented separately on each platform.
111 // TODO(davidsac): Consider refactoring this to take a WebContents directly.
112 // crbug.com/668289
109 static void RunExternalProtocolDialog(const GURL& url, 113 static void RunExternalProtocolDialog(const GURL& url,
110 int render_process_host_id, 114 int render_process_host_id,
111 int routing_id, 115 int routing_id,
112 ui::PageTransition page_transition, 116 ui::PageTransition page_transition,
113 bool has_user_gesture); 117 bool has_user_gesture);
114 118
115 private: 119 private:
116 DISALLOW_COPY_AND_ASSIGN(ExternalProtocolHandler); 120 DISALLOW_COPY_AND_ASSIGN(ExternalProtocolHandler);
117 }; 121 };
118 122
119 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ 123 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_site_per_process_browsertest.cc ('k') | chrome/browser/external_protocol/external_protocol_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698