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

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

Issue 2591143002: Rename |tab_contents_id| to |render_view_routing_id|. (Closed)
Patch Set: 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/external_protocol/external_protocol_handler.h" 5 #include "chrome/browser/external_protocol/external_protocol_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } else { 73 } else {
74 delegate->RunExternalProtocolDialog( 74 delegate->RunExternalProtocolDialog(
75 url, render_process_host_id, routing_id, page_transition, 75 url, render_process_host_id, routing_id, page_transition,
76 has_user_gesture); 76 has_user_gesture);
77 } 77 }
78 } 78 }
79 79
80 void LaunchUrlWithoutSecurityCheckWithDelegate( 80 void LaunchUrlWithoutSecurityCheckWithDelegate(
81 const GURL& url, 81 const GURL& url,
82 int render_process_host_id, 82 int render_process_host_id,
83 int tab_contents_id, 83 int render_view_routing_id,
84 ExternalProtocolHandler::Delegate* delegate) { 84 ExternalProtocolHandler::Delegate* delegate) {
85 content::WebContents* web_contents = 85 content::WebContents* web_contents = tab_util::GetWebContentsByID(
86 tab_util::GetWebContentsByID(render_process_host_id, tab_contents_id); 86 render_process_host_id, render_view_routing_id);
87 87
88 if (!delegate) { 88 if (!delegate) {
89 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents); 89 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents);
90 } else { 90 } else {
91 delegate->LaunchUrlWithoutSecurityCheck(url, web_contents); 91 delegate->LaunchUrlWithoutSecurityCheck(url, web_contents);
92 } 92 }
93 } 93 }
94 94
95 // When we are about to launch a URL with the default OS level application, we 95 // When we are about to launch a URL with the default OS level application, we
96 // check if the external application will be us. If it is we just ignore the 96 // check if the external application will be us. If it is we just ignore the
97 // request. 97 // request.
98 void OnDefaultProtocolClientWorkerFinished( 98 void OnDefaultProtocolClientWorkerFinished(
99 const GURL& escaped_url, 99 const GURL& escaped_url,
100 int render_process_host_id, 100 int render_process_host_id,
101 int tab_contents_id, 101 int render_view_routing_id,
102 bool prompt_user, 102 bool prompt_user,
103 ui::PageTransition page_transition, 103 ui::PageTransition page_transition,
104 bool has_user_gesture, 104 bool has_user_gesture,
105 ExternalProtocolHandler::Delegate* delegate, 105 ExternalProtocolHandler::Delegate* delegate,
106 shell_integration::DefaultWebClientState state) { 106 shell_integration::DefaultWebClientState state) {
107 DCHECK_CURRENTLY_ON(BrowserThread::UI); 107 DCHECK_CURRENTLY_ON(BrowserThread::UI);
108 108
109 if (delegate) 109 if (delegate)
110 delegate->FinishedProcessingCheck(); 110 delegate->FinishedProcessingCheck();
111 111
112 if (state == shell_integration::IS_DEFAULT) { 112 if (state == shell_integration::IS_DEFAULT) {
113 if (delegate) 113 if (delegate)
114 delegate->BlockRequest(); 114 delegate->BlockRequest();
115 return; 115 return;
116 } 116 }
117 117
118 // If we get here, either we are not the default or we cannot work out 118 // If we get here, either we are not the default or we cannot work out
119 // what the default is, so we proceed. 119 // what the default is, so we proceed.
120 if (prompt_user) { 120 if (prompt_user) {
121 // Ask the user if they want to allow the protocol. This will call 121 // Ask the user if they want to allow the protocol. This will call
122 // LaunchUrlWithoutSecurityCheck if the user decides to accept the 122 // LaunchUrlWithoutSecurityCheck if the user decides to accept the
123 // protocol. 123 // protocol.
124 RunExternalProtocolDialogWithDelegate(escaped_url, render_process_host_id, 124 RunExternalProtocolDialogWithDelegate(
125 tab_contents_id, page_transition, 125 escaped_url, render_process_host_id, render_view_routing_id,
126 has_user_gesture, delegate); 126 page_transition, has_user_gesture, delegate);
127 return; 127 return;
128 } 128 }
129 129
130 LaunchUrlWithoutSecurityCheckWithDelegate(escaped_url, render_process_host_id, 130 LaunchUrlWithoutSecurityCheckWithDelegate(escaped_url, render_process_host_id,
131 tab_contents_id, delegate); 131 render_view_routing_id, delegate);
132 } 132 }
133 133
134 } // namespace 134 } // namespace
135 135
136 // static 136 // static
137 ExternalProtocolHandler::BlockState ExternalProtocolHandler::GetBlockState( 137 ExternalProtocolHandler::BlockState ExternalProtocolHandler::GetBlockState(
138 const std::string& scheme) { 138 const std::string& scheme) {
139 // If we are being carpet bombed, block the request. 139 // If we are being carpet bombed, block the request.
140 if (!g_accept_requests) 140 if (!g_accept_requests)
141 return BLOCK; 141 return BLOCK;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } else { 180 } else {
181 update_excluded_schemas->SetBoolean(scheme, (state == BLOCK)); 181 update_excluded_schemas->SetBoolean(scheme, (state == BLOCK));
182 } 182 }
183 } 183 }
184 } 184 }
185 185
186 // static 186 // static
187 void ExternalProtocolHandler::LaunchUrlWithDelegate( 187 void ExternalProtocolHandler::LaunchUrlWithDelegate(
188 const GURL& url, 188 const GURL& url,
189 int render_process_host_id, 189 int render_process_host_id,
190 int tab_contents_id, 190 int render_view_routing_id,
191 ui::PageTransition page_transition, 191 ui::PageTransition page_transition,
192 bool has_user_gesture, 192 bool has_user_gesture,
193 Delegate* delegate) { 193 Delegate* delegate) {
194 DCHECK(base::MessageLoopForUI::IsCurrent()); 194 DCHECK(base::MessageLoopForUI::IsCurrent());
195 195
196 // Escape the input scheme to be sure that the command does not 196 // Escape the input scheme to be sure that the command does not
197 // have parameters unexpected by the external program. 197 // have parameters unexpected by the external program.
198 std::string escaped_url_string = net::EscapeExternalHandlerValue(url.spec()); 198 std::string escaped_url_string = net::EscapeExternalHandlerValue(url.spec());
199 GURL escaped_url(escaped_url_string); 199 GURL escaped_url(escaped_url_string);
200 BlockState block_state = 200 BlockState block_state =
201 GetBlockStateWithDelegate(escaped_url.scheme(), delegate); 201 GetBlockStateWithDelegate(escaped_url.scheme(), delegate);
202 if (block_state == BLOCK) { 202 if (block_state == BLOCK) {
203 if (delegate) 203 if (delegate)
204 delegate->BlockRequest(); 204 delegate->BlockRequest();
205 return; 205 return;
206 } 206 }
207 207
208 g_accept_requests = false; 208 g_accept_requests = false;
209 209
210 // The worker creates tasks with references to itself and puts them into 210 // The worker creates tasks with references to itself and puts them into
211 // message loops. 211 // message loops.
212 shell_integration::DefaultWebClientWorkerCallback callback = base::Bind( 212 shell_integration::DefaultWebClientWorkerCallback callback = base::Bind(
213 &OnDefaultProtocolClientWorkerFinished, url, render_process_host_id, 213 &OnDefaultProtocolClientWorkerFinished, url, render_process_host_id,
214 tab_contents_id, block_state == UNKNOWN, page_transition, 214 render_view_routing_id, block_state == UNKNOWN, page_transition,
215 has_user_gesture, delegate); 215 has_user_gesture, delegate);
216 216
217 // Start the check process running. This will send tasks to the FILE thread 217 // Start the check process running. This will send tasks to the FILE thread
218 // and when the answer is known will send the result back to 218 // and when the answer is known will send the result back to
219 // OnDefaultProtocolClientWorkerFinished(). 219 // OnDefaultProtocolClientWorkerFinished().
220 CreateShellWorker(callback, escaped_url.scheme(), delegate) 220 CreateShellWorker(callback, escaped_url.scheme(), delegate)
221 ->StartCheckIsDefault(); 221 ->StartCheckIsDefault();
222 } 222 }
223 223
224 // static 224 // static
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // static 294 // static
295 void ExternalProtocolHandler::RecordMetrics(bool selected) { 295 void ExternalProtocolHandler::RecordMetrics(bool selected) {
296 UMA_HISTOGRAM_BOOLEAN("BrowserDialogs.ExternalProtocol.RememberCheckbox", 296 UMA_HISTOGRAM_BOOLEAN("BrowserDialogs.ExternalProtocol.RememberCheckbox",
297 selected); 297 selected);
298 } 298 }
299 299
300 // static 300 // static
301 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) { 301 void ExternalProtocolHandler::RegisterPrefs(PrefRegistrySimple* registry) {
302 registry->RegisterDictionaryPref(prefs::kExcludedSchemes); 302 registry->RegisterDictionaryPref(prefs::kExcludedSchemes);
303 } 303 }
OLDNEW
« no previous file with comments | « chrome/browser/external_protocol/external_protocol_handler.h ('k') | chrome/browser/ui/external_protocol_dialog_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698