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

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

Issue 2538353002: fix external protocol handling for OOPIFs (Closed)
Patch Set: rebase 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
15
alexmos 2016/12/01 19:21:14 nit: no blank line
davidsac (gone - try alexmos) 2016/12/12 19:15:47 Done.
14 class GURL; 16 class GURL;
15 class PrefRegistrySimple; 17 class PrefRegistrySimple;
16 18
17 namespace base { 19 namespace base {
18 class DictionaryValue; 20 class DictionaryValue;
19 } 21 }
20 22
21 class ExternalProtocolHandler { 23 class ExternalProtocolHandler {
22 public: 24 public:
23 enum BlockState { 25 enum BlockState {
(...skipping 10 matching lines...) Expand all
34 const shell_integration::DefaultWebClientWorkerCallback& callback, 36 const shell_integration::DefaultWebClientWorkerCallback& callback,
35 const std::string& protocol) = 0; 37 const std::string& protocol) = 0;
36 virtual BlockState GetBlockState(const std::string& scheme) = 0; 38 virtual BlockState GetBlockState(const std::string& scheme) = 0;
37 virtual void BlockRequest() = 0; 39 virtual void BlockRequest() = 0;
38 virtual void RunExternalProtocolDialog( 40 virtual void RunExternalProtocolDialog(
39 const GURL& url, 41 const GURL& url,
40 int render_process_host_id, 42 int render_process_host_id,
41 int routing_id, 43 int routing_id,
42 ui::PageTransition page_transition, 44 ui::PageTransition page_transition,
43 bool has_user_gesture) = 0; 45 bool has_user_gesture) = 0;
44 virtual void LaunchUrlWithoutSecurityCheck(const GURL& url) = 0; 46 virtual void LaunchUrlWithoutSecurityCheck(
47 const GURL& url,
48 content::WebContents* web_contents) = 0;
45 virtual void FinishedProcessingCheck() = 0; 49 virtual void FinishedProcessingCheck() = 0;
46 virtual ~Delegate() {} 50 virtual ~Delegate() {}
47 }; 51 };
48 52
49 // Returns whether we should block a given scheme. 53 // Returns whether we should block a given scheme.
50 static BlockState GetBlockState(const std::string& scheme); 54 static BlockState GetBlockState(const std::string& scheme);
51 55
52 // Sets whether we should block a given scheme. 56 // Sets whether we should block a given scheme.
53 static void SetBlockState(const std::string& scheme, BlockState state); 57 static void SetBlockState(const std::string& scheme, BlockState state);
54 58
55 // Checks to see if the protocol is allowed, if it is whitelisted, 59 // Checks to see if the protocol is allowed, if it is whitelisted,
56 // the application associated with the protocol is launched on the io thread, 60 // the application associated with the protocol is launched on the io thread,
57 // if it is blacklisted, returns silently. Otherwise, an 61 // if it is blacklisted, returns silently. Otherwise, an
58 // ExternalProtocolDialog is created asking the user. If the user accepts, 62 // ExternalProtocolDialog is created asking the user. If the user accepts,
59 // LaunchUrlWithoutSecurityCheck is called on the io thread and the 63 // LaunchUrlWithoutSecurityCheck is called on the io thread and the
60 // application is launched. 64 // application is launched.
61 // Must run on the UI thread. 65 // Must run on the UI thread.
62 // Allowing use of a delegate to facilitate unit testing. 66 // Allowing use of a delegate to facilitate unit testing.
63 static void LaunchUrlWithDelegate(const GURL& url, 67 static void LaunchUrlWithDelegate(const GURL& url,
64 int render_process_host_id, 68 int render_process_host_id,
65 int tab_contents_id, 69 int tab_contents_id,
66 ui::PageTransition page_transition, 70 ui::PageTransition page_transition,
67 bool has_user_gesture, 71 bool has_user_gesture,
68 Delegate* delegate); 72 Delegate* delegate);
69 73
70 // Starts a url using the external protocol handler with the help 74 // Starts a url using the external protocol handler with the help
71 // of shellexecute. Should only be called if the protocol is whitelisted 75 // of shellexecute. Should only be called if the protocol is whitelisted
72 // (checked in LaunchUrl) or if the user explicitly allows it. (By selecting 76 // (checked in LaunchUrl) or if the user explicitly allows it. (By selecting
73 // "Launch Application" in an ExternalProtocolDialog.) It is assumed that the 77 // "Launch Application" in an ExternalProtocolDialog.) It is assumed that the
alexmos 2016/12/01 19:21:14 Side note: it would probably be good to (manually)
davidsac (gone - try alexmos) 2016/12/12 19:15:47 Done.
74 // url has already been escaped, which happens in LaunchUrl. 78 // url has already been escaped, which happens in LaunchUrl.
75 // NOTE: You should Not call this function directly unless you are sure the 79 // 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. 80 // 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. 81 // All calls to this function should originate in some way from LaunchUrl.
78 static void LaunchUrlWithoutSecurityCheck(const GURL& url, 82 static void LaunchUrlWithoutSecurityCheck(const GURL& url,
79 int render_process_host_id, 83 content::WebContents* web_contents);
80 int tab_contents_id);
81 84
82 // Allows LaunchUrl to proceed with launching an external protocol handler. 85 // Allows LaunchUrl to proceed with launching an external protocol handler.
83 // This is typically triggered by a user gesture, but is also called for 86 // 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 87 // each extension API function. Note that each call to LaunchUrl resets
85 // the state to false (not allowed). 88 // the state to false (not allowed).
86 static void PermitLaunchUrl(); 89 static void PermitLaunchUrl();
87 90
88 // Prepopulates the dictionary with known protocols to deny or allow, if 91 // Prepopulates the dictionary with known protocols to deny or allow, if
89 // preferences for them do not already exist. 92 // preferences for them do not already exist.
90 static void PrepopulateDictionary(base::DictionaryValue* win_pref); 93 static void PrepopulateDictionary(base::DictionaryValue* win_pref);
(...skipping 19 matching lines...) Expand all
110 int render_process_host_id, 113 int render_process_host_id,
111 int routing_id, 114 int routing_id,
112 ui::PageTransition page_transition, 115 ui::PageTransition page_transition,
113 bool has_user_gesture); 116 bool has_user_gesture);
114 117
115 private: 118 private:
116 DISALLOW_COPY_AND_ASSIGN(ExternalProtocolHandler); 119 DISALLOW_COPY_AND_ASSIGN(ExternalProtocolHandler);
117 }; 120 };
118 121
119 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ 122 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698