 Chromium Code Reviews
 Chromium Code Reviews Issue 2009453002:
  service worker: Don't control a subframe of an insecure context  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 2009453002:
  service worker: Don't control a subframe of an insecure context  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 
| 7 | 7 | 
| 8 #include <stddef.h> | 8 #include <stddef.h> | 
| 9 #include <stdint.h> | 9 #include <stdint.h> | 
| 10 | 10 | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 // MSG_ROUTING_NONE. When this provider host is for a Document, | 65 // MSG_ROUTING_NONE. When this provider host is for a Document, | 
| 66 // |route_id| is the frame ID of the Document. When this provider host is for | 66 // |route_id| is the frame ID of the Document. When this provider host is for | 
| 67 // a Shared Worker, |route_id| is the Shared Worker route ID. | 67 // a Shared Worker, |route_id| is the Shared Worker route ID. | 
| 68 // |provider_type| gives additional information whether the provider is | 68 // |provider_type| gives additional information whether the provider is | 
| 69 // created for controller (ServiceWorker) or controllee (Document or | 69 // created for controller (ServiceWorker) or controllee (Document or | 
| 70 // SharedWorker). | 70 // SharedWorker). | 
| 71 ServiceWorkerProviderHost(int render_process_id, | 71 ServiceWorkerProviderHost(int render_process_id, | 
| 72 int route_id, | 72 int route_id, | 
| 73 int provider_id, | 73 int provider_id, | 
| 74 ServiceWorkerProviderType provider_type, | 74 ServiceWorkerProviderType provider_type, | 
| 75 bool is_parent_frame_secure, | |
| 75 base::WeakPtr<ServiceWorkerContextCore> context, | 76 base::WeakPtr<ServiceWorkerContextCore> context, | 
| 76 ServiceWorkerDispatcherHost* dispatcher_host); | 77 ServiceWorkerDispatcherHost* dispatcher_host); | 
| 77 virtual ~ServiceWorkerProviderHost(); | 78 virtual ~ServiceWorkerProviderHost(); | 
| 78 | 79 | 
| 79 const std::string& client_uuid() const { return client_uuid_; } | 80 const std::string& client_uuid() const { return client_uuid_; } | 
| 80 int process_id() const { return render_process_id_; } | 81 int process_id() const { return render_process_id_; } | 
| 81 int provider_id() const { return provider_id_; } | 82 int provider_id() const { return provider_id_; } | 
| 82 int frame_id() const; | 83 int frame_id() const; | 
| 83 int route_id() const { return route_id_; } | 84 int route_id() const { return route_id_; } | 
| 84 | 85 | 
| 86 bool is_parent_frame_secure() const { return is_parent_frame_secure_; } | |
| 87 void set_parent_frame_secure(bool is_parent_frame_secure) { | |
| 88 is_parent_frame_secure_ = is_parent_frame_secure; | |
| 
horo
2016/06/03 09:54:45
Please add DCHECK() to ensure that set_parent_fram
 
falken
2016/06/03 12:10:45
Done. I ended up making the bool an enum, which is
 | |
| 89 } | |
| 90 | |
| 91 // Returns whether this provider host is secure enough to have a service | |
| 92 // worker controller. | |
| 93 // Analogous to Blink's Document::isSecureContext. Because of how service | |
| 94 // worker intercepts main resource requests, this check must be done | |
| 95 // browser-side once the URL is known (see comments in | |
| 96 // ServiceWorkerNetworkProvider::CreateForNavigation). This function uses | |
| 97 // |document_url_| and |is_parent_frame_secure_| to determine context | |
| 98 // security, so they must be set properly before calling this function. | |
| 99 bool IsContextSecureForServiceWorker() const; | |
| 100 | |
| 85 bool IsHostToRunningServiceWorker() { | 101 bool IsHostToRunningServiceWorker() { | 
| 86 return running_hosted_version_.get() != NULL; | 102 return running_hosted_version_.get() != NULL; | 
| 87 } | 103 } | 
| 88 | 104 | 
| 89 ServiceWorkerVersion* controlling_version() const { | 105 ServiceWorkerVersion* controlling_version() const { | 
| 90 return controlling_version_.get(); | 106 return controlling_version_.get(); | 
| 91 } | 107 } | 
| 92 ServiceWorkerVersion* active_version() const { | 108 ServiceWorkerVersion* active_version() const { | 
| 93 return associated_registration_.get() ? | 109 return associated_registration_.get() ? | 
| 94 associated_registration_->active_version() : NULL; | 110 associated_registration_->active_version() : NULL; | 
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 void FinalizeInitialization(int process_id, | 316 void FinalizeInitialization(int process_id, | 
| 301 int frame_routing_id, | 317 int frame_routing_id, | 
| 302 ServiceWorkerDispatcherHost* dispatcher_host); | 318 ServiceWorkerDispatcherHost* dispatcher_host); | 
| 303 | 319 | 
| 304 std::string client_uuid_; | 320 std::string client_uuid_; | 
| 305 int render_process_id_; | 321 int render_process_id_; | 
| 306 int route_id_; | 322 int route_id_; | 
| 307 int render_thread_id_; | 323 int render_thread_id_; | 
| 308 int provider_id_; | 324 int provider_id_; | 
| 309 ServiceWorkerProviderType provider_type_; | 325 ServiceWorkerProviderType provider_type_; | 
| 326 bool is_parent_frame_secure_; | |
| 310 GURL document_url_; | 327 GURL document_url_; | 
| 311 GURL topmost_frame_url_; | 328 GURL topmost_frame_url_; | 
| 312 | 329 | 
| 313 std::vector<GURL> associated_patterns_; | 330 std::vector<GURL> associated_patterns_; | 
| 314 scoped_refptr<ServiceWorkerRegistration> associated_registration_; | 331 scoped_refptr<ServiceWorkerRegistration> associated_registration_; | 
| 315 | 332 | 
| 316 // Keyed by registration scope URL length. | 333 // Keyed by registration scope URL length. | 
| 317 typedef std::map<size_t, scoped_refptr<ServiceWorkerRegistration>> | 334 typedef std::map<size_t, scoped_refptr<ServiceWorkerRegistration>> | 
| 318 ServiceWorkerRegistrationMap; | 335 ServiceWorkerRegistrationMap; | 
| 319 // Contains all living registrations which has pattern this document's | 336 // Contains all living registrations which has pattern this document's | 
| 320 // URL starts with. | 337 // URL starts with. | 
| 321 ServiceWorkerRegistrationMap matching_registrations_; | 338 ServiceWorkerRegistrationMap matching_registrations_; | 
| 322 | 339 | 
| 323 std::unique_ptr<OneShotGetReadyCallback> get_ready_callback_; | 340 std::unique_ptr<OneShotGetReadyCallback> get_ready_callback_; | 
| 324 scoped_refptr<ServiceWorkerVersion> controlling_version_; | 341 scoped_refptr<ServiceWorkerVersion> controlling_version_; | 
| 325 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; | 342 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; | 
| 326 base::WeakPtr<ServiceWorkerContextCore> context_; | 343 base::WeakPtr<ServiceWorkerContextCore> context_; | 
| 327 ServiceWorkerDispatcherHost* dispatcher_host_; | 344 ServiceWorkerDispatcherHost* dispatcher_host_; | 
| 328 bool allow_association_; | 345 bool allow_association_; | 
| 329 | 346 | 
| 330 std::vector<base::Closure> queued_events_; | 347 std::vector<base::Closure> queued_events_; | 
| 331 | 348 | 
| 332 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 349 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 
| 333 }; | 350 }; | 
| 334 | 351 | 
| 335 } // namespace content | 352 } // namespace content | 
| 336 | 353 | 
| 337 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 354 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 
| OLD | NEW |