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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 844733003: Use VisibilityState enum and move WebPageVisibilityState to public/platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sw_enum_stuff
Patch Set: SWContainer uses pageVisibilityState Created 5 years, 11 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
« no previous file with comments | « Source/core/dom/Document.idl ('k') | Source/modules/serviceworkers/ServiceWorkerWindowClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/dom/ExecutionContext.h" 42 #include "core/dom/ExecutionContext.h"
43 #include "core/dom/MessagePort.h" 43 #include "core/dom/MessagePort.h"
44 #include "core/events/MessageEvent.h" 44 #include "core/events/MessageEvent.h"
45 #include "core/frame/LocalDOMWindow.h" 45 #include "core/frame/LocalDOMWindow.h"
46 #include "modules/EventTargetModules.h" 46 #include "modules/EventTargetModules.h"
47 #include "modules/serviceworkers/ServiceWorker.h" 47 #include "modules/serviceworkers/ServiceWorker.h"
48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
49 #include "modules/serviceworkers/ServiceWorkerError.h" 49 #include "modules/serviceworkers/ServiceWorkerError.h"
50 #include "modules/serviceworkers/ServiceWorkerRegistration.h" 50 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
51 #include "platform/RuntimeEnabledFeatures.h" 51 #include "platform/RuntimeEnabledFeatures.h"
52 #include "public/platform/WebPageVisibilityState.h"
52 #include "public/platform/WebServiceWorker.h" 53 #include "public/platform/WebServiceWorker.h"
53 #include "public/platform/WebServiceWorkerClientsInfo.h" 54 #include "public/platform/WebServiceWorkerClientsInfo.h"
54 #include "public/platform/WebServiceWorkerProvider.h" 55 #include "public/platform/WebServiceWorkerProvider.h"
55 #include "public/platform/WebServiceWorkerRegistration.h" 56 #include "public/platform/WebServiceWorkerRegistration.h"
56 #include "public/platform/WebString.h" 57 #include "public/platform/WebString.h"
57 #include "public/platform/WebURL.h" 58 #include "public/platform/WebURL.h"
58 59
59 namespace blink { 60 namespace blink {
60 61
61 // This wraps CallbackPromiseAdapter and resolves the promise with undefined 62 // This wraps CallbackPromiseAdapter and resolves the promise with undefined
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return EventTargetNames::ServiceWorkerContainer; 284 return EventTargetNames::ServiceWorkerContainer;
284 } 285 }
285 286
286 bool ServiceWorkerContainer::getClientInfo(WebServiceWorkerClientInfo* info) 287 bool ServiceWorkerContainer::getClientInfo(WebServiceWorkerClientInfo* info)
287 { 288 {
288 ExecutionContext* context = executionContext(); 289 ExecutionContext* context = executionContext();
289 // FIXME: Make this work for non-document context (e.g. shared workers). 290 // FIXME: Make this work for non-document context (e.g. shared workers).
290 if (!context || !context->isDocument()) 291 if (!context || !context->isDocument())
291 return false; 292 return false;
292 Document* document = toDocument(context); 293 Document* document = toDocument(context);
294 // FIXME: remove info->visibilityState when Chromium is updated.
293 info->visibilityState = document->visibilityState(); 295 info->visibilityState = document->visibilityState();
296 info->pageVisibilityState = static_cast<WebPageVisibilityState>(document->pa geVisibilityState());
294 info->isFocused = document->hasFocus(); 297 info->isFocused = document->hasFocus();
295 info->url = document->url(); 298 info->url = document->url();
296 if (!document->frame()) 299 if (!document->frame())
297 info->frameType = WebURLRequest::FrameTypeNone; 300 info->frameType = WebURLRequest::FrameTypeNone;
298 else if (document->frame()->isMainFrame()) 301 else if (document->frame()->isMainFrame())
299 info->frameType = WebURLRequest::FrameTypeTopLevel; 302 info->frameType = WebURLRequest::FrameTypeTopLevel;
300 else 303 else
301 info->frameType = WebURLRequest::FrameTypeNested; 304 info->frameType = WebURLRequest::FrameTypeNested;
302 return true; 305 return true;
303 } 306 }
304 307
305 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) 308 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t)
306 : ContextLifecycleObserver(executionContext) 309 : ContextLifecycleObserver(executionContext)
307 , m_provider(0) 310 , m_provider(0)
308 { 311 {
309 312
310 if (!executionContext) 313 if (!executionContext)
311 return; 314 return;
312 315
313 m_ready = createReadyProperty(); 316 m_ready = createReadyProperty();
314 317
315 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 318 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
316 m_provider = client->provider(); 319 m_provider = client->provider();
317 if (m_provider) 320 if (m_provider)
318 m_provider->setClient(this); 321 m_provider->setClient(this);
319 } 322 }
320 } 323 }
321 324
322 } // namespace blink 325 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Document.idl ('k') | Source/modules/serviceworkers/ServiceWorkerWindowClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698