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

Side by Side Diff: ios/chrome/browser/ssl/ios_chrome_security_state_model_client.mm

Issue 2448943002: Refactor SecurityStateModel/Clients for simplicity and reusability. (Closed)
Patch Set: update comments. Created 4 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/ssl/ios_chrome_security_state_model_client.h"
6
7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram_macros.h"
10 #include "ios/web/public/navigation_item.h"
11 #import "ios/web/public/navigation_manager.h"
12 #import "ios/web/public/origin_util.h"
13 #include "ios/web/public/security_style.h"
14 #include "ios/web/public/ssl_status.h"
15 #include "ios/web/public/web_state/web_state.h"
16 #include "net/cert/x509_certificate.h"
17
18 DEFINE_WEB_STATE_USER_DATA_KEY(IOSChromeSecurityStateModelClient);
19
20 IOSChromeSecurityStateModelClient::IOSChromeSecurityStateModelClient(
21 web::WebState* web_state)
22 : web_state_(web_state),
23 security_state_model_(new security_state::SecurityStateModel()) {
24 security_state_model_->SetClient(this);
25 }
26
27 IOSChromeSecurityStateModelClient::~IOSChromeSecurityStateModelClient() {}
28
29 void IOSChromeSecurityStateModelClient::GetSecurityInfo(
30 security_state::SecurityStateModel::SecurityInfo* result) const {
31 return security_state_model_->GetSecurityInfo(result);
32 }
33
34 bool IOSChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() {
35 return false;
36 }
37
38 bool IOSChromeSecurityStateModelClient::IsOriginSecure(const GURL& url) {
39 return web::IsOriginSecure(url);
40 }
41
42 void IOSChromeSecurityStateModelClient::GetVisibleSecurityState(
43 security_state::SecurityStateModel::VisibleSecurityState* state) {
44 web::NavigationItem* item =
45 web_state_->GetNavigationManager()->GetVisibleItem();
46 if (!item || item->GetSSL().security_style == web::SECURITY_STYLE_UNKNOWN) {
47 *state = security_state::SecurityStateModel::VisibleSecurityState();
48 return;
49 }
50
51 state->connection_info_initialized = true;
52 state->url = item->GetURL();
53 const web::SSLStatus& ssl = item->GetSSL();
54 state->certificate = ssl.certificate;
55 state->cert_status = ssl.cert_status;
56 state->connection_status = ssl.connection_status;
57 state->security_bits = ssl.security_bits;
58 state->displayed_mixed_content =
59 (ssl.content_status & web::SSLStatus::DISPLAYED_INSECURE_CONTENT) ? true
60 : false;
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698