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

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

Issue 1202453002: ServiceWorker: Implement navigate() method in WindowClient (chromium side). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_provider_host.h" 5 #include "content/browser/service_worker/service_worker_provider_host.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/frame_host/frame_tree_node.h" 10 #include "content/browser/frame_host/frame_tree_node.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // Focus the frame's view to make sure the frame is now considered as focused. 49 // Focus the frame's view to make sure the frame is now considered as focused.
50 render_frame_host->GetView()->Focus(); 50 render_frame_host->GetView()->Focus();
51 51
52 // Move the web contents to the foreground. 52 // Move the web contents to the foreground.
53 web_contents->Activate(); 53 web_contents->Activate();
54 54
55 return ServiceWorkerProviderHost::GetWindowClientInfoOnUI(render_process_id, 55 return ServiceWorkerProviderHost::GetWindowClientInfoOnUI(render_process_id,
56 render_frame_id); 56 render_frame_id);
57 } 57 }
58 58
59 ServiceWorkerClientInfo NavigateOnUIThread(const GURL& url,
60 int render_process_id,
61 int render_frame_id) {
62 RenderFrameHostImpl* render_frame_host =
63 RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
64
65 if (!render_frame_host)
66 return ServiceWorkerClientInfo();
67
68 render_frame_host->NavigateToURL(url);
69
70 return ServiceWorkerProviderHost::GetWindowClientInfoOnUI(render_process_id,
71 render_frame_id);
72 }
73
59 } // anonymous namespace 74 } // anonymous namespace
60 75
61 ServiceWorkerProviderHost::OneShotGetReadyCallback::OneShotGetReadyCallback( 76 ServiceWorkerProviderHost::OneShotGetReadyCallback::OneShotGetReadyCallback(
62 const GetRegistrationForReadyCallback& callback) 77 const GetRegistrationForReadyCallback& callback)
63 : callback(callback), 78 : callback(callback),
64 called(false) { 79 called(false) {
65 } 80 }
66 81
67 ServiceWorkerProviderHost::OneShotGetReadyCallback::~OneShotGetReadyCallback() { 82 ServiceWorkerProviderHost::OneShotGetReadyCallback::~OneShotGetReadyCallback() {
68 } 83 }
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 void ServiceWorkerProviderHost::Focus(const GetClientInfoCallback& callback) { 408 void ServiceWorkerProviderHost::Focus(const GetClientInfoCallback& callback) {
394 if (provider_type_ != SERVICE_WORKER_PROVIDER_FOR_WINDOW) { 409 if (provider_type_ != SERVICE_WORKER_PROVIDER_FOR_WINDOW) {
395 callback.Run(ServiceWorkerClientInfo()); 410 callback.Run(ServiceWorkerClientInfo());
396 return; 411 return;
397 } 412 }
398 BrowserThread::PostTaskAndReplyWithResult( 413 BrowserThread::PostTaskAndReplyWithResult(
399 BrowserThread::UI, FROM_HERE, 414 BrowserThread::UI, FROM_HERE,
400 base::Bind(&FocusOnUIThread, render_process_id_, route_id_), callback); 415 base::Bind(&FocusOnUIThread, render_process_id_, route_id_), callback);
401 } 416 }
402 417
418 void ServiceWorkerProviderHost::Navigate(
419 const GURL& url,
420 const GetClientInfoCallback& callback) {
421 if (provider_type_ != SERVICE_WORKER_PROVIDER_FOR_WINDOW) {
422 callback.Run(ServiceWorkerClientInfo());
423 return;
424 }
425 BrowserThread::PostTaskAndReplyWithResult(
426 BrowserThread::UI, FROM_HERE,
427 base::Bind(&NavigateOnUIThread, url, render_process_id_, route_id_),
428 callback);
429 }
430
403 void ServiceWorkerProviderHost::GetWindowClientInfo( 431 void ServiceWorkerProviderHost::GetWindowClientInfo(
404 const GetClientInfoCallback& callback) const { 432 const GetClientInfoCallback& callback) const {
405 if (provider_type_ != SERVICE_WORKER_PROVIDER_FOR_WINDOW) { 433 if (provider_type_ != SERVICE_WORKER_PROVIDER_FOR_WINDOW) {
406 callback.Run(ServiceWorkerClientInfo()); 434 callback.Run(ServiceWorkerClientInfo());
407 return; 435 return;
408 } 436 }
409 BrowserThread::PostTaskAndReplyWithResult( 437 BrowserThread::PostTaskAndReplyWithResult(
410 BrowserThread::UI, FROM_HERE, 438 BrowserThread::UI, FROM_HERE,
411 base::Bind(&ServiceWorkerProviderHost::GetWindowClientInfoOnUI, 439 base::Bind(&ServiceWorkerProviderHost::GetWindowClientInfoOnUI,
412 render_process_id_, route_id_), 440 render_process_id_, route_id_),
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 return context_ != NULL; 688 return context_ != NULL;
661 } 689 }
662 690
663 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { 691 void ServiceWorkerProviderHost::Send(IPC::Message* message) const {
664 DCHECK(dispatcher_host_); 692 DCHECK(dispatcher_host_);
665 DCHECK(IsReadyToSendMessages()); 693 DCHECK(IsReadyToSendMessages());
666 dispatcher_host_->Send(message); 694 dispatcher_host_->Send(message);
667 } 695 }
668 696
669 } // namespace content 697 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698