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

Side by Side Diff: chrome/browser/ssl/chrome_ssl_host_state_delegate.cc

Issue 1312453005: Removed Profile::GetHostContentSettingsMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed patch conflict Created 5 years, 3 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
« no previous file with comments | « chrome/browser/signin/chrome_signin_client.cc ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ssl/chrome_ssl_host_state_delegate.h" 5 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/guid.h" 12 #include "base/guid.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/time/clock.h" 16 #include "base/time/clock.h"
17 #include "base/time/default_clock.h" 17 #include "base/time/default_clock.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
22 #include "components/content_settings/core/browser/host_content_settings_map.h" 23 #include "components/content_settings/core/browser/host_content_settings_map.h"
23 #include "components/content_settings/core/common/content_settings_types.h" 24 #include "components/content_settings/core/common/content_settings_types.h"
24 #include "components/variations/variations_associated_data.h" 25 #include "components/variations/variations_associated_data.h"
25 #include "net/base/hash_value.h" 26 #include "net/base/hash_value.h"
26 #include "net/base/net_util.h" 27 #include "net/base/net_util.h"
27 #include "net/cert/x509_certificate.h" 28 #include "net/cert/x509_certificate.h"
28 #include "net/http/http_transaction_factory.h" 29 #include "net/http/http_transaction_factory.h"
29 #include "net/url_request/url_request_context.h" 30 #include "net/url_request/url_request_context.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 230
230 ChromeSSLHostStateDelegate::~ChromeSSLHostStateDelegate() { 231 ChromeSSLHostStateDelegate::~ChromeSSLHostStateDelegate() {
231 } 232 }
232 233
233 void ChromeSSLHostStateDelegate::AllowCert(const std::string& host, 234 void ChromeSSLHostStateDelegate::AllowCert(const std::string& host,
234 const net::X509Certificate& cert, 235 const net::X509Certificate& cert,
235 net::CertStatus error) { 236 net::CertStatus error) {
236 GURL url = GetSecureGURLForHost(host); 237 GURL url = GetSecureGURLForHost(host);
237 const ContentSettingsPattern pattern = 238 const ContentSettingsPattern pattern =
238 ContentSettingsPattern::FromURLNoWildcard(url); 239 ContentSettingsPattern::FromURLNoWildcard(url);
239 HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); 240 HostContentSettingsMap* map =
241 HostContentSettingsMapFactory::GetForProfile(profile_);
240 scoped_ptr<base::Value> value(map->GetWebsiteSetting( 242 scoped_ptr<base::Value> value(map->GetWebsiteSetting(
241 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL)); 243 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL));
242 244
243 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) 245 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY))
244 value.reset(new base::DictionaryValue()); 246 value.reset(new base::DictionaryValue());
245 247
246 base::DictionaryValue* dict; 248 base::DictionaryValue* dict;
247 bool success = value->GetAsDictionary(&dict); 249 bool success = value->GetAsDictionary(&dict);
248 DCHECK(success); 250 DCHECK(success);
249 251
(...skipping 13 matching lines...) Expand all
263 // The map takes ownership of the value, so it is released in the call to 265 // The map takes ownership of the value, so it is released in the call to
264 // SetWebsiteSetting. 266 // SetWebsiteSetting.
265 map->SetWebsiteSetting(pattern, 267 map->SetWebsiteSetting(pattern,
266 pattern, 268 pattern,
267 CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, 269 CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS,
268 std::string(), 270 std::string(),
269 value.release()); 271 value.release());
270 } 272 }
271 273
272 void ChromeSSLHostStateDelegate::Clear() { 274 void ChromeSSLHostStateDelegate::Clear() {
273 profile_->GetHostContentSettingsMap()->ClearSettingsForOneType( 275 HostContentSettingsMapFactory::GetForProfile(profile_)
274 CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS); 276 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS);
275 } 277 }
276 278
277 content::SSLHostStateDelegate::CertJudgment 279 content::SSLHostStateDelegate::CertJudgment
278 ChromeSSLHostStateDelegate::QueryPolicy(const std::string& host, 280 ChromeSSLHostStateDelegate::QueryPolicy(const std::string& host,
279 const net::X509Certificate& cert, 281 const net::X509Certificate& cert,
280 net::CertStatus error, 282 net::CertStatus error,
281 bool* expired_previous_decision) { 283 bool* expired_previous_decision) {
282 HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); 284 HostContentSettingsMap* map =
285 HostContentSettingsMapFactory::GetForProfile(profile_);
283 GURL url = GetSecureGURLForHost(host); 286 GURL url = GetSecureGURLForHost(host);
284 scoped_ptr<base::Value> value(map->GetWebsiteSetting( 287 scoped_ptr<base::Value> value(map->GetWebsiteSetting(
285 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL)); 288 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL));
286 289
287 // Set a default value in case this method is short circuited and doesn't do a 290 // Set a default value in case this method is short circuited and doesn't do a
288 // full query. 291 // full query.
289 *expired_previous_decision = false; 292 *expired_previous_decision = false;
290 293
291 // If the appropriate flag is set, let requests on localhost go 294 // If the appropriate flag is set, let requests on localhost go
292 // through even if there are certificate errors. Errors on localhost 295 // through even if there are certificate errors. Errors on localhost
(...skipping 30 matching lines...) Expand all
323 return ALLOWED; 326 return ALLOWED;
324 327
325 return DENIED; 328 return DENIED;
326 } 329 }
327 330
328 void ChromeSSLHostStateDelegate::RevokeUserAllowExceptions( 331 void ChromeSSLHostStateDelegate::RevokeUserAllowExceptions(
329 const std::string& host) { 332 const std::string& host) {
330 GURL url = GetSecureGURLForHost(host); 333 GURL url = GetSecureGURLForHost(host);
331 const ContentSettingsPattern pattern = 334 const ContentSettingsPattern pattern =
332 ContentSettingsPattern::FromURLNoWildcard(url); 335 ContentSettingsPattern::FromURLNoWildcard(url);
333 HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); 336 HostContentSettingsMap* map =
337 HostContentSettingsMapFactory::GetForProfile(profile_);
334 338
335 map->SetWebsiteSetting(pattern, 339 map->SetWebsiteSetting(pattern,
336 pattern, 340 pattern,
337 CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, 341 CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS,
338 std::string(), 342 std::string(),
339 NULL); 343 NULL);
340 } 344 }
341 345
342 // TODO(jww): This will revoke all of the decisions in the browser context. 346 // TODO(jww): This will revoke all of the decisions in the browser context.
343 // However, the networking stack actually keeps track of its own list of 347 // However, the networking stack actually keeps track of its own list of
(...skipping 18 matching lines...) Expand all
362 profile_->GetRequestContext()); 366 profile_->GetRequestContext());
363 getter->GetNetworkTaskRunner()->PostTask( 367 getter->GetNetworkTaskRunner()->PostTask(
364 FROM_HERE, base::Bind(&CloseIdleConnections, getter)); 368 FROM_HERE, base::Bind(&CloseIdleConnections, getter));
365 } 369 }
366 370
367 bool ChromeSSLHostStateDelegate::HasAllowException( 371 bool ChromeSSLHostStateDelegate::HasAllowException(
368 const std::string& host) const { 372 const std::string& host) const {
369 GURL url = GetSecureGURLForHost(host); 373 GURL url = GetSecureGURLForHost(host);
370 const ContentSettingsPattern pattern = 374 const ContentSettingsPattern pattern =
371 ContentSettingsPattern::FromURLNoWildcard(url); 375 ContentSettingsPattern::FromURLNoWildcard(url);
372 HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); 376 HostContentSettingsMap* map =
377 HostContentSettingsMapFactory::GetForProfile(profile_);
373 378
374 scoped_ptr<base::Value> value(map->GetWebsiteSetting( 379 scoped_ptr<base::Value> value(map->GetWebsiteSetting(
375 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL)); 380 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL));
376 381
377 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) 382 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY))
378 return false; 383 return false;
379 384
380 base::DictionaryValue* dict; // Owned by value 385 base::DictionaryValue* dict; // Owned by value
381 bool success = value->GetAsDictionary(&dict); 386 bool success = value->GetAsDictionary(&dict);
382 DCHECK(success); 387 DCHECK(success);
(...skipping 14 matching lines...) Expand all
397 } 402 }
398 403
399 bool ChromeSSLHostStateDelegate::DidHostRunInsecureContent( 404 bool ChromeSSLHostStateDelegate::DidHostRunInsecureContent(
400 const std::string& host, 405 const std::string& host,
401 int pid) const { 406 int pid) const {
402 return !!ran_insecure_content_hosts_.count(BrokenHostEntry(host, pid)); 407 return !!ran_insecure_content_hosts_.count(BrokenHostEntry(host, pid));
403 } 408 }
404 void ChromeSSLHostStateDelegate::SetClock(scoped_ptr<base::Clock> clock) { 409 void ChromeSSLHostStateDelegate::SetClock(scoped_ptr<base::Clock> clock) {
405 clock_.reset(clock.release()); 410 clock_.reset(clock.release());
406 } 411 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/chrome_signin_client.cc ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698