summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 00:55:08 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 00:55:08 +0000
commit70d6650d6f65b91dbcb67847aaae640d041aa592 (patch)
treebc3c91e1e67a825a30e730491a267a6c0201b1b2 /chrome
parent0a075d63f82146768aac85366fa28ae8dcb5cfa9 (diff)
downloadchromium_src-70d6650d6f65b91dbcb67847aaae640d041aa592.zip
chromium_src-70d6650d6f65b91dbcb67847aaae640d041aa592.tar.gz
chromium_src-70d6650d6f65b91dbcb67847aaae640d041aa592.tar.bz2
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 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.
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/7969023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102415 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc11
-rw-r--r--chrome/browser/automation/testing_automation_provider.h7
-rw-r--r--chrome/browser/page_info_model.cc6
-rw-r--r--chrome/browser/ssl/ssl_browser_tests.cc6
-rw-r--r--chrome/browser/ssl/ssl_error_info.cc4
-rw-r--r--chrome/browser/ssl/ssl_error_info.h8
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc5
-rw-r--r--chrome/browser/ui/toolbar/toolbar_model.cc4
-rw-r--r--chrome/common/automation_messages_internal.h7
-rw-r--r--chrome/test/automation/tab_proxy.cc2
-rw-r--r--chrome/test/automation/tab_proxy.h2
11 files changed, 36 insertions, 26 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index c1f805d..bc08fdc 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -1480,11 +1480,12 @@ void TestingAutomationProvider::WaitForTabToBeRestored(
}
}
-void TestingAutomationProvider::GetSecurityState(int handle,
- bool* success,
- SecurityStyle* security_style,
- int* ssl_cert_status,
- int* insecure_content_status) {
+void TestingAutomationProvider::GetSecurityState(
+ int handle,
+ bool* success,
+ SecurityStyle* security_style,
+ net::CertStatus* ssl_cert_status,
+ int* insecure_content_status) {
if (tab_tracker_->ContainsHandle(handle)) {
NavigationController* tab = tab_tracker_->GetResource(handle);
NavigationEntry* entry = tab->GetActiveEntry();
diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h
index a9e4441..02efc7c 100644
--- a/chrome/browser/automation/testing_automation_provider.h
+++ b/chrome/browser/automation/testing_automation_provider.h
@@ -19,6 +19,7 @@
#include "chrome/browser/ui/browser_list.h"
#include "content/common/notification_registrar.h"
#include "content/common/page_type.h"
+#include "net/base/cert_status_flags.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
class ImporterList;
@@ -196,8 +197,10 @@ class TestingAutomationProvider : public AutomationProvider,
void WaitForTabToBeRestored(int tab_handle, IPC::Message* reply_message);
// Gets the security state for the tab associated to the specified |handle|.
- void GetSecurityState(int handle, bool* success,
- SecurityStyle* security_style, int* ssl_cert_status,
+ void GetSecurityState(int handle,
+ bool* success,
+ SecurityStyle* security_style,
+ net::CertStatus* ssl_cert_status,
int* insecure_content_status);
// Gets the page type for the tab associated to the specified |handle|.
diff --git a/chrome/browser/page_info_model.cc b/chrome/browser/page_info_model.cc
index 4395e50..9e4394d 100644
--- a/chrome/browser/page_info_model.cc
+++ b/chrome/browser/page_info_model.cc
@@ -68,7 +68,7 @@ PageInfoModel::PageInfoModel(Profile* profile,
CertStore::GetInstance()->RetrieveCert(ssl.cert_id(), &cert) &&
!net::IsCertStatusError(status_with_warnings_removed)) {
// No error found so far, check cert_status warnings.
- int cert_status = ssl.cert_status();
+ net::CertStatus cert_status = ssl.cert_status();
if (cert_status & cert_warnings) {
string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
if (issuer_name.empty()) {
@@ -89,7 +89,7 @@ PageInfoModel::PageInfoModel(Profile* profile,
NOTREACHED() << "Need to specify string for this warning";
}
icon_id = ICON_STATE_WARNING_MINOR;
- } else if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) != 0) {
+ } else if (ssl.cert_status() & net::CERT_STATUS_IS_EV) {
// EV HTTPS page.
DCHECK(!cert->subject().organization_names.empty());
headline =
@@ -119,7 +119,7 @@ PageInfoModel::PageInfoModel(Profile* profile,
UTF8ToUTF16(cert->subject().organization_names[0]),
locality,
UTF8ToUTF16(cert->issuer().GetDisplayName())));
- } else if ((ssl.cert_status() & net::CERT_STATUS_IS_DNSSEC) != 0) {
+ } else if (ssl.cert_status() & net::CERT_STATUS_IS_DNSSEC) {
// DNSSEC authenticated page.
if (empty_subject_name)
headline.clear(); // Don't display any title.
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index 59b3712..47427a2 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -49,7 +49,7 @@ class SSLUITest : public InProcessBrowserTest {
ASSERT_TRUE(entry);
EXPECT_EQ(NORMAL_PAGE, entry->page_type());
EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, entry->ssl().security_style());
- EXPECT_EQ(0, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS);
+ EXPECT_EQ(0U, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS);
EXPECT_EQ(displayed_insecure_content,
entry->ssl().displayed_insecure_content());
EXPECT_FALSE(entry->ssl().ran_insecure_content());
@@ -60,13 +60,13 @@ class SSLUITest : public InProcessBrowserTest {
ASSERT_TRUE(entry);
EXPECT_EQ(NORMAL_PAGE, entry->page_type());
EXPECT_EQ(SECURITY_STYLE_UNAUTHENTICATED, entry->ssl().security_style());
- EXPECT_EQ(0, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS);
+ EXPECT_EQ(0U, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS);
EXPECT_FALSE(entry->ssl().displayed_insecure_content());
EXPECT_FALSE(entry->ssl().ran_insecure_content());
}
void CheckAuthenticationBrokenState(TabContents* tab,
- int error,
+ net::CertStatus error,
bool ran_insecure_content,
bool interstitial) {
NavigationEntry* entry = tab->controller().GetActiveEntry();
diff --git a/chrome/browser/ssl/ssl_error_info.cc b/chrome/browser/ssl/ssl_error_info.cc
index 63555d4..5bfa28b 100644
--- a/chrome/browser/ssl/ssl_error_info.cc
+++ b/chrome/browser/ssl/ssl_error_info.cc
@@ -231,10 +231,10 @@ SSLErrorInfo::ErrorType SSLErrorInfo::NetErrorToErrorType(int net_error) {
// static
int SSLErrorInfo::GetErrorsForCertStatus(int cert_id,
- int cert_status,
+ net::CertStatus cert_status,
const GURL& url,
std::vector<SSLErrorInfo>* errors) {
- const int kErrorFlags[] = {
+ const net::CertStatus kErrorFlags[] = {
net::CERT_STATUS_COMMON_NAME_INVALID,
net::CERT_STATUS_DATE_INVALID,
net::CERT_STATUS_AUTHORITY_INVALID,
diff --git a/chrome/browser/ssl/ssl_error_info.h b/chrome/browser/ssl/ssl_error_info.h
index ca87a0b4..79d2908 100644
--- a/chrome/browser/ssl/ssl_error_info.h
+++ b/chrome/browser/ssl/ssl_error_info.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/string16.h"
+#include "net/base/cert_status_flags.h"
#include "net/base/x509_certificate.h"
class GURL;
@@ -46,9 +47,10 @@ class SSLErrorInfo {
// Populates the specified |errors| vector with the errors contained in
// |cert_status|. Returns the number of errors found.
// Callers only interested in the error count can pass NULL for |errors|.
- static int GetErrorsForCertStatus(int cert_status,
- int cert_id,
- const GURL& request_url,
+ // TODO(wtc): Document |cert_id| and |url| arguments.
+ static int GetErrorsForCertStatus(int cert_id,
+ net::CertStatus cert_status,
+ const GURL& url,
std::vector<SSLErrorInfo>* errors);
// A title describing the error, usually to be used with the details below.
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 31bb05b..0099b90 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -1664,7 +1664,10 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
// Deserialize the SSL info.
NavigationEntry::SSLStatus ssl;
if (!params_.security_info.empty()) {
- int cert_id, cert_status, security_bits, connection_status;
+ int cert_id;
+ net::CertStatus cert_status;
+ int security_bits;
+ int connection_status;
SSLManager::DeserializeSecurityInfo(params_.security_info,
&cert_id,
&cert_status,
diff --git a/chrome/browser/ui/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model.cc
index a7284d2..6716e73 100644
--- a/chrome/browser/ui/toolbar/toolbar_model.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model.cc
@@ -86,8 +86,8 @@ ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const {
if (ssl.displayed_insecure_content())
return SECURITY_WARNING;
if (net::IsCertStatusError(ssl.cert_status())) {
- DCHECK_EQ(ssl.cert_status() & net::CERT_STATUS_ALL_ERRORS,
- net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION);
+ DCHECK_EQ(net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION,
+ ssl.cert_status() & net::CERT_STATUS_ALL_ERRORS);
return SECURITY_WARNING;
}
if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) &&
diff --git a/chrome/common/automation_messages_internal.h b/chrome/common/automation_messages_internal.h
index 55020c6..17e1def 100644
--- a/chrome/common/automation_messages_internal.h
+++ b/chrome/common/automation_messages_internal.h
@@ -12,6 +12,7 @@
#include "content/common/navigation_types.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h"
+#include "net/base/cert_status_flags.h"
#include "net/url_request/url_request_status.h"
#include "ui/gfx/rect.h"
#include "webkit/glue/window_open_disposition.h"
@@ -552,15 +553,15 @@ IPC_MESSAGE_ROUTED1(AutomationMsg_DidNavigate,
// Response:
// - bool: whether the operation was successful.
// - SecurityStyle: the security style of the tab.
-// - int: the status of the server's ssl cert (0 means no errors or no ssl
-// was used).
+// - net::CertStatus: the status of the server's ssl cert (0 means no errors or
+// no ssl was used).
// - int: the insecure content state, 0 means no insecure contents.
IPC_SYNC_MESSAGE_CONTROL1_4(AutomationMsg_GetSecurityState,
int,
bool,
SecurityStyle,
- int,
+ net::CertStatus,
int)
// This message requests the page type of the page displayed in the specified
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index d45fe9a..0a2a5c1 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -571,7 +571,7 @@ bool TabProxy::WaitForTabToBeRestored(uint32 timeout_ms) {
}
bool TabProxy::GetSecurityState(SecurityStyle* security_style,
- int* ssl_cert_status,
+ net::CertStatus* ssl_cert_status,
int* insecure_content_status) {
DCHECK(security_style && ssl_cert_status && insecure_content_status);
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index 26d3ea3..a92f422 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -282,7 +282,7 @@ class TabProxy : public AutomationResourceProxy,
// Retrieves the different security states for the current tab.
bool GetSecurityState(SecurityStyle* security_style,
- int* ssl_cert_status,
+ net::CertStatus* ssl_cert_status,
int* insecure_content_status) WARN_UNUSED_RESULT;
// Returns the type of the page currently showing (normal, interstitial,