| OLD | NEW | 
|    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 #include "chrome/browser/net/ssl_config_service_manager.h" |    4 #include "chrome/browser/net/ssl_config_service_manager.h" | 
|    5  |    5  | 
|    6 #include <algorithm> |    6 #include <algorithm> | 
|    7 #include <string> |    7 #include <string> | 
|    8 #include <vector> |    8 #include <vector> | 
|    9  |    9  | 
|   10 #include "base/basictypes.h" |   10 #include "base/basictypes.h" | 
|   11 #include "base/bind.h" |   11 #include "base/bind.h" | 
|   12 #include "base/prefs/public/pref_change_registrar.h" |   12 #include "base/prefs/public/pref_change_registrar.h" | 
|   13 #include "base/prefs/public/pref_observer.h" |  | 
|   14 #include "chrome/browser/api/prefs/pref_member.h" |   13 #include "chrome/browser/api/prefs/pref_member.h" | 
|   15 #include "chrome/browser/content_settings/content_settings_utils.h" |   14 #include "chrome/browser/content_settings/content_settings_utils.h" | 
|   16 #include "chrome/browser/prefs/pref_service.h" |   15 #include "chrome/browser/prefs/pref_service.h" | 
|   17 #include "chrome/common/chrome_notification_types.h" |   16 #include "chrome/common/chrome_notification_types.h" | 
|   18 #include "chrome/common/content_settings.h" |   17 #include "chrome/common/content_settings.h" | 
|   19 #include "chrome/common/pref_names.h" |   18 #include "chrome/common/pref_names.h" | 
|   20 #include "content/public/browser/browser_thread.h" |   19 #include "content/public/browser/browser_thread.h" | 
|   21 #include "net/base/ssl_cipher_suite_names.h" |   20 #include "net/base/ssl_cipher_suite_names.h" | 
|   22 #include "net/base/ssl_config_service.h" |   21 #include "net/base/ssl_config_service.h" | 
|   23  |   22  | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  136   net::SSLConfig orig_config = cached_config_; |  135   net::SSLConfig orig_config = cached_config_; | 
|  137   cached_config_ = new_config; |  136   cached_config_ = new_config; | 
|  138   ProcessConfigUpdate(orig_config, new_config); |  137   ProcessConfigUpdate(orig_config, new_config); | 
|  139 } |  138 } | 
|  140  |  139  | 
|  141 //////////////////////////////////////////////////////////////////////////////// |  140 //////////////////////////////////////////////////////////////////////////////// | 
|  142 //  SSLConfigServiceManagerPref |  141 //  SSLConfigServiceManagerPref | 
|  143  |  142  | 
|  144 // The manager for holding and updating an SSLConfigServicePref instance. |  143 // The manager for holding and updating an SSLConfigServicePref instance. | 
|  145 class SSLConfigServiceManagerPref |  144 class SSLConfigServiceManagerPref | 
|  146     : public SSLConfigServiceManager, |  145     : public SSLConfigServiceManager { | 
|  147       public PrefObserver { |  | 
|  148  public: |  146  public: | 
|  149   SSLConfigServiceManagerPref(PrefService* local_state, |  147   SSLConfigServiceManagerPref(PrefService* local_state, | 
|  150                               PrefService* user_prefs); |  148                               PrefService* user_prefs); | 
|  151   virtual ~SSLConfigServiceManagerPref() {} |  149   virtual ~SSLConfigServiceManagerPref() {} | 
|  152  |  150  | 
|  153   // Register local_state SSL preferences. |  151   // Register local_state SSL preferences. | 
|  154   static void RegisterPrefs(PrefService* local_state); |  152   static void RegisterPrefs(PrefService* local_state); | 
|  155  |  153  | 
|  156   virtual net::SSLConfigService* Get(); |  154   virtual net::SSLConfigService* Get(); | 
|  157  |  155  | 
|  158  private: |  156  private: | 
|  159   // Callback for preference changes.  This will post the changes to the IO |  157   // Callback for preference changes.  This will post the changes to the IO | 
|  160   // thread with SetNewSSLConfig. |  158   // thread with SetNewSSLConfig. | 
|  161   virtual void OnPreferenceChanged(PrefServiceBase* service, |  159   void OnPreferenceChanged(PrefServiceBase* prefs, | 
|  162                                    const std::string& pref_name) OVERRIDE; |  160                            const std::string& pref_name); | 
|  163  |  161  | 
|  164   // Store SSL config settings in |config|, directly from the preferences. Must |  162   // Store SSL config settings in |config|, directly from the preferences. Must | 
|  165   // only be called from UI thread. |  163   // only be called from UI thread. | 
|  166   void GetSSLConfigFromPrefs(net::SSLConfig* config); |  164   void GetSSLConfigFromPrefs(net::SSLConfig* config); | 
|  167  |  165  | 
|  168   // Processes changes to the disabled cipher suites preference, updating the |  166   // Processes changes to the disabled cipher suites preference, updating the | 
|  169   // cached list of parsed SSL/TLS cipher suites that are disabled. |  167   // cached list of parsed SSL/TLS cipher suites that are disabled. | 
|  170   void OnDisabledCipherSuitesChange(PrefServiceBase* local_state); |  168   void OnDisabledCipherSuitesChange(PrefServiceBase* local_state); | 
|  171  |  169  | 
|  172   // Processes changes to the default cookie settings. |  170   // Processes changes to the default cookie settings. | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
|  198  |  196  | 
|  199   DISALLOW_COPY_AND_ASSIGN(SSLConfigServiceManagerPref); |  197   DISALLOW_COPY_AND_ASSIGN(SSLConfigServiceManagerPref); | 
|  200 }; |  198 }; | 
|  201  |  199  | 
|  202 SSLConfigServiceManagerPref::SSLConfigServiceManagerPref( |  200 SSLConfigServiceManagerPref::SSLConfigServiceManagerPref( | 
|  203     PrefService* local_state, PrefService* user_prefs) |  201     PrefService* local_state, PrefService* user_prefs) | 
|  204     : have_user_prefs_(!!user_prefs), |  202     : have_user_prefs_(!!user_prefs), | 
|  205       ssl_config_service_(new SSLConfigServicePref()) { |  203       ssl_config_service_(new SSLConfigServicePref()) { | 
|  206   DCHECK(local_state); |  204   DCHECK(local_state); | 
|  207  |  205  | 
|  208   rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled, |  206   PrefChangeRegistrar::NamedChangeCallback local_state_callback = base::Bind( | 
|  209                              local_state, this); |  207       &SSLConfigServiceManagerPref::OnPreferenceChanged, | 
|  210   ssl_version_min_.Init(prefs::kSSLVersionMin, local_state, this); |  208       base::Unretained(this), | 
|  211   ssl_version_max_.Init(prefs::kSSLVersionMax, local_state, this); |  209       local_state); | 
|  212   channel_id_enabled_.Init(prefs::kEnableOriginBoundCerts, local_state, this); |  210  | 
|  213   ssl_record_splitting_disabled_.Init(prefs::kDisableSSLRecordSplitting, |  211   rev_checking_enabled_.Init( | 
|  214                                       local_state, this); |  212       prefs::kCertRevocationCheckingEnabled, local_state, local_state_callback); | 
 |  213   ssl_version_min_.Init( | 
 |  214       prefs::kSSLVersionMin, local_state, local_state_callback); | 
 |  215   ssl_version_max_.Init( | 
 |  216       prefs::kSSLVersionMax, local_state, local_state_callback); | 
 |  217   channel_id_enabled_.Init( | 
 |  218       prefs::kEnableOriginBoundCerts, local_state, local_state_callback); | 
 |  219   ssl_record_splitting_disabled_.Init( | 
 |  220       prefs::kDisableSSLRecordSplitting, local_state, local_state_callback); | 
 |  221  | 
|  215   local_state_change_registrar_.Init(local_state); |  222   local_state_change_registrar_.Init(local_state); | 
|  216   local_state_change_registrar_.Add(prefs::kCipherSuiteBlacklist, this); |  223   local_state_change_registrar_.Add( | 
 |  224       prefs::kCipherSuiteBlacklist, local_state_callback); | 
|  217  |  225  | 
|  218   OnDisabledCipherSuitesChange(local_state); |  226   OnDisabledCipherSuitesChange(local_state); | 
|  219  |  227  | 
|  220   if (user_prefs) { |  228   if (user_prefs) { | 
|  221     block_third_party_cookies_.Init(prefs::kBlockThirdPartyCookies, user_prefs, |  229     PrefChangeRegistrar::NamedChangeCallback user_prefs_callback = base::Bind( | 
|  222                                     this); |  230         &SSLConfigServiceManagerPref::OnPreferenceChanged, | 
 |  231         base::Unretained(this), | 
 |  232         user_prefs); | 
 |  233     block_third_party_cookies_.Init( | 
 |  234         prefs::kBlockThirdPartyCookies, user_prefs, user_prefs_callback); | 
|  223     user_prefs_change_registrar_.Init(user_prefs); |  235     user_prefs_change_registrar_.Init(user_prefs); | 
|  224     user_prefs_change_registrar_.Add(prefs::kDefaultContentSettings, this); |  236     user_prefs_change_registrar_.Add( | 
 |  237         prefs::kDefaultContentSettings, user_prefs_callback); | 
|  225  |  238  | 
|  226     OnDefaultContentSettingsChange(user_prefs); |  239     OnDefaultContentSettingsChange(user_prefs); | 
|  227   } |  240   } | 
|  228  |  241  | 
|  229   // Initialize from UI thread.  This is okay as there shouldn't be anything on |  242   // Initialize from UI thread.  This is okay as there shouldn't be anything on | 
|  230   // the IO thread trying to access it yet. |  243   // the IO thread trying to access it yet. | 
|  231   GetSSLConfigFromPrefs(&ssl_config_service_->cached_config_); |  244   GetSSLConfigFromPrefs(&ssl_config_service_->cached_config_); | 
|  232 } |  245 } | 
|  233  |  246  | 
|  234 // static |  247 // static | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  335 // static |  348 // static | 
|  336 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( |  349 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( | 
|  337     PrefService* local_state, PrefService* user_prefs) { |  350     PrefService* local_state, PrefService* user_prefs) { | 
|  338   return new SSLConfigServiceManagerPref(local_state, user_prefs); |  351   return new SSLConfigServiceManagerPref(local_state, user_prefs); | 
|  339 } |  352 } | 
|  340  |  353  | 
|  341 // static |  354 // static | 
|  342 void SSLConfigServiceManager::RegisterPrefs(PrefService* prefs) { |  355 void SSLConfigServiceManager::RegisterPrefs(PrefService* prefs) { | 
|  343   SSLConfigServiceManagerPref::RegisterPrefs(prefs); |  356   SSLConfigServiceManagerPref::RegisterPrefs(prefs); | 
|  344 } |  357 } | 
| OLD | NEW |