summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-19 15:42:20 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-19 15:42:20 +0000
commiteb34392be36ea2948f39bd22a6beae19e0b0bd24 (patch)
treeb5b4e701a3c0e01cc4a2be2ac8c2b798c472cab6 /chrome/browser
parentd499ed582b58cf676becdc97ca7280861a9483b0 (diff)
downloadchromium_src-eb34392be36ea2948f39bd22a6beae19e0b0bd24.zip
chromium_src-eb34392be36ea2948f39bd22a6beae19e0b0bd24.tar.gz
chromium_src-eb34392be36ea2948f39bd22a6beae19e0b0bd24.tar.bz2
Factor the SSL state out of the main NavigationEntry into a helper class. This
makes it easier to find stuff and also copy ssl state (just assign). I made one "real" change in web_contents where I copy the entire SSL state now to the new entry rather than just a few fields like the old one. I couldn't figure out why this was necessary: running it shows that this leaves the other two fields in the uninitialized state which seems wrong. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/automation_provider.cc4
-rw-r--r--chrome/browser/navigation_controller.cc6
-rw-r--r--chrome/browser/navigation_controller.h2
-rw-r--r--chrome/browser/navigation_controller_base.cc10
-rw-r--r--chrome/browser/navigation_controller_base.h3
-rw-r--r--chrome/browser/navigation_entry.cc34
-rw-r--r--chrome/browser/navigation_entry.h145
-rw-r--r--chrome/browser/page_info_window.cc23
-rw-r--r--chrome/browser/ssl_blocking_page.cc9
-rw-r--r--chrome/browser/ssl_manager.cc26
-rw-r--r--chrome/browser/ssl_policy.cc11
-rw-r--r--chrome/browser/ssl_uitest.cc34
-rw-r--r--chrome/browser/tab_contents.cc8
-rw-r--r--chrome/browser/toolbar_model.cc35
-rw-r--r--chrome/browser/web_contents.cc12
15 files changed, 187 insertions, 175 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 1bae14d..db3f630 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -2002,8 +2002,8 @@ void AutomationProvider::GetSecurityState(const IPC::Message& message,
NavigationController* tab = tab_tracker_->GetResource(handle);
NavigationEntry* entry = tab->GetActiveEntry();
Send(new AutomationMsg_GetSecurityStateResponse(message.routing_id(), true,
- entry->GetSecurityStyle(), entry->GetSSLCertStatus(),
- entry->GetContentStatus()));
+ entry->ssl().security_style(), entry->ssl().cert_status(),
+ entry->ssl().content_status()));
} else {
Send(new AutomationMsg_GetSecurityStateResponse(message.routing_id(), false,
SECURITY_STYLE_UNKNOWN,
diff --git a/chrome/browser/navigation_controller.cc b/chrome/browser/navigation_controller.cc
index ac4392f..91b404a4 100644
--- a/chrome/browser/navigation_controller.cc
+++ b/chrome/browser/navigation_controller.cc
@@ -190,11 +190,11 @@ TabContents* NavigationController::GetTabContents(TabContentsType t) {
return tab_contents_map_[t];
}
-void NavigationController::Reset() {
+/*void NavigationController::Reset() {
NavigationControllerBase::Reset();
NotifyPrunedEntries();
-}
+}*/
void NavigationController::Reload() {
// TODO(pkasting): http://b/1113085 Should this use DiscardPendingEntry()?
@@ -455,7 +455,7 @@ void NavigationController::NavigateToPendingEntry(bool reload) {
// Reset the security states as any SSL error may have been resolved since we
// last visited that page.
- pending_entry_->ResetSSLStates();
+ pending_entry_->ssl() = NavigationEntry::SSLStatus();
if (from_contents && from_contents->type() != pending_entry_->GetType())
from_contents->SetActive(false);
diff --git a/chrome/browser/navigation_controller.h b/chrome/browser/navigation_controller.h
index 070abfa..136540e 100644
--- a/chrome/browser/navigation_controller.h
+++ b/chrome/browser/navigation_controller.h
@@ -83,8 +83,6 @@ class NavigationController : public NavigationControllerBase {
HWND parent);
~NavigationController();
- virtual void Reset();
-
// Overriden to prompt the user if reloading a URL with POST data and the
// active WebContents isn't showing the POST interstitial page.
virtual void Reload();
diff --git a/chrome/browser/navigation_controller_base.cc b/chrome/browser/navigation_controller_base.cc
index f34876d..f2b921d 100644
--- a/chrome/browser/navigation_controller_base.cc
+++ b/chrome/browser/navigation_controller_base.cc
@@ -47,14 +47,14 @@ NavigationControllerBase::NavigationControllerBase()
NavigationControllerBase::~NavigationControllerBase() {
// NOTE: This does NOT invoke Reset as Reset is virtual.
- ResetInternal();
+ //ResetInternal();
}
-void NavigationControllerBase::Reset() {
+/*void NavigationControllerBase::Reset() {
ResetInternal();
last_committed_entry_index_ = -1;
-}
+}*/
NavigationEntry* NavigationControllerBase::GetActiveEntry() const {
NavigationEntry* entry = pending_entry_;
@@ -274,9 +274,11 @@ void NavigationControllerBase::DidNavigateToEntry(NavigationEntry* entry) {
existing_entry->SetFavIconURL(entry->GetFavIconURL());
existing_entry->SetFavIcon(entry->GetFavIcon());
existing_entry->SetValidFavIcon(entry->IsValidFavIcon());
- existing_entry->SetSecurityStyle(entry->GetSecurityStyle());
existing_entry->SetContentState(entry->GetContentState());
+ // TODO(brettw) why only copy the security style and no other SSL stuff?
+ existing_entry->ssl().set_security_style(entry->ssl().security_style());
+
const int prev_entry_index = last_committed_entry_index_;
if (existing_entry == pending_entry_) {
DCHECK(pending_entry_index_ != -1);
diff --git a/chrome/browser/navigation_controller_base.h b/chrome/browser/navigation_controller_base.h
index 6b33a58..e712ff3 100644
--- a/chrome/browser/navigation_controller_base.h
+++ b/chrome/browser/navigation_controller_base.h
@@ -51,9 +51,6 @@ class NavigationControllerBase {
NavigationControllerBase();
virtual ~NavigationControllerBase();
- // Empties the history list.
- virtual void Reset();
-
// Returns the active entry, which is the pending entry if a navigation is in
// progress or the last committed entry otherwise. NOTE: This can be NULL!!
//
diff --git a/chrome/browser/navigation_entry.cc b/chrome/browser/navigation_entry.cc
index 89756e9..8c9e0f1 100644
--- a/chrome/browser/navigation_entry.cc
+++ b/chrome/browser/navigation_entry.cc
@@ -33,18 +33,21 @@
int NavigationEntry::unique_id_counter_ = 0;
+NavigationEntry::SSLStatus::SSLStatus()
+ : security_style_(SECURITY_STYLE_UNKNOWN),
+ cert_id_(0),
+ cert_status_(0),
+ security_bits_(-1),
+ content_status_(NORMAL_CONTENT) {
+}
+
NavigationEntry::NavigationEntry(TabContentsType type)
: type_(type),
unique_id_(GetUniqueID()),
site_instance_(NULL),
page_id_(-1),
- security_style_(SECURITY_STYLE_UNKNOWN),
transition_type_(PageTransition::LINK),
page_type_(NORMAL_PAGE),
- ssl_cert_id_(0),
- ssl_cert_status_(0),
- ssl_security_bits_(0),
- content_status_(NORMAL_CONTENT),
valid_fav_icon_(false),
has_post_data_(false),
restored_(false) {
@@ -63,14 +66,9 @@ NavigationEntry::NavigationEntry(TabContentsType type,
site_instance_(instance),
page_id_(page_id),
url_(url),
- security_style_(SECURITY_STYLE_UNKNOWN),
title_(title),
transition_type_(transition_type),
page_type_(NORMAL_PAGE),
- ssl_cert_id_(0),
- ssl_cert_status_(0),
- ssl_security_bits_(-1),
- content_status_(NORMAL_CONTENT),
valid_fav_icon_(false),
has_post_data_(false),
restored_(false) {
@@ -97,22 +95,6 @@ void NavigationEntry::SetContentState(const std::string& state) {
state_ = state;
}
-void NavigationEntry::CopySSLInfoFrom(const NavigationEntry& entry) {
- security_style_ = entry.security_style_;
- content_status_ = entry.content_status_;
- ssl_cert_id_ = entry.ssl_cert_id_;
- ssl_cert_status_ = entry.ssl_cert_status_;
- ssl_security_bits_ = entry.ssl_security_bits_;
-}
-
-void NavigationEntry::ResetSSLStates() {
- ssl_cert_id_ = 0;
- ssl_cert_status_ = 0;
- ssl_security_bits_ = -1;
- security_style_ = SECURITY_STYLE_UNKNOWN;
- content_status_ = NORMAL_CONTENT;
-}
-
int NavigationEntry::GetUniqueID() {
// Never return 0, as that is the "no ID" value.
do {
diff --git a/chrome/browser/navigation_entry.h b/chrome/browser/navigation_entry.h
index 222daf4..fa6d013 100644
--- a/chrome/browser/navigation_entry.h
+++ b/chrome/browser/navigation_entry.h
@@ -52,6 +52,84 @@
////////////////////////////////////////////////////////////////////////////////
class NavigationEntry {
public:
+ // Collects the SSL information for this NavigationEntry.
+ class SSLStatus {
+ public:
+ // Flags used for the page security content status.
+ enum ContentStatusFlags {
+ NORMAL_CONTENT = 0, // Neither of the 2 cases below.
+ MIXED_CONTENT = 1 << 0, // https page containing http resources.
+ UNSAFE_CONTENT = 1 << 1 // https page containing broken https resources.
+ };
+
+ SSLStatus();
+
+ void set_security_style(SecurityStyle security_style) {
+ security_style_ = security_style;
+ }
+ SecurityStyle security_style() const {
+ return security_style_;
+ }
+
+ void set_cert_id(int ssl_cert_id) {
+ cert_id_ = ssl_cert_id;
+ }
+ int cert_id() const {
+ return cert_id_;
+ }
+
+ void set_cert_status(int ssl_cert_status) {
+ cert_status_ = ssl_cert_status;
+ }
+ int cert_status() const {
+ return cert_status_;
+ }
+
+ void set_security_bits(int security_bits) {
+ security_bits_ = security_bits;
+ }
+ int security_bits() const {
+ return security_bits_;
+ }
+
+ // Mixed content means that this page which is served over https contains
+ // http sub-resources.
+ void set_has_mixed_content() {
+ content_status_ |= MIXED_CONTENT;
+ }
+ bool has_mixed_content() const {
+ return (content_status_ & MIXED_CONTENT) != 0;
+ }
+
+ // Unsafe content means that this page is served over https but contains
+ // https sub-resources with cert errors.
+ void set_has_unsafe_content() {
+ content_status_ |= UNSAFE_CONTENT;
+ }
+ bool has_unsafe_content() const {
+ return (content_status_ & UNSAFE_CONTENT) != 0;
+ }
+
+ // Raw accessors for all the content status flags. This is used by the UI
+ // tests for checking and for certain copying. Use the per-status functions
+ // for normal usage.
+ void set_content_status(int content_status) {
+ content_status_ = content_status;
+ }
+ int content_status() const {
+ return content_status_;
+ }
+
+ private:
+ SecurityStyle security_style_;
+ int cert_id_;
+ int cert_status_;
+ int security_bits_;
+ int content_status_; // A combination of any of the ContentStatusFlags.
+
+ // Copy and assignment is explicitly allowed for this class.
+ };
+
// The type of the page an entry corresponds to. Used by ui tests.
enum PageType {
NORMAL_PAGE = 0,
@@ -59,13 +137,6 @@ class NavigationEntry {
INTERSTITIAL_PAGE
};
- // Flags used for the page security content status.
- enum {
- NORMAL_CONTENT = 0, // neither of the 2 cases below.
- MIXED_CONTENT = 1 << 0, // https page containing http resources.
- UNSAFE_CONTENT = 1 << 1 // https page containing broken https resources.
- };
-
// Use this to get a new unique ID during construction.
static int GetUniqueID();
@@ -99,11 +170,13 @@ class NavigationEntry {
void SetURL(const GURL& url) { url_ = url; }
const GURL& GetURL() const { return url_; }
- // Set / Get the security style.
- void SetSecurityStyle(SecurityStyle security_style) {
- security_style_ = security_style;
+ // All the SSL flags.
+ const SSLStatus& ssl() const {
+ return ssl_;
+ }
+ SSLStatus& ssl() {
+ return ssl_;
}
- SecurityStyle GetSecurityStyle() const { return security_style_; }
// Set / Get the page type.
void SetPageType(PageType page_type) { page_type_ = page_type; }
@@ -169,46 +242,6 @@ class NavigationEntry {
return user_typed_url_.is_valid() ? user_typed_url_ : url_;
}
- void SetSSLCertID(int ssl_cert_id) { ssl_cert_id_ = ssl_cert_id; }
- int GetSSLCertID() const { return ssl_cert_id_; }
-
- void SetSSLCertStatus(int ssl_cert_status) {
- ssl_cert_status_ = ssl_cert_status;
- }
- int GetSSLCertStatus() const { return ssl_cert_status_; }
-
- void SetSSLSecurityBits(int security_bits) {
- ssl_security_bits_ = security_bits;
- }
- int GetSSLSecurityBits() const { return ssl_security_bits_; }
-
- // Whether this page which is served over https contains http sub-resources.
- void SetHasMixedContent() {
- content_status_ |= MIXED_CONTENT;
- }
- bool HasMixedContent() const {
- return (content_status_ & MIXED_CONTENT) == MIXED_CONTENT;
- }
-
- // Whether this page which is served over https contains https sub-resources
- // with cert errors.
- void SetHasUnsafeContent() {
- content_status_ |= UNSAFE_CONTENT;
- }
- bool HasUnsafeContent() const {
- return (content_status_ & UNSAFE_CONTENT) == UNSAFE_CONTENT;
- }
-
- // Copies all the security states (security style, SSL info -cert id, status
- // and bits-, mixed/unsafe content status) in this entry from the specified
- // |entry|.
- void CopySSLInfoFrom(const NavigationEntry& entry);
-
- // Used by UI tests.
- int GetContentStatus() const { return content_status_; }
-
- void ResetSSLStates();
-
bool HasPostData() const { return has_post_data_; }
void SetHasPostData(bool has_post_data) { has_post_data_ = has_post_data; }
@@ -247,18 +280,10 @@ class NavigationEntry {
GURL url_;
// The URL the user typed in. May be invalid.
GURL user_typed_url_;
- SecurityStyle security_style_;
std::wstring title_;
GURL favicon_url_;
GURL display_url_;
- // SSL related info.
- int ssl_cert_id_;
- int ssl_cert_status_;
- int ssl_security_bits_;
-
- int content_status_;
-
std::string state_;
// The favorite icon for this entry.
@@ -266,6 +291,8 @@ class NavigationEntry {
PageType page_type_;
+ SSLStatus ssl_;
+
bool valid_fav_icon_;
// True if this navigation needs to send post data in order to be displayed
diff --git a/chrome/browser/page_info_window.cc b/chrome/browser/page_info_window.cc
index 475dfbe..b27f2ba 100644
--- a/chrome/browser/page_info_window.cc
+++ b/chrome/browser/page_info_window.cc
@@ -255,8 +255,7 @@ SecurityTabView::SecurityTabView(Profile* profile,
std::wstring identity_msg;
std::wstring connection_msg;
scoped_refptr<net::X509Certificate> cert;
- int cert_id = navigation_entry->GetSSLCertID();
- int cert_status = navigation_entry->GetSSLCertStatus();
+ const NavigationEntry::SSLStatus& ssl = navigation_entry->ssl();
// Identity section.
std::wstring subject_name(UTF8ToWide(navigation_entry->GetURL().host()));
@@ -267,10 +266,11 @@ SecurityTabView::SecurityTabView(Profile* profile,
empty_subject_name = true;
}
if (navigation_entry->GetPageType() == NavigationEntry::NORMAL_PAGE &&
- cert_id && CertStore::GetSharedInstance()->RetrieveCert(cert_id, &cert) &&
- !net::IsCertStatusError(cert_status)) {
+ ssl.cert_id() &&
+ CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), &cert) &&
+ !net::IsCertStatusError(ssl.cert_status())) {
// OK HTTPS page.
- if ((cert_status & net::CERT_STATUS_IS_EV) != 0) {
+ if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) != 0) {
DCHECK(!cert->subject().organization_names.empty());
identity_title =
l10n_util::GetStringF(IDS_PAGE_INFO_EV_IDENTITY_TITLE,
@@ -326,14 +326,13 @@ SecurityTabView::SecurityTabView(Profile* profile,
// We consider anything less than 80 bits encryption to be weak encryption.
// TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
// weakly encrypted connections.
- int security_bits = navigation_entry->GetSSLSecurityBits();
- if (security_bits <= 0) {
+ if (ssl.security_bits() <= 0) {
connection_ok = false;
connection_msg.assign(
l10n_util::GetStringF(
IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
subject_name));
- } else if (security_bits < 80) {
+ } else if (ssl.security_bits() < 80) {
connection_ok = false;
connection_msg.assign(
l10n_util::GetStringF(
@@ -344,8 +343,8 @@ SecurityTabView::SecurityTabView(Profile* profile,
l10n_util::GetStringF(
IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
subject_name,
- IntToWString(security_bits)));
- if (navigation_entry->HasMixedContent()) {
+ IntToWString(ssl.security_bits())));
+ if (ssl.has_mixed_content()) {
connection_ok = false;
connection_msg.assign(
l10n_util::GetStringF(
@@ -353,7 +352,7 @@ SecurityTabView::SecurityTabView(Profile* profile,
connection_msg,
l10n_util::GetString(
IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_MIXED_CONTENT_WARNING)));
- } else if (navigation_entry->HasUnsafeContent()) {
+ } else if (ssl.has_unsafe_content()) {
connection_ok = false;
connection_msg.assign(
l10n_util::GetStringF(
@@ -521,7 +520,7 @@ PageInfoWindow::~PageInfoWindow() {
void PageInfoWindow::Init(Profile* profile,
NavigationEntry* navigation_entry,
HWND parent) {
- cert_id_ = navigation_entry->GetSSLCertID();
+ cert_id_ = navigation_entry->ssl().cert_id();
cert_info_button_ = new ChromeViews::NativeButton(
l10n_util::GetString(IDS_PAGEINFO_CERT_INFO_BUTTON));
diff --git a/chrome/browser/ssl_blocking_page.cc b/chrome/browser/ssl_blocking_page.cc
index bd99b30..3a29533 100644
--- a/chrome/browser/ssl_blocking_page.cc
+++ b/chrome/browser/ssl_blocking_page.cc
@@ -172,10 +172,11 @@ void SSLBlockingPage::Show() {
*nav_entry = *(tab_->controller()->GetPendingEntry());
}
nav_entry->SetPageType(NavigationEntry::INTERSTITIAL_PAGE);
- nav_entry->SetSecurityStyle(SECURITY_STYLE_AUTHENTICATION_BROKEN);
- nav_entry->SetSSLCertID(cert_id);
- nav_entry->SetSSLCertStatus(ssl_info.cert_status);
- nav_entry->SetSSLSecurityBits(ssl_info.security_bits);
+
+ nav_entry->ssl().set_security_style(SECURITY_STYLE_AUTHENTICATION_BROKEN);
+ nav_entry->ssl().set_cert_id(cert_id);
+ nav_entry->ssl().set_cert_status(ssl_info.cert_status);
+ nav_entry->ssl().set_security_bits(ssl_info.security_bits);
// The controller will own the entry.
int page_id = nav_entry->GetPageID();
tab_->controller()->DidNavigateToEntry(nav_entry);
diff --git a/chrome/browser/ssl_manager.cc b/chrome/browser/ssl_manager.cc
index 0e9b16a..be58f24 100644
--- a/chrome/browser/ssl_manager.cc
+++ b/chrome/browser/ssl_manager.cc
@@ -213,7 +213,7 @@ void SSLManager::ShowMessageWithLink(const std::wstring& msg,
return;
// Don't show the message if the user doesn't expect an authenticated session.
- if (entry->GetSecurityStyle() <= SECURITY_STYLE_UNAUTHENTICATED)
+ if (entry->ssl().security_style() <= SECURITY_STYLE_UNAUTHENTICATED)
return;
InfoBarView* info_bar_view =
@@ -247,8 +247,8 @@ void SSLManager::SetMaxSecurityStyle(SecurityStyle style) {
return;
}
- if (entry->GetSecurityStyle() > style) {
- entry->SetSecurityStyle(style);
+ if (entry->ssl().security_style() > style) {
+ entry->ssl().set_security_style(style);
controller_->EntryUpdated(entry);
}
}
@@ -261,7 +261,7 @@ void SSLManager::AddMessageToConsole(const std::wstring& msg,
if (!web_contents)
return;
- web_contents->AddMessageToConsole(L"", msg, level);
+ web_contents->AddMessageToConsole(std::wstring(), msg, level);
}
@@ -310,7 +310,7 @@ bool SSLManager::ProcessedSSLErrorFromRequest() const {
return false;
}
- return net::IsCertStatusError(entry->GetSSLCertStatus());
+ return net::IsCertStatusError(entry->ssl().cert_status());
}
////////////////////////////////////////////////////////////////////////////////
@@ -603,8 +603,10 @@ void SSLManager::InitializeEntryIfNeeded(NavigationEntry* entry) {
// If the security style of the entry is SECURITY_STYLE_UNKNOWN, then it is a
// fresh entry and should get the default style.
- if (entry->GetSecurityStyle() == SECURITY_STYLE_UNKNOWN)
- entry->SetSecurityStyle(delegate()->GetDefaultStyle(entry->GetURL()));
+ if (entry->ssl().security_style() == SECURITY_STYLE_UNKNOWN) {
+ entry->ssl().set_security_style(
+ delegate()->GetDefaultStyle(entry->GetURL()));
+ }
}
void SSLManager::NavigationStateChanged() {
@@ -648,11 +650,11 @@ void SSLManager::DidCommitProvisionalLoad(ProvisionalLoadDetails* details) {
NavigationEntry* entry = controller_->GetActiveEntry();
if (entry) {
// We may not have an entry if this is a navigation to an initial blank
- // page.
- entry->ResetSSLStates(); // Clears mixed/unsafe content state.
- entry->SetSSLCertID(details->ssl_cert_id());
- entry->SetSSLCertStatus(details->ssl_cert_status());
- entry->SetSSLSecurityBits(details->ssl_security_bits());
+ // page. Reset the SSL information and add the new data we have.
+ entry->ssl() = NavigationEntry::SSLStatus();
+ entry->ssl().set_cert_id(details->ssl_cert_id());
+ entry->ssl().set_cert_status(details->ssl_cert_status());
+ entry->ssl().set_security_bits(details->ssl_security_bits());
controller_->EntryUpdated(entry);
}
diff --git a/chrome/browser/ssl_policy.cc b/chrome/browser/ssl_policy.cc
index 1ae9ae1..dd83357 100644
--- a/chrome/browser/ssl_policy.cc
+++ b/chrome/browser/ssl_policy.cc
@@ -345,7 +345,7 @@ class DefaultPolicy : public SSLPolicy {
mixed_content_handler->StartRequest(filter_policy);
NavigationEntry* entry = navigation_controller->GetActiveEntry();
- entry->SetHasMixedContent();
+ entry->ssl().set_has_mixed_content();
navigation_controller->EntryUpdated(entry);
}
@@ -409,9 +409,10 @@ void SSLPolicy::OnRequestStarted(SSLManager* manager, const GURL& url,
return;
}
+ NavigationEntry::SSLStatus& ssl = entry->ssl();
if (!entry->GetURL().SchemeIsSecure() || // Current page is not secure.
resource_type == ResourceType::MAIN_FRAME || // Main frame load.
- net::IsCertStatusError(entry->GetSSLCertStatus())) { // There is already
+ net::IsCertStatusError(ssl.cert_status())) { // There is already
// an error for the main page, don't report sub-resources as unsafe
// content.
// No mixed/unsafe content check necessary.
@@ -428,8 +429,8 @@ void SSLPolicy::OnRequestStarted(SSLManager* manager, const GURL& url,
// net::IsCertStatusError(ssl_cert_status)) {
if (net::IsCertStatusError(ssl_cert_status)) {
// The resource is unsafe.
- if (!entry->HasUnsafeContent()) {
- entry->SetHasUnsafeContent();
+ if (!ssl.has_unsafe_content()) {
+ ssl.set_has_unsafe_content();
manager->SetMaxSecurityStyle(SECURITY_STYLE_AUTHENTICATION_BROKEN);
}
}
@@ -443,7 +444,7 @@ void SSLPolicy::OnRequestStarted(SSLManager* manager, const GURL& url,
// Now check for mixed content.
if (entry->GetURL().SchemeIsSecure() && !url.SchemeIsSecure()) {
- entry->SetHasMixedContent();
+ ssl.set_has_mixed_content();
const std::wstring& msg = l10n_util::GetStringF(
IDS_MIXED_CONTENT_LOG_MESSAGE,
UTF8ToWide(entry->GetURL().spec()),
diff --git a/chrome/browser/ssl_uitest.cc b/chrome/browser/ssl_uitest.cc
index 01d38c0..43a9c3c 100644
--- a/chrome/browser/ssl_uitest.cc
+++ b/chrome/browser/ssl_uitest.cc
@@ -142,7 +142,7 @@ TEST_F(SSLUITest, TestHTTP) {
&mixed_content_state));
EXPECT_EQ(SECURITY_STYLE_UNAUTHENTICATED, security_style);
EXPECT_EQ(0, cert_status);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
}
// Visits a page over http which includes broken https resources (status should
@@ -163,7 +163,7 @@ TEST_F(SSLUITest, TestHTTPWithBrokenHTTPSResource) {
&mixed_content_state));
EXPECT_EQ(SECURITY_STYLE_UNAUTHENTICATED, security_style);
EXPECT_EQ(0, cert_status);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
}
// Visits a page over OK https:
@@ -185,7 +185,7 @@ TEST_F(SSLUITest, TestOKHTTPS) {
&mixed_content_state));
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
EXPECT_EQ(0, cert_status & net::CERT_STATUS_ALL_ERRORS);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
}
// Visits a page with https error:
@@ -208,7 +208,7 @@ TEST_F(SSLUITest, TestHTTPSExpiredCert) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, security_style);
EXPECT_EQ(net::CERT_STATUS_DATE_INVALID,
cert_status & net::CERT_STATUS_ALL_ERRORS);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
EXPECT_TRUE(tab->TakeActionOnSSLBlockingPage(true));
EXPECT_TRUE(tab->GetPageType(&page_type));
@@ -218,7 +218,7 @@ TEST_F(SSLUITest, TestHTTPSExpiredCert) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, security_style);
EXPECT_EQ(net::CERT_STATUS_DATE_INVALID,
cert_status & net::CERT_STATUS_ALL_ERRORS);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
}
//
@@ -246,7 +246,7 @@ TEST_F(SSLUITest, TestMixedContents) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
EXPECT_EQ(0,
cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
- EXPECT_EQ(NavigationEntry::MIXED_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
}
// Visits a page with unsafe content and make sure that:
@@ -276,7 +276,7 @@ TEST_F(SSLUITest, TestUnsafeContents) {
EXPECT_EQ(SECURITY_STYLE_UNAUTHENTICATED, security_style);
EXPECT_EQ(0,
cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
// Because of cross-frame scripting restrictions, we cannot access the iframe
// content. So to know if the frame was loaded, we just check if a popup was
@@ -325,7 +325,7 @@ TEST_F(SSLUITest, TestMixedContentsLoadedFromJS) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
EXPECT_EQ(0,
cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
// Load the insecure image.
bool js_result = false;
@@ -340,7 +340,7 @@ TEST_F(SSLUITest, TestMixedContentsLoadedFromJS) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
EXPECT_EQ(0,
cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
- EXPECT_EQ(NavigationEntry::MIXED_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
}
// Visits a page with an image over http. Visits another page over https
@@ -366,7 +366,7 @@ TEST_F(SSLUITest, TestCachedMixedContents) {
EXPECT_EQ(SECURITY_STYLE_UNAUTHENTICATED, security_style);
EXPECT_EQ(0,
cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
// Load again but over SSL. It should have mixed-contents (even though the
// image comes from the WebCore memory cache).
@@ -380,7 +380,7 @@ TEST_F(SSLUITest, TestCachedMixedContents) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
EXPECT_EQ(0,
cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
- EXPECT_EQ(NavigationEntry::MIXED_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
}
// This test ensures the CN invalid status does not 'stick' to a certificate
@@ -410,7 +410,7 @@ TEST_F(SSLUITest, DISABLED_TestCNInvalidStickiness) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, security_style);
EXPECT_EQ(net::CERT_STATUS_COMMON_NAME_INVALID,
cert_status & net::CERT_STATUS_ALL_ERRORS);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
// We proceed through the interstitial page.
EXPECT_TRUE(tab->TakeActionOnSSLBlockingPage(true));
@@ -436,7 +436,7 @@ TEST_F(SSLUITest, DISABLED_TestCNInvalidStickiness) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
EXPECT_EQ(0,
cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
// Now try again the broken one to make sure it is still broken.
NavigateTab(tab.get(), https_server.TestServerPageW(
@@ -450,7 +450,7 @@ TEST_F(SSLUITest, DISABLED_TestCNInvalidStickiness) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, security_style);
EXPECT_EQ(net::CERT_STATUS_COMMON_NAME_INVALID,
cert_status & net::CERT_STATUS_ALL_ERRORS);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
}
// Test that navigating to a #ref does not change a bad security state.
@@ -472,7 +472,7 @@ TEST_F(SSLUITest, TestRefNavigation) {
&mixed_content_state));
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, security_style);
EXPECT_EQ(net::CERT_STATUS_DATE_INVALID, cert_status);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
EXPECT_TRUE(tab->TakeActionOnSSLBlockingPage(true));
EXPECT_TRUE(tab->GetPageType(&page_type));
@@ -482,7 +482,7 @@ TEST_F(SSLUITest, TestRefNavigation) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, security_style);
EXPECT_EQ(net::CERT_STATUS_DATE_INVALID,
cert_status & net::CERT_STATUS_ALL_ERRORS);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
// Now navigate to a ref in the page.
NavigateTab(tab.get(),
@@ -492,7 +492,7 @@ TEST_F(SSLUITest, TestRefNavigation) {
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, security_style);
EXPECT_EQ(net::CERT_STATUS_DATE_INVALID,
cert_status & net::CERT_STATUS_ALL_ERRORS);
- EXPECT_EQ(NavigationEntry::NORMAL_CONTENT, mixed_content_state);
+ EXPECT_EQ(NavigationEntry::SSLStatus::NORMAL_CONTENT, mixed_content_state);
}
// TODO (jcampan): more tests to do below.
diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc
index 62f6fb1..3edd315 100644
--- a/chrome/browser/tab_contents.cc
+++ b/chrome/browser/tab_contents.cc
@@ -152,7 +152,7 @@ SkBitmap TabContents::GetFavIcon() const {
SecurityStyle TabContents::GetSecurityStyle() const {
// We may not have a navigation entry yet.
NavigationEntry* entry = controller_->GetActiveEntry();
- return entry ? entry->GetSecurityStyle() : SECURITY_STYLE_UNKNOWN;
+ return entry ? entry->ssl().security_style() : SECURITY_STYLE_UNKNOWN;
}
bool TabContents::GetSSLEVText(std::wstring* ev_text,
@@ -163,12 +163,12 @@ bool TabContents::GetSSLEVText(std::wstring* ev_text,
NavigationEntry* entry = controller_->GetActiveEntry();
if (!entry ||
- net::IsCertStatusError(entry->GetSSLCertStatus()) ||
- ((entry->GetSSLCertStatus() & net::CERT_STATUS_IS_EV) == 0))
+ net::IsCertStatusError(entry->ssl().cert_status()) ||
+ ((entry->ssl().cert_status() & net::CERT_STATUS_IS_EV) == 0))
return false;
scoped_refptr<net::X509Certificate> cert;
- CertStore::GetSharedInstance()->RetrieveCert(entry->GetSSLCertID(), &cert);
+ CertStore::GetSharedInstance()->RetrieveCert(entry->ssl().cert_id(), &cert);
if (!cert.get()) {
NOTREACHED();
return false;
diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc
index 2e2b1be..090acc6 100644
--- a/chrome/browser/toolbar_model.cc
+++ b/chrome/browser/toolbar_model.cc
@@ -82,9 +82,9 @@ ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() {
if (!entry)
return ToolbarModel::NORMAL;
- switch (entry->GetSecurityStyle()) {
+ switch (entry->ssl().security_style()) {
case SECURITY_STYLE_AUTHENTICATED:
- if (entry->HasMixedContent())
+ if (entry->ssl().has_mixed_content())
return ToolbarModel::NORMAL;
return ToolbarModel::SECURE;
case SECURITY_STYLE_AUTHENTICATION_BROKEN:
@@ -115,9 +115,10 @@ ToolbarModel::Icon ToolbarModel::GetIcon() {
if (!entry)
return ToolbarModel::NO_ICON;
- switch (entry->GetSecurityStyle()) {
+ const NavigationEntry::SSLStatus& ssl = entry->ssl();
+ switch (ssl.security_style()) {
case SECURITY_STYLE_AUTHENTICATED:
- if (entry->HasMixedContent())
+ if (ssl.has_mixed_content())
return ToolbarModel::WARNING_ICON;
return ToolbarModel::LOCK_ICON;
case SECURITY_STYLE_AUTHENTICATION_BROKEN:
@@ -146,16 +147,18 @@ void ToolbarModel::GetIconHoverText(std::wstring* text, SkColor* text_color) {
NavigationEntry* entry = navigation_controller->GetActiveEntry();
DCHECK(entry);
- switch (entry->GetSecurityStyle()) {
+
+ const NavigationEntry::SSLStatus& ssl = entry->ssl();
+ switch (ssl.security_style()) {
case SECURITY_STYLE_AUTHENTICATED: {
- if (entry->HasMixedContent()) {
+ if (ssl.has_mixed_content()) {
SSLErrorInfo error_info =
SSLErrorInfo::CreateError(SSLErrorInfo::MIXED_CONTENTS,
NULL, GURL::EmptyGURL());
text->assign(error_info.short_description());
*text_color = kBrokenHttpsInfoBubbleTextColor;
} else {
- GURL url = entry->GetURL();
+ const GURL& url = entry->GetURL();
DCHECK(url.has_host());
text->assign(l10n_util::GetStringF(IDS_SECURE_CONNECTION,
UTF8ToWide(url.host())));
@@ -196,13 +199,14 @@ void ToolbarModel::GetInfoText(std::wstring* text,
return;
NavigationEntry* entry = navigation_controller->GetActiveEntry();
- if (!entry || entry->HasMixedContent() ||
- net::IsCertStatusError(entry->GetSSLCertStatus()) ||
- ((entry->GetSSLCertStatus() & net::CERT_STATUS_IS_EV) == 0))
+ const NavigationEntry::SSLStatus& ssl = entry->ssl();
+ if (!entry || ssl.has_mixed_content() ||
+ net::IsCertStatusError(ssl.cert_status()) ||
+ ((ssl.cert_status() & net::CERT_STATUS_IS_EV) == 0))
return;
scoped_refptr<net::X509Certificate> cert;
- CertStore::GetSharedInstance()->RetrieveCert(entry->GetSSLCertID(), &cert);
+ CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), &cert);
if (!cert.get()) {
NOTREACHED();
return;
@@ -213,16 +217,17 @@ void ToolbarModel::GetInfoText(std::wstring* text,
}
void ToolbarModel::CreateErrorText(NavigationEntry* entry, std::wstring* text) {
+ const NavigationEntry::SSLStatus& ssl = entry->ssl();
std::vector<SSLErrorInfo> errors;
- SSLErrorInfo::GetErrorsForCertStatus(entry->GetSSLCertID(),
- entry->GetSSLCertStatus(),
+ SSLErrorInfo::GetErrorsForCertStatus(ssl.cert_id(),
+ ssl.cert_status(),
entry->GetURL(),
&errors);
- if (entry->HasMixedContent()) {
+ if (ssl.has_mixed_content()) {
errors.push_back(SSLErrorInfo::CreateError(SSLErrorInfo::MIXED_CONTENTS,
NULL, GURL::EmptyGURL()));
}
- if (entry->HasUnsafeContent()) {
+ if (ssl.has_unsafe_content()) {
errors.push_back(SSLErrorInfo::CreateError(SSLErrorInfo::UNSAFE_CONTENTS,
NULL, GURL::EmptyGURL()));
}
diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc
index 891ec4b..79593c9 100644
--- a/chrome/browser/web_contents.cc
+++ b/chrome/browser/web_contents.cc
@@ -1317,7 +1317,7 @@ NavigationEntry* WebContents::CreateNavigationEntryForCommit(
entry->SetFavIconURL(old_entry->GetFavIconURL());
if (in_page_nav) {
entry->SetValidFavIcon(old_entry->IsValidFavIcon());
- entry->CopySSLInfoFrom(*old_entry);
+ entry->ssl() = old_entry->ssl();
}
}
}
@@ -1436,10 +1436,9 @@ void WebContents::DidNavigateSubFramePreCommit(
// Reset entry state to match that of the pending entry.
entry->set_unique_id(last_committed->unique_id());
entry->SetURL(last_committed->GetURL());
- entry->SetSecurityStyle(last_committed->GetSecurityStyle());
- entry->SetContentState(last_committed->GetContentState());
entry->SetTransitionType(last_committed->GetTransitionType());
entry->SetUserTypedURL(last_committed->GetUserTypedURL());
+ entry->SetContentState(last_committed->GetContentState());
// TODO(jcampan): when navigating to an insecure/unsafe inner frame, the
// main entry is the one that gets notified of the mixed/unsafe contents
@@ -1447,10 +1446,9 @@ void WebContents::DidNavigateSubFramePreCommit(
// state. We should find a better way to do this.
// Note that it is OK that the mixed/unsafe contents is set on the wrong
// navigation entry, as that state is reset when navigating back to it.
- if (last_committed->HasMixedContent())
- entry->SetHasMixedContent();
- if (last_committed->HasUnsafeContent())
- entry->SetHasUnsafeContent();
+ DCHECK(last_committed->ssl().content_status() == 0) << "We should never be "
+ "setting the status bits from 1 to 0 on navigate.";
+ entry->ssl() = last_committed->ssl();
}
void WebContents::DidNavigateAnyFramePreCommit(