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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 553603002: [ServiceWorker] Introduce isControlledByServiceWorker() in content::RenderFrameImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: isControlledByServiceWorker Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index e2b1bfa076d3d9247d9bfe495a6b6e8d1841e7cb..ec4e5270b680694b30af00ec2c0a627798f228f1 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -24,6 +24,7 @@
#include "content/child/quota_dispatcher.h"
#include "content/child/request_extra_data.h"
#include "content/child/service_worker/service_worker_network_provider.h"
+#include "content/child/service_worker/service_worker_provider_context.h"
#include "content/child/service_worker/web_service_worker_provider_impl.h"
#include "content/child/web_socket_stream_handle_impl.h"
#include "content/child/web_url_request_util.h"
@@ -3188,6 +3189,22 @@ blink::WebScreenOrientationClient*
return screen_orientation_dispatcher_;
}
+bool RenderFrameImpl::isControlledByServiceWorker() {
+ // If we're in the middle of committing a load, the data source we need
+ // will still be provisional.
+ WebFrame* main_frame = render_view_->webview()->mainFrame();
+ WebDataSource* data_source = NULL;
+ if (main_frame->provisionalDataSource())
+ data_source = main_frame->provisionalDataSource();
+ else
+ data_source = main_frame->dataSource();
+ ServiceWorkerNetworkProvider* provider =
+ ServiceWorkerNetworkProvider::FromDocumentState(
+ DocumentState::FromDataSource(data_source));
+ return provider->context()->controller_handle_id() !=
+ kInvalidServiceWorkerHandleId;
+}
+
void RenderFrameImpl::DidPlay(blink::WebMediaPlayer* player) {
Send(new FrameHostMsg_MediaPlayingNotification(
routing_id_, reinterpret_cast<int64>(player), player->hasVideo(),
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698