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

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

Issue 24153012: Fix cyclic dependency between ProfilePolicyConnector and PrefService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix/Extend NetworkConfigurationUpdater unit test. Created 7 years, 1 month 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "chrome/common/chrome_paths.h" 56 #include "chrome/common/chrome_paths.h"
57 #include "chrome/common/chrome_switches.h" 57 #include "chrome/common/chrome_switches.h"
58 #include "chrome/common/pref_names.h" 58 #include "chrome/common/pref_names.h"
59 #include "chrome/common/url_constants.h" 59 #include "chrome/common/url_constants.h"
60 #include "components/startup_metric_utils/startup_metric_utils.h" 60 #include "components/startup_metric_utils/startup_metric_utils.h"
61 #include "content/public/browser/browser_thread.h" 61 #include "content/public/browser/browser_thread.h"
62 #include "content/public/browser/host_zoom_map.h" 62 #include "content/public/browser/host_zoom_map.h"
63 #include "content/public/browser/notification_service.h" 63 #include "content/public/browser/notification_service.h"
64 #include "content/public/browser/resource_context.h" 64 #include "content/public/browser/resource_context.h"
65 #include "extensions/common/constants.h" 65 #include "extensions/common/constants.h"
66 #include "net/cert/cert_verifier.h"
67 #include "net/cookies/canonical_cookie.h" 66 #include "net/cookies/canonical_cookie.h"
68 #include "net/cookies/cookie_monster.h" 67 #include "net/cookies/cookie_monster.h"
69 #include "net/http/http_transaction_factory.h" 68 #include "net/http/http_transaction_factory.h"
70 #include "net/http/http_util.h" 69 #include "net/http/http_util.h"
71 #include "net/proxy/proxy_config_service_fixed.h" 70 #include "net/proxy/proxy_config_service_fixed.h"
72 #include "net/proxy/proxy_script_fetcher_impl.h" 71 #include "net/proxy/proxy_script_fetcher_impl.h"
73 #include "net/proxy/proxy_service.h" 72 #include "net/proxy/proxy_service.h"
74 #include "net/ssl/client_cert_store.h" 73 #include "net/ssl/client_cert_store.h"
75 #include "net/ssl/client_cert_store_impl.h" 74 #include "net/ssl/client_cert_store_impl.h"
76 #include "net/ssl/server_bound_cert_service.h" 75 #include "net/ssl/server_bound_cert_service.h"
77 #include "net/url_request/data_protocol_handler.h" 76 #include "net/url_request/data_protocol_handler.h"
78 #include "net/url_request/file_protocol_handler.h" 77 #include "net/url_request/file_protocol_handler.h"
79 #include "net/url_request/ftp_protocol_handler.h" 78 #include "net/url_request/ftp_protocol_handler.h"
80 #include "net/url_request/protocol_intercept_job_factory.h" 79 #include "net/url_request/protocol_intercept_job_factory.h"
81 #include "net/url_request/url_request.h" 80 #include "net/url_request/url_request.h"
82 #include "net/url_request/url_request_file_job.h" 81 #include "net/url_request/url_request_file_job.h"
83 #include "net/url_request/url_request_job_factory_impl.h" 82 #include "net/url_request/url_request_job_factory_impl.h"
84 83
85 #if defined(ENABLE_MANAGED_USERS) 84 #if defined(ENABLE_MANAGED_USERS)
86 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" 85 #include "chrome/browser/managed_mode/managed_mode_url_filter.h"
87 #include "chrome/browser/managed_mode/managed_user_service.h" 86 #include "chrome/browser/managed_mode/managed_user_service.h"
88 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 87 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
89 #endif 88 #endif
90 89
91 #if defined(OS_CHROMEOS) 90 #if defined(OS_CHROMEOS)
92 #include "chrome/browser/chromeos/drive/drive_protocol_handler.h" 91 #include "chrome/browser/chromeos/drive/drive_protocol_handler.h"
92 #include "chrome/browser/chromeos/policy/network_policy_service.h"
93 #include "chrome/browser/chromeos/policy/network_policy_service_factory.h"
93 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" 94 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h"
94 #include "chrome/browser/chromeos/policy/user_network_configuration_updater.h"
95 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_fact ory.h"
96 #include "chrome/browser/chromeos/settings/cros_settings.h" 95 #include "chrome/browser/chromeos/settings/cros_settings.h"
97 #include "chrome/browser/policy/profile_policy_connector.h"
98 #include "chrome/browser/policy/profile_policy_connector_factory.h"
99 #include "chromeos/settings/cros_settings_names.h" 96 #include "chromeos/settings/cros_settings_names.h"
100 #endif // defined(OS_CHROMEOS) 97 #endif // defined(OS_CHROMEOS)
101 98
102 using content::BrowserContext; 99 using content::BrowserContext;
103 using content::BrowserThread; 100 using content::BrowserThread;
104 using content::ResourceContext; 101 using content::ResourceContext;
105 102
106 namespace { 103 namespace {
107 104
108 // ---------------------------------------------------------------------------- 105 // ----------------------------------------------------------------------------
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 request, network_delegate, path, 217 request, network_delegate, path,
221 content::BrowserThread::GetBlockingPool()-> 218 content::BrowserThread::GetBlockingPool()->
222 GetTaskRunnerWithShutdownBehavior( 219 GetTaskRunnerWithShutdownBehavior(
223 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); 220 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
224 221
225 return NULL; 222 return NULL;
226 } 223 }
227 }; 224 };
228 #endif // defined(DEBUG_DEVTOOLS) 225 #endif // defined(DEBUG_DEVTOOLS)
229 226
230 #if defined(OS_CHROMEOS)
231 scoped_ptr<policy::PolicyCertVerifier> CreatePolicyCertVerifier(
232 Profile* profile) {
233 policy::ProfilePolicyConnector* connector =
234 policy::ProfilePolicyConnectorFactory::GetForProfile(profile);
235 base::Closure policy_cert_trusted_callback =
236 base::Bind(base::IgnoreResult(&content::BrowserThread::PostTask),
237 content::BrowserThread::UI,
238 FROM_HERE,
239 connector->GetPolicyCertTrustedCallback());
240 scoped_ptr<policy::PolicyCertVerifier> cert_verifier(
241 new policy::PolicyCertVerifier(policy_cert_trusted_callback));
242 policy::UserNetworkConfigurationUpdater* network_configuration_updater =
243 policy::UserNetworkConfigurationUpdaterFactory::GetForProfile(profile);
244 if (network_configuration_updater)
245 network_configuration_updater->SetPolicyCertVerifier(cert_verifier.get());
246 return cert_verifier.Pass();
247 }
248 #endif
249 } // namespace 227 } // namespace
250 228
251 void ProfileIOData::InitializeOnUIThread(Profile* profile) { 229 void ProfileIOData::InitializeOnUIThread(Profile* profile) {
252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
253 PrefService* pref_service = profile->GetPrefs(); 231 PrefService* pref_service = profile->GetPrefs();
254 PrefService* local_state_pref_service = g_browser_process->local_state(); 232 PrefService* local_state_pref_service = g_browser_process->local_state();
255 233
256 scoped_ptr<ProfileParams> params(new ProfileParams); 234 scoped_ptr<ProfileParams> params(new ProfileParams);
257 params->path = profile->GetPath(); 235 params->path = profile->GetPath();
258 236
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 272
295 params->proxy_config_service 273 params->proxy_config_service
296 .reset(ProxyServiceFactory::CreateProxyConfigService( 274 .reset(ProxyServiceFactory::CreateProxyConfigService(
297 profile->GetProxyConfigTracker())); 275 profile->GetProxyConfigTracker()));
298 #if defined(ENABLE_MANAGED_USERS) 276 #if defined(ENABLE_MANAGED_USERS)
299 ManagedUserService* managed_user_service = 277 ManagedUserService* managed_user_service =
300 ManagedUserServiceFactory::GetForProfile(profile); 278 ManagedUserServiceFactory::GetForProfile(profile);
301 params->managed_mode_url_filter = 279 params->managed_mode_url_filter =
302 managed_user_service->GetURLFilterForIOThread(); 280 managed_user_service->GetURLFilterForIOThread();
303 #endif 281 #endif
304 #if defined(OS_CHROMEOS)
305 params->cert_verifier = CreatePolicyCertVerifier(profile);
306 #endif
307 282
308 params->profile = profile; 283 params->profile = profile;
309 profile_params_.reset(params.release()); 284 profile_params_.reset(params.release());
310 285
311 ChromeNetworkDelegate::InitializePrefsOnUIThread( 286 ChromeNetworkDelegate::InitializePrefsOnUIThread(
312 &enable_referrers_, 287 &enable_referrers_,
313 &enable_do_not_track_, 288 &enable_do_not_track_,
314 &force_safesearch_, 289 &force_safesearch_,
315 pref_service); 290 pref_service);
316 291
(...skipping 27 matching lines...) Expand all
344 prefs::kReverseAutologinRejectedEmailList, pref_service); 319 prefs::kReverseAutologinRejectedEmailList, pref_service);
345 one_click_signin_rejected_email_list_.MoveToThread(io_message_loop_proxy); 320 one_click_signin_rejected_email_list_.MoveToThread(io_message_loop_proxy);
346 321
347 sync_disabled_.Init(prefs::kSyncManaged, pref_service); 322 sync_disabled_.Init(prefs::kSyncManaged, pref_service);
348 sync_disabled_.MoveToThread(io_message_loop_proxy); 323 sync_disabled_.MoveToThread(io_message_loop_proxy);
349 324
350 signin_allowed_.Init(prefs::kSigninAllowed, pref_service); 325 signin_allowed_.Init(prefs::kSigninAllowed, pref_service);
351 signin_allowed_.MoveToThread(io_message_loop_proxy); 326 signin_allowed_.MoveToThread(io_message_loop_proxy);
352 } 327 }
353 328
329 #if defined(OS_CHROMEOS)
330 cert_verifier_ =
331 policy::NetworkPolicyServiceFactory::CreateForProfile(profile);
332 #endif
354 // The URLBlacklistManager has to be created on the UI thread to register 333 // The URLBlacklistManager has to be created on the UI thread to register
355 // observers of |pref_service|, and it also has to clean up on 334 // observers of |pref_service|, and it also has to clean up on
356 // ShutdownOnUIThread to release these observers on the right thread. 335 // ShutdownOnUIThread to release these observers on the right thread.
357 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up, 336 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up,
358 // in particular when this ProfileIOData isn't |initialized_| during deletion. 337 // in particular when this ProfileIOData isn't |initialized_| during deletion.
359 #if defined(ENABLE_CONFIGURATION_POLICY) 338 #if defined(ENABLE_CONFIGURATION_POLICY)
360 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service)); 339 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service));
361 #endif 340 #endif
362 341
363 initialized_on_UI_thread_ = true; 342 initialized_on_UI_thread_ = true;
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 if (profile_params_->resource_prefetch_predictor_observer_) { 817 if (profile_params_->resource_prefetch_predictor_observer_) {
839 resource_prefetch_predictor_observer_.reset( 818 resource_prefetch_predictor_observer_.reset(
840 profile_params_->resource_prefetch_predictor_observer_.release()); 819 profile_params_->resource_prefetch_predictor_observer_.release());
841 } 820 }
842 821
843 #if defined(ENABLE_MANAGED_USERS) 822 #if defined(ENABLE_MANAGED_USERS)
844 managed_mode_url_filter_ = profile_params_->managed_mode_url_filter; 823 managed_mode_url_filter_ = profile_params_->managed_mode_url_filter;
845 #endif 824 #endif
846 825
847 #if defined(OS_CHROMEOS) 826 #if defined(OS_CHROMEOS)
848 profile_params_->cert_verifier->InitializeOnIOThread(); 827 if (cert_verifier_) {
849 cert_verifier_ = profile_params_->cert_verifier.Pass(); 828 cert_verifier_->InitializeOnIOThread();
850 main_request_context_->set_cert_verifier(cert_verifier_.get()); 829 main_request_context_->set_cert_verifier(cert_verifier_.get());
830 } else {
831 main_request_context_->set_cert_verifier(
832 io_thread_globals->cert_verifier.get());
833 }
851 #else 834 #else
852 main_request_context_->set_cert_verifier( 835 main_request_context_->set_cert_verifier(
853 io_thread_globals->cert_verifier.get()); 836 io_thread_globals->cert_verifier.get());
854 #endif 837 #endif
855 838
856 InitializeInternal(profile_params_.get(), protocol_handlers); 839 InitializeInternal(profile_params_.get(), protocol_handlers);
857 840
858 profile_params_.reset(); 841 profile_params_.reset();
859 initialized_ = true; 842 initialized_ = true;
860 } 843 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 void ProfileIOData::SetCookieSettingsForTesting( 981 void ProfileIOData::SetCookieSettingsForTesting(
999 CookieSettings* cookie_settings) { 982 CookieSettings* cookie_settings) {
1000 DCHECK(!cookie_settings_.get()); 983 DCHECK(!cookie_settings_.get());
1001 cookie_settings_ = cookie_settings; 984 cookie_settings_ = cookie_settings;
1002 } 985 }
1003 986
1004 void ProfileIOData::set_signin_names_for_testing( 987 void ProfileIOData::set_signin_names_for_testing(
1005 SigninNamesOnIOThread* signin_names) { 988 SigninNamesOnIOThread* signin_names) {
1006 signin_names_.reset(signin_names); 989 signin_names_.reset(signin_names);
1007 } 990 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698