diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-22 19:03:12 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-22 19:03:12 +0000 |
commit | 619864aa8a68195cd58a6bc63b33d7a3c08520ba (patch) | |
tree | 50716a661a9af6ed5a21b06ac71a8d62b8524b7c /content/browser/tab_contents | |
parent | 653dc46f668da5aed227aafe39ec66fada3df230 (diff) | |
download | chromium_src-619864aa8a68195cd58a6bc63b33d7a3c08520ba.zip chromium_src-619864aa8a68195cd58a6bc63b33d7a3c08520ba.tar.gz chromium_src-619864aa8a68195cd58a6bc63b33d7a3c08520ba.tar.bz2 |
Revert 102322 - For the SSL cert status, convert anonymous enum that gives bit values into a typedefed uint32. This allows code all over Chromium to use an explicit type instead of "int". (This isn't possible by simply naming the enum as technically the enum doesn't define all of the possible combinations of bits.) This also means the individual named bit constants themselves have the same explicit type. I find the resulting code to be noticeably clearer. This also exposed a bug in SSLErrorInfo::GetErrorsForCertStatus() where not having an explicit type allowed a function argument ordering bug to creep in, so I claim this is safer too.
I also added CERT_STATUS_NO_ERROR in place of "0" as a magic number.
Normally this makes things like DCHECK_EQ() unhappy, but when I'd originally tested this I didn't seem to need to make any changes due to that. Will be watching the trybots...
The original motiviation for this change was to find a way to eliminate some cases of passing anonymous-typed values as template arguments (which happens when you use a value from the enum in e.g. EXPECT_EQ()), which is technically illegal in C++03, though we don't warn about it. Simply naming the enum would have done this, but this would have encouraged readers to actually use the enum name as a type, which for a bitfield is inappropriate for the reason given in the first paragraph.
BUG=92247
TEST=Compiles
Review URL: http://codereview.chromium.org/7819009
TBR=pkasting@chromium.org
Review URL: http://codereview.chromium.org/7995014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/tab_contents')
4 files changed, 8 insertions, 14 deletions
diff --git a/content/browser/tab_contents/navigation_entry.h b/content/browser/tab_contents/navigation_entry.h index 40bc8a8..2ed55b8 100644 --- a/content/browser/tab_contents/navigation_entry.h +++ b/content/browser/tab_contents/navigation_entry.h @@ -15,7 +15,6 @@ #include "content/common/page_type.h" #include "content/common/security_style.h" #include "googleurl/src/gurl.h" -#include "net/base/cert_status_flags.h" #include "third_party/skia/include/core/SkBitmap.h" class SiteInstance; @@ -76,10 +75,10 @@ class CONTENT_EXPORT NavigationEntry { return cert_id_; } - void set_cert_status(net::CertStatus ssl_cert_status) { + void set_cert_status(int ssl_cert_status) { cert_status_ = ssl_cert_status; } - net::CertStatus cert_status() const { + int cert_status() const { return cert_status_; } @@ -126,7 +125,7 @@ class CONTENT_EXPORT NavigationEntry { // See the accessors above for descriptions. SecurityStyle security_style_; int cert_id_; - net::CertStatus cert_status_; + int cert_status_; int security_bits_; int connection_status_; int content_status_; diff --git a/content/browser/tab_contents/navigation_entry_unittest.cc b/content/browser/tab_contents/navigation_entry_unittest.cc index a7b5ff9..ee7d083 100644 --- a/content/browser/tab_contents/navigation_entry_unittest.cc +++ b/content/browser/tab_contents/navigation_entry_unittest.cc @@ -113,14 +113,13 @@ TEST_F(NavigationEntryTest, NavigationEntrySSLStatus) { // Change from the defaults entry2_.get()->ssl().set_security_style(SECURITY_STYLE_AUTHENTICATED); entry2_.get()->ssl().set_cert_id(4); - entry2_.get()->ssl().set_cert_status(net::CERT_STATUS_COMMON_NAME_INVALID); + entry2_.get()->ssl().set_cert_status(1); entry2_.get()->ssl().set_security_bits(0); entry2_.get()->ssl().set_displayed_insecure_content(); EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, entry2_.get()->ssl().security_style()); EXPECT_EQ(4, entry2_.get()->ssl().cert_id()); - EXPECT_EQ(net::CERT_STATUS_COMMON_NAME_INVALID, - entry2_.get()->ssl().cert_status()); + EXPECT_EQ(1, entry2_.get()->ssl().cert_status()); EXPECT_EQ(0, entry2_.get()->ssl().security_bits()); EXPECT_TRUE(entry2_.get()->ssl().displayed_insecure_content()); diff --git a/content/browser/tab_contents/provisional_load_details.h b/content/browser/tab_contents/provisional_load_details.h index 87d6569..0e8331f 100644 --- a/content/browser/tab_contents/provisional_load_details.h +++ b/content/browser/tab_contents/provisional_load_details.h @@ -11,7 +11,6 @@ #include "base/basictypes.h" #include "content/common/page_transition_types.h" #include "googleurl/src/gurl.h" -#include "net/base/cert_status_flags.h" // This class captures some of the information associated to the provisional // load of a frame. It is provided as Details with the @@ -49,7 +48,7 @@ class ProvisionalLoadDetails { int ssl_cert_id() const { return ssl_cert_id_; } - net::CertStatus ssl_cert_status() const { return ssl_cert_status_; } + int ssl_cert_status() const { return ssl_cert_status_; } int ssl_security_bits() const { return ssl_security_bits_; } @@ -66,7 +65,7 @@ class ProvisionalLoadDetails { bool is_main_frame_; bool is_in_page_navigation_; int ssl_cert_id_; - net::CertStatus ssl_cert_status_; + int ssl_cert_status_; int ssl_security_bits_; int ssl_connection_status_; bool is_error_page_; diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 9e80c93..287e661 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -1030,10 +1030,7 @@ void TabContents::OnDidLoadResourceFromMemoryCache( cache.Increment(); // Send out a notification that we loaded a resource from our memory cache. - int cert_id = 0; - net::CertStatus cert_status = 0; - int security_bits = -1; - int connection_status = 0; + int cert_id = 0, cert_status = 0, security_bits = -1, connection_status = 0; SSLManager::DeserializeSecurityInfo(security_info, &cert_id, &cert_status, &security_bits, |