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

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 502483002: Check policy when checking device access for enumerating devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added dchecks Created 6 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 | Annotate | Revision Log
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 #include "chrome/browser/profiles/profile_io_data.h" 5 #include "chrome/browser/profiles/profile_io_data.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/content_settings/cookie_settings.h" 27 #include "chrome/browser/content_settings/cookie_settings.h"
28 #include "chrome/browser/content_settings/host_content_settings_map.h" 28 #include "chrome/browser/content_settings/host_content_settings_map.h"
29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
31 #include "chrome/browser/devtools/devtools_network_controller.h" 31 #include "chrome/browser/devtools/devtools_network_controller.h"
32 #include "chrome/browser/devtools/devtools_network_transaction_factory.h" 32 #include "chrome/browser/devtools/devtools_network_transaction_factory.h"
33 #include "chrome/browser/download/download_service.h" 33 #include "chrome/browser/download/download_service.h"
34 #include "chrome/browser/download/download_service_factory.h" 34 #include "chrome/browser/download/download_service_factory.h"
35 #include "chrome/browser/io_thread.h" 35 #include "chrome/browser/io_thread.h"
36 #include "chrome/browser/media/media_device_id_salt.h" 36 #include "chrome/browser/media/media_device_id_salt.h"
37 #include "chrome/browser/media/media_stream_devices_helper.h"
37 #include "chrome/browser/net/about_protocol_handler.h" 38 #include "chrome/browser/net/about_protocol_handler.h"
38 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" 39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h"
39 #include "chrome/browser/net/chrome_http_user_agent_settings.h" 40 #include "chrome/browser/net/chrome_http_user_agent_settings.h"
40 #include "chrome/browser/net/chrome_net_log.h" 41 #include "chrome/browser/net/chrome_net_log.h"
41 #include "chrome/browser/net/chrome_network_delegate.h" 42 #include "chrome/browser/net/chrome_network_delegate.h"
42 #include "chrome/browser/net/chrome_url_request_context_getter.h" 43 #include "chrome/browser/net/chrome_url_request_context_getter.h"
43 #include "chrome/browser/net/cookie_store_util.h" 44 #include "chrome/browser/net/cookie_store_util.h"
44 #include "chrome/browser/net/proxy_service_factory.h" 45 #include "chrome/browser/net/proxy_service_factory.h"
45 #include "chrome/browser/profiles/profile.h" 46 #include "chrome/browser/profiles/profile.h"
46 #include "chrome/browser/profiles/profile_manager.h" 47 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 return http_server_properties_->GetWeakPtr(); 866 return http_server_properties_->GetWeakPtr();
866 } 867 }
867 868
868 void ProfileIOData::set_http_server_properties( 869 void ProfileIOData::set_http_server_properties(
869 scoped_ptr<net::HttpServerProperties> http_server_properties) const { 870 scoped_ptr<net::HttpServerProperties> http_server_properties) const {
870 http_server_properties_ = http_server_properties.Pass(); 871 http_server_properties_ = http_server_properties.Pass();
871 } 872 }
872 873
873 ProfileIOData::ResourceContext::ResourceContext(ProfileIOData* io_data) 874 ProfileIOData::ResourceContext::ResourceContext(ProfileIOData* io_data)
874 : io_data_(io_data), 875 : io_data_(io_data),
876 profile_(NULL),
875 host_resolver_(NULL), 877 host_resolver_(NULL),
876 request_context_(NULL) { 878 request_context_(NULL) {
877 DCHECK(io_data); 879 DCHECK(io_data);
878 } 880 }
879 881
880 ProfileIOData::ResourceContext::~ResourceContext() {} 882 ProfileIOData::ResourceContext::~ResourceContext() {}
881 883
884 void ProfileIOData::ResourceContext::set_profile(Profile* profile) {
885 DCHECK(!profile_);
886 DCHECK(profile);
887 profile_ = profile;
888 }
889
882 net::HostResolver* ProfileIOData::ResourceContext::GetHostResolver() { 890 net::HostResolver* ProfileIOData::ResourceContext::GetHostResolver() {
883 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 891 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
884 DCHECK(io_data_->initialized_); 892 DCHECK(io_data_->initialized_);
885 return host_resolver_; 893 return host_resolver_;
886 } 894 }
887 895
888 net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() { 896 net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() {
889 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 897 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
890 DCHECK(io_data_->initialized_); 898 DCHECK(io_data_->initialized_);
891 return request_context_; 899 return request_context_;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 return; 952 return;
945 } 953 }
946 // Otherwise, the InitializeSlot will run the callback asynchronously. 954 // Otherwise, the InitializeSlot will run the callback asynchronously.
947 #else 955 #else
948 callback.Run(make_scoped_ptr( 956 callback.Run(make_scoped_ptr(
949 new net::KeygenHandler(key_size_in_bits, challenge_string, url))); 957 new net::KeygenHandler(key_size_in_bits, challenge_string, url)));
950 #endif 958 #endif
951 } 959 }
952 960
953 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) { 961 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) {
962 DCHECK(profile_);
963 if (GetDevicePolicy(profile_, origin, prefs::kAudioCaptureAllowed,
964 prefs::kAudioCaptureAllowedUrls) == ALWAYS_ALLOW) {
mmenke 2014/08/22 20:08:52 Erm...Aren't we on the IO thread here, not the UI
965 return true;
966 }
954 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 967 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
955 } 968 }
956 969
957 bool ProfileIOData::ResourceContext::AllowCameraAccess(const GURL& origin) { 970 bool ProfileIOData::ResourceContext::AllowCameraAccess(const GURL& origin) {
971 DCHECK(profile_);
972 if (GetDevicePolicy(profile_, origin, prefs::kVideoCaptureAllowed,
973 prefs::kVideoCaptureAllowedUrls) == ALWAYS_ALLOW) {
974 return true;
975 }
958 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 976 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
959 } 977 }
960 978
961 bool ProfileIOData::ResourceContext::AllowContentAccess( 979 bool ProfileIOData::ResourceContext::AllowContentAccess(
962 const GURL& origin, ContentSettingsType type) { 980 const GURL& origin, ContentSettingsType type) {
963 HostContentSettingsMap* content_settings = 981 HostContentSettingsMap* content_settings =
964 io_data_->GetHostContentSettingsMap(); 982 io_data_->GetHostContentSettingsMap();
965 ContentSetting setting = content_settings->GetContentSetting( 983 ContentSetting setting = content_settings->GetContentSetting(
966 origin, origin, type, NO_RESOURCE_IDENTIFIER); 984 origin, origin, type, NO_RESOURCE_IDENTIFIER);
967 return setting == CONTENT_SETTING_ALLOW; 985 return setting == CONTENT_SETTING_ALLOW;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 void ProfileIOData::SetCookieSettingsForTesting( 1313 void ProfileIOData::SetCookieSettingsForTesting(
1296 CookieSettings* cookie_settings) { 1314 CookieSettings* cookie_settings) {
1297 DCHECK(!cookie_settings_.get()); 1315 DCHECK(!cookie_settings_.get());
1298 cookie_settings_ = cookie_settings; 1316 cookie_settings_ = cookie_settings;
1299 } 1317 }
1300 1318
1301 void ProfileIOData::set_signin_names_for_testing( 1319 void ProfileIOData::set_signin_names_for_testing(
1302 SigninNamesOnIOThread* signin_names) { 1320 SigninNamesOnIOThread* signin_names) {
1303 signin_names_.reset(signin_names); 1321 signin_names_.reset(signin_names);
1304 } 1322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698