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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model_impl.cc

Issue 1440303002: Componentize SecurityStateModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android/cros fixes Created 5 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
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" 5 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 10 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/search/search.h" 12 #include "chrome/browser/search/search.h"
13 #include "chrome/browser/ssl/security_state_model.h" 13 #include "chrome/browser/ssl/chrome_security_state_model_delegate.h"
14 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" 14 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
18 #include "components/google/core/browser/google_util.h" 18 #include "components/google/core/browser/google_util.h"
19 #include "components/omnibox/browser/autocomplete_classifier.h" 19 #include "components/omnibox/browser/autocomplete_classifier.h"
20 #include "components/omnibox/browser/autocomplete_input.h" 20 #include "components/omnibox/browser/autocomplete_input.h"
21 #include "components/omnibox/browser/autocomplete_match.h" 21 #include "components/omnibox/browser/autocomplete_match.h"
22 #include "components/url_formatter/elide_url.h" 22 #include "components/url_formatter/elide_url.h"
23 #include "components/url_formatter/url_formatter.h" 23 #include "components/url_formatter/url_formatter.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return !GetSearchTerms(ignore_editing).empty(); 122 return !GetSearchTerms(ignore_editing).empty();
123 } 123 }
124 124
125 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( 125 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel(
126 bool ignore_editing) const { 126 bool ignore_editing) const {
127 const content::WebContents* web_contents = delegate_->GetActiveWebContents(); 127 const content::WebContents* web_contents = delegate_->GetActiveWebContents();
128 // If there is no active WebContents (which can happen during toolbar 128 // If there is no active WebContents (which can happen during toolbar
129 // initialization), assume no security style. 129 // initialization), assume no security style.
130 if (!web_contents) 130 if (!web_contents)
131 return SecurityStateModel::NONE; 131 return SecurityStateModel::NONE;
132 const SecurityStateModel* model = 132 const ChromeSecurityStateModelDelegate* model_delegate =
133 SecurityStateModel::FromWebContents(web_contents); 133 ChromeSecurityStateModelDelegate::FromWebContents(web_contents);
134 134
135 // When editing, assume no security style. 135 // When editing, assume no security style.
136 return (input_in_progress() && !ignore_editing) 136 return (input_in_progress() && !ignore_editing)
137 ? SecurityStateModel::NONE 137 ? SecurityStateModel::NONE
138 : model->GetSecurityInfo().security_level; 138 : static_cast<SecurityStateModel::SecurityLevel>(
139 model_delegate->GetSecurityInfo().security_level);
139 } 140 }
140 141
141 int ToolbarModelImpl::GetIcon() const { 142 int ToolbarModelImpl::GetIcon() const {
142 switch (GetSecurityLevel(false)) { 143 switch (GetSecurityLevel(false)) {
143 case SecurityStateModel::NONE: 144 case SecurityStateModel::NONE:
144 return IDR_LOCATION_BAR_HTTP; 145 return IDR_LOCATION_BAR_HTTP;
145 case SecurityStateModel::EV_SECURE: 146 case SecurityStateModel::EV_SECURE:
146 case SecurityStateModel::SECURE: 147 case SecurityStateModel::SECURE:
147 return IDR_OMNIBOX_HTTPS_VALID; 148 return IDR_OMNIBOX_HTTPS_VALID;
148 case SecurityStateModel::SECURITY_WARNING: 149 case SecurityStateModel::SECURITY_WARNING:
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 275
275 // Otherwise, extract search terms for HTTPS pages that do not have a security 276 // Otherwise, extract search terms for HTTPS pages that do not have a security
276 // error. 277 // error.
277 SecurityStateModel::SecurityLevel security_level = 278 SecurityStateModel::SecurityLevel security_level =
278 GetSecurityLevel(ignore_editing); 279 GetSecurityLevel(ignore_editing);
279 return ((security_level == SecurityStateModel::NONE) || 280 return ((security_level == SecurityStateModel::NONE) ||
280 (security_level == SecurityStateModel::SECURITY_ERROR)) 281 (security_level == SecurityStateModel::SECURITY_ERROR))
281 ? base::string16() 282 ? base::string16()
282 : search_terms; 283 : search_terms;
283 } 284 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_helpers.cc ('k') | chrome/browser/ui/views/frame/web_app_left_header_view_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698