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

Side by Side Diff: content/browser/service_worker/service_worker_client_utils.cc

Issue 2893823004: [Payments] Implement openWindow for service worker based payment handler (Closed)
Patch Set: rename ipc messages Created 3 years, 6 months 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/service_worker/service_worker_client_utils.h" 5 #include "content/browser/service_worker/service_worker_client_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 static_cast<RenderFrameHostImpl*>(web_contents->GetMainFrame()); 173 static_cast<RenderFrameHostImpl*>(web_contents->GetMainFrame());
174 new OpenURLObserver(web_contents, 174 new OpenURLObserver(web_contents,
175 rfhi->frame_tree_node()->frame_tree_node_id(), callback); 175 rfhi->frame_tree_node()->frame_tree_node_id(), callback);
176 } 176 }
177 177
178 void OpenWindowOnUI( 178 void OpenWindowOnUI(
179 const GURL& url, 179 const GURL& url,
180 const GURL& script_url, 180 const GURL& script_url,
181 int worker_process_id, 181 int worker_process_id,
182 const scoped_refptr<ServiceWorkerContextWrapper>& context_wrapper, 182 const scoped_refptr<ServiceWorkerContextWrapper>& context_wrapper,
183 WindowOpenDisposition disposition,
183 const OpenURLCallback& callback) { 184 const OpenURLCallback& callback) {
184 DCHECK_CURRENTLY_ON(BrowserThread::UI); 185 DCHECK_CURRENTLY_ON(BrowserThread::UI);
185 186
186 BrowserContext* browser_context = 187 BrowserContext* browser_context =
187 context_wrapper->storage_partition() 188 context_wrapper->storage_partition()
188 ? context_wrapper->storage_partition()->browser_context() 189 ? context_wrapper->storage_partition()->browser_context()
189 : nullptr; 190 : nullptr;
190 // We are shutting down. 191 // We are shutting down.
191 if (!browser_context) 192 if (!browser_context)
192 return; 193 return;
193 194
194 RenderProcessHost* render_process_host = 195 RenderProcessHost* render_process_host =
195 RenderProcessHost::FromID(worker_process_id); 196 RenderProcessHost::FromID(worker_process_id);
196 if (render_process_host->IsForGuestsOnly()) { 197 if (render_process_host->IsForGuestsOnly()) {
197 BrowserThread::PostTask( 198 BrowserThread::PostTask(
198 BrowserThread::IO, FROM_HERE, 199 BrowserThread::IO, FROM_HERE,
199 base::Bind(callback, ChildProcessHost::kInvalidUniqueID, 200 base::Bind(callback, ChildProcessHost::kInvalidUniqueID,
200 MSG_ROUTING_NONE)); 201 MSG_ROUTING_NONE));
201 return; 202 return;
202 } 203 }
203 204
204 OpenURLParams params( 205 OpenURLParams params(
205 url, 206 url,
206 Referrer::SanitizeForRequest( 207 Referrer::SanitizeForRequest(
207 url, Referrer(script_url, blink::kWebReferrerPolicyDefault)), 208 url, Referrer(script_url, blink::kWebReferrerPolicyDefault)),
208 WindowOpenDisposition::NEW_FOREGROUND_TAB, 209 disposition, ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
209 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, true /* is_renderer_initiated */); 210 true /* is_renderer_initiated */);
210 211
211 GetContentClient()->browser()->OpenURL(browser_context, params, 212 GetContentClient()->browser()->OpenURL(browser_context, params,
212 base::Bind(&DidOpenURLOnUI, callback)); 213 base::Bind(&DidOpenURLOnUI, callback));
213 } 214 }
214 215
215 void NavigateClientOnUI(const GURL& url, 216 void NavigateClientOnUI(const GURL& url,
216 const GURL& script_url, 217 const GURL& script_url,
217 int process_id, 218 int process_id,
218 int frame_id, 219 int frame_id,
219 const OpenURLCallback& callback) { 220 const OpenURLCallback& callback) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 BrowserThread::UI, FROM_HERE, 432 BrowserThread::UI, FROM_HERE,
432 base::Bind(&FocusOnUI, provider_host->process_id(), 433 base::Bind(&FocusOnUI, provider_host->process_id(),
433 provider_host->frame_id(), provider_host->client_uuid()), 434 provider_host->frame_id(), provider_host->client_uuid()),
434 callback); 435 callback);
435 } 436 }
436 437
437 void OpenWindow(const GURL& url, 438 void OpenWindow(const GURL& url,
438 const GURL& script_url, 439 const GURL& script_url,
439 int worker_process_id, 440 int worker_process_id,
440 const base::WeakPtr<ServiceWorkerContextCore>& context, 441 const base::WeakPtr<ServiceWorkerContextCore>& context,
442 WindowOpenDisposition disposition,
441 const NavigationCallback& callback) { 443 const NavigationCallback& callback) {
442 DCHECK_CURRENTLY_ON(BrowserThread::IO); 444 DCHECK_CURRENTLY_ON(BrowserThread::IO);
443 BrowserThread::PostTask( 445 BrowserThread::PostTask(
444 BrowserThread::UI, FROM_HERE, 446 BrowserThread::UI, FROM_HERE,
445 base::Bind( 447 base::Bind(
446 &OpenWindowOnUI, url, script_url, worker_process_id, 448 &OpenWindowOnUI, url, script_url, worker_process_id,
447 make_scoped_refptr(context->wrapper()), 449 make_scoped_refptr(context->wrapper()), disposition,
448 base::Bind(&DidNavigate, context, script_url.GetOrigin(), callback))); 450 base::Bind(&DidNavigate, context, script_url.GetOrigin(), callback)));
449 } 451 }
450 452
451 void NavigateClient(const GURL& url, 453 void NavigateClient(const GURL& url,
452 const GURL& script_url, 454 const GURL& script_url,
453 int process_id, 455 int process_id,
454 int frame_id, 456 int frame_id,
455 const base::WeakPtr<ServiceWorkerContextCore>& context, 457 const base::WeakPtr<ServiceWorkerContextCore>& context,
456 const NavigationCallback& callback) { 458 const NavigationCallback& callback) {
457 DCHECK_CURRENTLY_ON(BrowserThread::IO); 459 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 GetWindowClients(controller, options, callback); 509 GetWindowClients(controller, options, callback);
508 return; 510 return;
509 } 511 }
510 512
511 GetNonWindowClients(controller, options, &clients); 513 GetNonWindowClients(controller, options, &clients);
512 DidGetClients(callback, &clients); 514 DidGetClients(callback, &clients);
513 } 515 }
514 516
515 } // namespace service_worker_client_utils 517 } // namespace service_worker_client_utils
516 } // namespace content 518 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698