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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.h

Issue 2182633007: Avoid using ContentBrowserClient::IsIllegalOrigin in ResourceDispatcherHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile failures Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This is the browser side of the resource dispatcher, it receives requests 5 // This is the browser side of the resource dispatcher, it receives requests
6 // from the child process (i.e. [Renderer, Plugin, Worker]ProcessHost), and 6 // from the child process (i.e. [Renderer, Plugin, Worker]ProcessHost), and
7 // dispatches them to URLRequests. It then forwards the messages from the 7 // dispatches them to URLRequests. It then forwards the messages from the
8 // URLRequests back to the correct process for handling. 8 // URLRequests back to the correct process for handling.
9 // 9 //
10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 RenderFrameHost* root_frame_host); 117 RenderFrameHost* root_frame_host);
118 118
119 // Cancels any blocked request for the frame and its subframes. 119 // Cancels any blocked request for the frame and its subframes.
120 static void CancelBlockedRequestsForFrameFromUI( 120 static void CancelBlockedRequestsForFrameFromUI(
121 RenderFrameHostImpl* root_frame_host); 121 RenderFrameHostImpl* root_frame_host);
122 122
123 // ResourceDispatcherHost implementation: 123 // ResourceDispatcherHost implementation:
124 void SetDelegate(ResourceDispatcherHostDelegate* delegate) override; 124 void SetDelegate(ResourceDispatcherHostDelegate* delegate) override;
125 void SetAllowCrossOriginAuthPrompt(bool value) override; 125 void SetAllowCrossOriginAuthPrompt(bool value) override;
126 void ClearLoginDelegateForRequest(net::URLRequest* request) override; 126 void ClearLoginDelegateForRequest(net::URLRequest* request) override;
127 127 void AddSchemeForAccessCheck(const std::string& scheme) override;
128 void AddOriginAccessInformation(const ResourceContext* context,
129 const std::string& origin) override;
130 void RemoveOriginAccessInformation(const ResourceContext* context,
131 const std::string& origin) override;
132 void AddOwnerForOrigin(const ResourceContext* context,
133 const std::string& origin,
134 int owner_process_id) override;
135 void RemoveOwnerForOrigin(const ResourceContext* context,
136 const std::string& origin,
137 int owner_process_id) override;
138 void AddGuestForOrigin(const ResourceContext* context,
139 const std::string& origin,
140 int guest_process_id) override;
141 void RemoveGuestForOrigin(const ResourceContext* context,
142 const std::string& origin,
143 int guest_process_id) override;
128 // Puts the resource dispatcher host in an inactive state (unable to begin 144 // Puts the resource dispatcher host in an inactive state (unable to begin
129 // new requests). Cancels all pending requests. 145 // new requests). Cancels all pending requests.
130 void Shutdown(); 146 void Shutdown();
131 147
132 // Force cancels any pending requests for the given |context|. This is 148 // Force cancels any pending requests for the given |context|. This is
133 // necessary to ensure that before |context| goes away, all requests 149 // necessary to ensure that before |context| goes away, all requests
134 // for it are dead. 150 // for it are dead.
135 void CancelRequestsForContext(ResourceContext* context); 151 void CancelRequestsForContext(ResourceContext* context);
136 152
137 // Returns true if the message was a resource message that was processed. 153 // Returns true if the message was a resource message that was processed.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 NavigationURLLoaderImplCore* loader); 316 NavigationURLLoaderImplCore* loader);
301 317
302 // Turns on stale-while-revalidate support, regardless of command-line flags 318 // Turns on stale-while-revalidate support, regardless of command-line flags
303 // or experiment status. For unit tests only. 319 // or experiment status. For unit tests only.
304 void EnableStaleWhileRevalidateForTesting(); 320 void EnableStaleWhileRevalidateForTesting();
305 321
306 // Sets the LoaderDelegate, which must outlive this object. Ownership is not 322 // Sets the LoaderDelegate, which must outlive this object. Ownership is not
307 // transferred. The LoaderDelegate should be interacted with on the IO thread. 323 // transferred. The LoaderDelegate should be interacted with on the IO thread.
308 void SetLoaderDelegate(LoaderDelegate* loader_delegate); 324 void SetLoaderDelegate(LoaderDelegate* loader_delegate);
309 325
326 // Checks whether the child process identified by |child_process_id| is
327 // allowed to access the |origin| and returns true if not.
328 bool IsIllegalOrigin(ResourceContext* context,
329 const GURL& origin,
330 int child_process_id);
331
310 private: 332 private:
311 friend class LoaderIOThreadNotifier; 333 friend class LoaderIOThreadNotifier;
312 friend class ResourceDispatcherHostTest; 334 friend class ResourceDispatcherHostTest;
313 335
314 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 336 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
315 TestBlockedRequestsProcessDies); 337 TestBlockedRequestsProcessDies);
316 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 338 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
317 CalculateApproximateMemoryCost); 339 CalculateApproximateMemoryCost);
318 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 340 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
319 DetachableResourceTimesOut); 341 DetachableResourceTimesOut);
(...skipping 14 matching lines...) Expand all
334 struct LoadInfo { 356 struct LoadInfo {
335 GURL url; 357 GURL url;
336 net::LoadStateWithParam load_state; 358 net::LoadStateWithParam load_state;
337 uint64_t upload_position; 359 uint64_t upload_position;
338 uint64_t upload_size; 360 uint64_t upload_size;
339 }; 361 };
340 362
341 // Map from ProcessID+RouteID pair to the "most interesting" LoadState. 363 // Map from ProcessID+RouteID pair to the "most interesting" LoadState.
342 typedef std::map<GlobalRoutingID, LoadInfo> LoadInfoMap; 364 typedef std::map<GlobalRoutingID, LoadInfo> LoadInfoMap;
343 365
366 // Information about an origin. This includes whether it has accessible
367 // resources, which processes own it, which are its guests, etc.
jam 2016/08/01 20:06:01 nit: this comment discusses chrome apps concepts,
ananta 2016/08/02 00:40:49 Done.
368 struct OriginAccessInfo {
369 // This structure is complicated enough for clang to require the ctors to
370 // be explicitly defined in the cc file.
371 OriginAccessInfo();
372 ~OriginAccessInfo();
373 OriginAccessInfo(const OriginAccessInfo& other);
374
375 std::set<int> origin_owner_processes;
376 std::set<int> origin_guest_processes;
377 };
378
379 // Map from the origin host (std::string) to its information
380 // (OriginAccessInfo).
381 // This map is per ResourceContext.
382 typedef std::map<std::string, OriginAccessInfo> OriginAccessInfoMap;
383
384 typedef std::map<const ResourceContext*, OriginAccessInfoMap*>
jam 2016/08/01 20:06:01 unique_ptr?
ananta 2016/08/02 00:40:50 Done.
385 ResourceContextOriginMap;
386
344 // ResourceLoaderDelegate implementation: 387 // ResourceLoaderDelegate implementation:
345 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( 388 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
346 ResourceLoader* loader, 389 ResourceLoader* loader,
347 net::AuthChallengeInfo* auth_info) override; 390 net::AuthChallengeInfo* auth_info) override;
348 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override; 391 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override;
349 void DidStartRequest(ResourceLoader* loader) override; 392 void DidStartRequest(ResourceLoader* loader) override;
350 void DidReceiveRedirect(ResourceLoader* loader, const GURL& new_url) override; 393 void DidReceiveRedirect(ResourceLoader* loader, const GURL& new_url) override;
351 void DidReceiveResponse(ResourceLoader* loader) override; 394 void DidReceiveResponse(ResourceLoader* loader) override;
352 void DidFinishLoading(ResourceLoader* loader) override; 395 void DidFinishLoading(ResourceLoader* loader) override;
353 std::unique_ptr<net::ClientCertStore> CreateClientCertStore( 396 std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // The certificate on a ResourceResponse is associated with a 590 // The certificate on a ResourceResponse is associated with a
548 // particular renderer process. As a transfer to a new process 591 // particular renderer process. As a transfer to a new process
549 // completes, the stored certificate has to be updated to reflect the 592 // completes, the stored certificate has to be updated to reflect the
550 // new renderer process. 593 // new renderer process.
551 void UpdateResponseCertificateForTransfer(ResourceResponse* response, 594 void UpdateResponseCertificateForTransfer(ResourceResponse* response,
552 const net::SSLInfo& ssl_info, 595 const net::SSLInfo& ssl_info,
553 int child_id); 596 int child_id);
554 597
555 CertStore* GetCertStore(); 598 CertStore* GetCertStore();
556 599
600 // Returns the OriginAccessInfoMap instance for the |context| passed in. This
601 // map is used to enforce access checks on web requests for some origins.
602 OriginAccessInfoMap* GetOriginAccessMapForResourceContext(
603 const ResourceContext* context);
604
557 LoaderMap pending_loaders_; 605 LoaderMap pending_loaders_;
558 606
559 // Collection of temp files downloaded for child processes via 607 // Collection of temp files downloaded for child processes via
560 // the download_to_file mechanism. We avoid deleting them until 608 // the download_to_file mechanism. We avoid deleting them until
561 // the client no longer needs them. 609 // the client no longer needs them.
562 typedef std::map<int, scoped_refptr<storage::ShareableFileReference> > 610 typedef std::map<int, scoped_refptr<storage::ShareableFileReference> >
563 DeletableFilesMap; // key is request id 611 DeletableFilesMap; // key is request id
564 typedef std::map<int, DeletableFilesMap> 612 typedef std::map<int, DeletableFilesMap>
565 RegisteredTempFiles; // key is child process id 613 RegisteredTempFiles; // key is child process id
566 RegisteredTempFiles registered_temp_files_; 614 RegisteredTempFiles registered_temp_files_;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 typedef std::map<GlobalRequestID, 689 typedef std::map<GlobalRequestID,
642 base::ObserverList<ResourceMessageDelegate>*> DelegateMap; 690 base::ObserverList<ResourceMessageDelegate>*> DelegateMap;
643 DelegateMap delegate_map_; 691 DelegateMap delegate_map_;
644 692
645 std::unique_ptr<ResourceScheduler> scheduler_; 693 std::unique_ptr<ResourceScheduler> scheduler_;
646 694
647 // Allows tests to use a mock CertStore. If set, the CertStore must 695 // Allows tests to use a mock CertStore. If set, the CertStore must
648 // outlive this ResourceDispatcherHostImpl. 696 // outlive this ResourceDispatcherHostImpl.
649 CertStore* cert_store_for_testing_; 697 CertStore* cert_store_for_testing_;
650 698
699 // Used to check whether a request to retrieve an origin resource is allowed.
700 // This is only done for origins which are to be checked for access.
701 ResourceContextOriginMap context_origin_access_info_map_;
702
703 // This contains the set of origins we need to enforce access checks on. By
704 // default everything is allowed.
705 std::set<std::string> origins_for_access_check_;
706
651 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 707 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
652 }; 708 };
653 709
654 } // namespace content 710 } // namespace content
655 711
656 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 712 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698