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

Side by Side Diff: chrome/browser/ui/webui/net_internals/net_internals_ui.cc

Issue 9415040: Refactor TransportSecurityState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | 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/ui/webui/net_internals/net_internals_ui.h" 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 992
993 if (!IsStringASCII(domain)) { 993 if (!IsStringASCII(domain)) {
994 result->SetString("error", "non-ASCII domain name"); 994 result->SetString("error", "non-ASCII domain name");
995 } else { 995 } else {
996 net::TransportSecurityState* transport_security_state = 996 net::TransportSecurityState* transport_security_state =
997 context_getter_->GetURLRequestContext()->transport_security_state(); 997 context_getter_->GetURLRequestContext()->transport_security_state();
998 if (!transport_security_state) { 998 if (!transport_security_state) {
999 result->SetString("error", "no TransportSecurityState active"); 999 result->SetString("error", "no TransportSecurityState active");
1000 } else { 1000 } else {
1001 net::TransportSecurityState::DomainState state; 1001 net::TransportSecurityState::DomainState state;
1002 const bool found = transport_security_state->HasMetadata( 1002 const bool found = transport_security_state->GetDomainState(
1003 &state, domain, true); 1003 domain, true, &state);
1004 1004
1005 result->SetBoolean("result", found); 1005 result->SetBoolean("result", found);
1006 if (found) { 1006 if (found) {
1007 result->SetInteger("mode", static_cast<int>(state.mode)); 1007 result->SetInteger("mode", static_cast<int>(state.upgrade_mode));
1008 result->SetBoolean("subdomains", state.include_subdomains); 1008 result->SetBoolean("subdomains", state.include_subdomains);
1009 result->SetBoolean("preloaded", state.preloaded); 1009 // TODO(palmer): result->SetBoolean("preloaded", state.preloaded);
eroman 2012/03/23 21:34:29 Please add a bug association.
palmer 2012/03/23 22:49:04 Actually I got rid of the TODO, it was a previous
1010 result->SetString("domain", state.domain); 1010 result->SetString("domain", state.domain);
1011 result->SetDouble("expiry", state.expiry.ToDoubleT()); 1011 result->SetDouble("expiry", state.upgrade_expiry.ToDoubleT());
1012 result->SetDouble("dynamic_spki_hashes_expiry", 1012 result->SetDouble("dynamic_spki_hashes_expiry",
1013 state.dynamic_spki_hashes_expiry.ToDoubleT()); 1013 state.dynamic_spki_hashes_expiry.ToDoubleT());
1014 1014
1015 std::string hashes; 1015 std::string hashes;
1016 SPKIHashesToString(state.preloaded_spki_hashes, &hashes); 1016 SPKIHashesToString(state.static_spki_hashes, &hashes);
1017 result->SetString("preloaded_spki_hashes", hashes); 1017 result->SetString("preloaded_spki_hashes", hashes);
eroman 2012/03/23 21:34:29 Consider renaming it in the javascript too for con
palmer 2012/03/23 22:49:04 Done.
1018 1018
1019 hashes.clear(); 1019 hashes.clear();
1020 SPKIHashesToString(state.dynamic_spki_hashes, &hashes); 1020 SPKIHashesToString(state.dynamic_spki_hashes, &hashes);
1021 result->SetString("dynamic_spki_hashes", hashes); 1021 result->SetString("dynamic_spki_hashes", hashes);
1022 } 1022 }
1023 } 1023 }
1024 } 1024 }
1025 1025
1026 SendJavascriptCommand("receivedHSTSResult", result); 1026 SendJavascriptCommand("receivedHSTSResult", result);
1027 } 1027 }
(...skipping 12 matching lines...) Expand all
1040 CHECK(list->GetBoolean(1, &include_subdomains)); 1040 CHECK(list->GetBoolean(1, &include_subdomains));
1041 std::string hashes_str; 1041 std::string hashes_str;
1042 CHECK(list->GetString(2, &hashes_str)); 1042 CHECK(list->GetString(2, &hashes_str));
1043 1043
1044 net::TransportSecurityState* transport_security_state = 1044 net::TransportSecurityState* transport_security_state =
1045 context_getter_->GetURLRequestContext()->transport_security_state(); 1045 context_getter_->GetURLRequestContext()->transport_security_state();
1046 if (!transport_security_state) 1046 if (!transport_security_state)
1047 return; 1047 return;
1048 1048
1049 net::TransportSecurityState::DomainState state; 1049 net::TransportSecurityState::DomainState state;
1050 state.expiry = state.created + base::TimeDelta::FromDays(1000); 1050 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000);
1051 state.include_subdomains = include_subdomains; 1051 state.include_subdomains = include_subdomains;
1052 if (!hashes_str.empty()) { 1052 if (!hashes_str.empty()) {
1053 std::vector<std::string> type_and_b64s; 1053 std::vector<std::string> type_and_b64s;
1054 base::SplitString(hashes_str, ',', &type_and_b64s); 1054 base::SplitString(hashes_str, ',', &type_and_b64s);
1055 for (std::vector<std::string>::const_iterator 1055 for (std::vector<std::string>::const_iterator
1056 i = type_and_b64s.begin(); i != type_and_b64s.end(); i++) { 1056 i = type_and_b64s.begin(); i != type_and_b64s.end(); i++) {
1057 std::string type_and_b64; 1057 std::string type_and_b64;
1058 RemoveChars(*i, " \t\r\n", &type_and_b64); 1058 RemoveChars(*i, " \t\r\n", &type_and_b64);
1059 net::SHA1Fingerprint hash; 1059 net::SHA1Fingerprint hash;
1060 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) 1060 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash))
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 1582
1583 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) 1583 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui)
1584 : WebUIController(web_ui) { 1584 : WebUIController(web_ui) {
1585 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); 1585 web_ui->AddMessageHandler(new NetInternalsMessageHandler());
1586 1586
1587 // Set up the chrome://net-internals/ source. 1587 // Set up the chrome://net-internals/ source.
1588 Profile* profile = Profile::FromWebUI(web_ui); 1588 Profile* profile = Profile::FromWebUI(web_ui);
1589 profile->GetChromeURLDataManager()->AddDataSource( 1589 profile->GetChromeURLDataManager()->AddDataSource(
1590 CreateNetInternalsHTMLSource()); 1590 CreateNetInternalsHTMLSource());
1591 } 1591 }
OLDNEW
« no previous file with comments | « chrome/browser/transport_security_persister_unittest.cc ('k') | net/base/transport_security_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698