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

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

Issue 1692503002: Functionality to allow blacklist and whitelist of custom schemes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another variable set as const Created 4 years, 9 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <algorithm> 10 #include <algorithm>
11 #include <set> 11 #include <set>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/bind_helpers.h" 16 #include "base/bind_helpers.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/debug/alias.h" 19 #include "base/debug/alias.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "base/memory/shared_memory.h"
24 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
25 #include "base/metrics/field_trial.h" 24 #include "base/metrics/field_trial.h"
26 #include "base/metrics/histogram_macros.h" 25 #include "base/metrics/histogram_macros.h"
27 #include "base/metrics/sparse_histogram.h" 26 #include "base/metrics/sparse_histogram.h"
28 #include "base/profiler/scoped_tracker.h" 27 #include "base/profiler/scoped_tracker.h"
29 #include "base/stl_util.h" 28 #include "base/stl_util.h"
30 #include "base/strings/string_util.h" 29 #include "base/strings/string_util.h"
31 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 30 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
32 #include "base/time/time.h" 31 #include "base/time/time.h"
33 #include "content/browser/appcache/appcache_interceptor.h" 32 #include "content/browser/appcache/appcache_interceptor.h"
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 843 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
845 844
846 if (!IsResourceTypeFrame(info->GetResourceType())) 845 if (!IsResourceTypeFrame(info->GetResourceType()))
847 return false; 846 return false;
848 847
849 const net::URLRequestJobFactory* job_factory = 848 const net::URLRequestJobFactory* job_factory =
850 info->GetContext()->GetRequestContext()->job_factory(); 849 info->GetContext()->GetRequestContext()->job_factory();
851 if (job_factory->IsHandledURL(url)) 850 if (job_factory->IsHandledURL(url))
852 return false; 851 return false;
853 852
853 const net::URLRequest* req = loader->request();
bartfab (slow) 2016/03/10 13:49:41 Nit: const pointer.
854 const net::NetworkDelegate* network_delegate = req->network_delegate();
bartfab (slow) 2016/03/10 13:49:41 Nit 1: #include "net/base/network_delegate.h" Nit
855 // Get the state, if url is in blacklist, whitelist or in none of those.
856 const net::NetworkDelegate::URLBlacklistState urlState =
857 network_delegate->GetURLBlacklistState(url);
858
859 if (urlState == net::NetworkDelegate::URLBlacklistState::URL_IN_BLACKLIST) {
860 // It's a link with custom scheme and it's blacklisted. We return false here
861 // and let it process as a normal URL. Eventually chrome_network_delegate
862 // will see it's in the blacklist and the user will be shown the blocked
863 // content page.
864 return false;
865 }
866
854 return delegate_->HandleExternalProtocol( 867 return delegate_->HandleExternalProtocol(
855 url, info->GetChildID(), info->GetWebContentsGetterForRequest(), 868 url, info->GetChildID(), info->GetWebContentsGetterForRequest(),
856 info->IsMainFrame(), info->GetPageTransition(), info->HasUserGesture()); 869 info->IsMainFrame(), info->GetPageTransition(), info->HasUserGesture(),
870 urlState == net::NetworkDelegate::URLBlacklistState::URL_IN_WHITELIST);
857 } 871 }
858 872
859 void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoader* loader) { 873 void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoader* loader) {
860 // Make sure we have the load state monitor running. 874 // Make sure we have the load state monitor running.
861 if (!update_load_states_timer_->IsRunning() && 875 if (!update_load_states_timer_->IsRunning() &&
862 scheduler_->HasLoadingClients()) { 876 scheduler_->HasLoadingClients()) {
863 update_load_states_timer_->Start( 877 update_load_states_timer_->Start(
864 FROM_HERE, TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), 878 FROM_HERE, TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec),
865 this, &ResourceDispatcherHostImpl::UpdateLoadInfo); 879 this, &ResourceDispatcherHostImpl::UpdateLoadInfo);
866 } 880 }
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 load_flags |= net::LOAD_PREFETCH; 2580 load_flags |= net::LOAD_PREFETCH;
2567 } 2581 }
2568 2582
2569 if (is_sync_load) 2583 if (is_sync_load)
2570 load_flags |= net::LOAD_IGNORE_LIMITS; 2584 load_flags |= net::LOAD_IGNORE_LIMITS;
2571 2585
2572 return load_flags; 2586 return load_flags;
2573 } 2587 }
2574 2588
2575 } // namespace content 2589 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698