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

Unified Diff: chrome/browser/ui/toolbar/toolbar_model_impl.cc

Issue 1314843007: Refactor connection_security into SecurityStateModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: create SecurityStateModel for chromeos login webview Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_model_impl.h ('k') | chrome/browser/ui/toolbar/toolbar_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/toolbar/toolbar_model_impl.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_model_impl.cc b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
index 6f2c5426d247e77bf1e0c3b93f1f6073b77d20e7..c14164d05a37ba3bffd73a5b57c4eb5510b6e43d 100644
--- a/chrome/browser/ui/toolbar/toolbar_model_impl.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
@@ -10,7 +10,7 @@
#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/search.h"
-#include "chrome/browser/ssl/connection_security.h"
+#include "chrome/browser/ssl/security_state_model.h"
#include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -109,13 +109,20 @@ bool ToolbarModelImpl::WouldPerformSearchTermReplacement(
return !GetSearchTerms(ignore_editing).empty();
}
-connection_security::SecurityLevel ToolbarModelImpl::GetSecurityLevel(
+SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel(
bool ignore_editing) const {
+ const content::WebContents* web_contents = delegate_->GetActiveWebContents();
+ // If there is no active WebContents (which can happen during toolbar
+ // initialization), assume no security style.
+ if (!web_contents)
+ return SecurityStateModel::NONE;
+ const SecurityStateModel* model =
+ SecurityStateModel::FromWebContents(web_contents);
+
// When editing, assume no security style.
return (input_in_progress() && !ignore_editing)
- ? connection_security::NONE
- : connection_security::GetSecurityLevelForWebContents(
- delegate_->GetActiveWebContents());
+ ? SecurityStateModel::NONE
+ : model->security_info().security_level;
}
int ToolbarModelImpl::GetIcon() const {
@@ -126,19 +133,19 @@ int ToolbarModelImpl::GetIcon() const {
}
int ToolbarModelImpl::GetIconForSecurityLevel(
- connection_security::SecurityLevel level) const {
+ SecurityStateModel::SecurityLevel level) const {
switch (level) {
- case connection_security::NONE:
+ case SecurityStateModel::NONE:
return IDR_LOCATION_BAR_HTTP;
- case connection_security::EV_SECURE:
- case connection_security::SECURE:
+ case SecurityStateModel::EV_SECURE:
+ case SecurityStateModel::SECURE:
return IDR_OMNIBOX_HTTPS_VALID;
- case connection_security::SECURITY_WARNING:
+ case SecurityStateModel::SECURITY_WARNING:
// Surface Dubious as Neutral.
return IDR_LOCATION_BAR_HTTP;
- case connection_security::SECURITY_POLICY_WARNING:
+ case SecurityStateModel::SECURITY_POLICY_WARNING:
return IDR_OMNIBOX_HTTPS_POLICY_WARNING;
- case connection_security::SECURITY_ERROR:
+ case SecurityStateModel::SECURITY_ERROR:
return IDR_OMNIBOX_HTTPS_INVALID;
}
@@ -147,7 +154,7 @@ int ToolbarModelImpl::GetIconForSecurityLevel(
}
base::string16 ToolbarModelImpl::GetEVCertName() const {
- if (GetSecurityLevel(false) != connection_security::EV_SECURE)
+ if (GetSecurityLevel(false) != SecurityStateModel::EV_SECURE)
return base::string16();
// Note: Navigation controller and active entry are guaranteed non-NULL or
@@ -240,10 +247,10 @@ base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const {
// Otherwise, extract search terms for HTTPS pages that do not have a security
// error.
- connection_security::SecurityLevel security_level =
+ SecurityStateModel::SecurityLevel security_level =
GetSecurityLevel(ignore_editing);
- return ((security_level == connection_security::NONE) ||
- (security_level == connection_security::SECURITY_ERROR))
+ return ((security_level == SecurityStateModel::NONE) ||
+ (security_level == SecurityStateModel::SECURITY_ERROR))
? base::string16()
: search_terms;
}
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_model_impl.h ('k') | chrome/browser/ui/toolbar/toolbar_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698