OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/common/service_worker/service_worker_client_info.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "content/common/service_worker/service_worker_types.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 ServiceWorkerClientInfo::ServiceWorkerClientInfo() |
| 13 : client_id(kInvalidServiceWorkerClientId), |
| 14 page_visibility_state(blink::WebPageVisibilityStateLast), |
| 15 is_focused(false), |
| 16 frame_type(REQUEST_CONTEXT_FRAME_TYPE_LAST) { |
| 17 } |
| 18 |
| 19 ServiceWorkerClientInfo::ServiceWorkerClientInfo( |
| 20 blink::WebPageVisibilityState page_visibility_state, |
| 21 bool is_focused, |
| 22 const GURL& url, |
| 23 RequestContextFrameType frame_type) |
| 24 : client_id(kInvalidServiceWorkerClientId), |
| 25 page_visibility_state(page_visibility_state), |
| 26 is_focused(is_focused), |
| 27 url(url), |
| 28 frame_type(frame_type) { |
| 29 } |
| 30 |
| 31 bool ServiceWorkerClientInfo::IsEmpty() const { |
| 32 return page_visibility_state == blink::WebPageVisibilityStateLast && |
| 33 is_focused == false && |
| 34 url.is_empty() && |
| 35 frame_type == REQUEST_CONTEXT_FRAME_TYPE_LAST; |
| 36 } |
| 37 |
| 38 bool ServiceWorkerClientInfo::IsValid() const { |
| 39 return !IsEmpty() && client_id != kInvalidServiceWorkerClientId; |
| 40 } |
| 41 |
| 42 ServiceWorkerClientInfo::operator blink::WebServiceWorkerClientInfo() const { |
| 43 DCHECK(IsValid()); |
| 44 |
| 45 blink::WebServiceWorkerClientInfo web_client_info; |
| 46 |
| 47 web_client_info.clientID = client_id; |
| 48 web_client_info.pageVisibilityState = page_visibility_state; |
| 49 web_client_info.isFocused = is_focused; |
| 50 web_client_info.url = url; |
| 51 web_client_info.frameType = |
| 52 static_cast<blink::WebURLRequest::FrameType>(frame_type); |
| 53 |
| 54 return web_client_info; |
| 55 } |
| 56 |
| 57 } // namespace content |
OLD | NEW |