| OLD | NEW |
| 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/chrome_security_state_model_client.h" |
| 13 #include "chrome/browser/ssl/security_state_model.h" | 14 #include "chrome/browser/ssl/security_state_model.h" |
| 14 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" | 15 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 18 #include "components/google/core/browser/google_util.h" | 19 #include "components/google/core/browser/google_util.h" |
| 19 #include "components/omnibox/browser/autocomplete_classifier.h" | 20 #include "components/omnibox/browser/autocomplete_classifier.h" |
| 20 #include "components/omnibox/browser/autocomplete_input.h" | 21 #include "components/omnibox/browser/autocomplete_input.h" |
| 21 #include "components/omnibox/browser/autocomplete_match.h" | 22 #include "components/omnibox/browser/autocomplete_match.h" |
| 22 #include "components/url_formatter/elide_url.h" | 23 #include "components/url_formatter/elide_url.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return !GetSearchTerms(ignore_editing).empty(); | 123 return !GetSearchTerms(ignore_editing).empty(); |
| 123 } | 124 } |
| 124 | 125 |
| 125 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( | 126 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( |
| 126 bool ignore_editing) const { | 127 bool ignore_editing) const { |
| 127 const content::WebContents* web_contents = delegate_->GetActiveWebContents(); | 128 const content::WebContents* web_contents = delegate_->GetActiveWebContents(); |
| 128 // If there is no active WebContents (which can happen during toolbar | 129 // If there is no active WebContents (which can happen during toolbar |
| 129 // initialization), assume no security style. | 130 // initialization), assume no security style. |
| 130 if (!web_contents) | 131 if (!web_contents) |
| 131 return SecurityStateModel::NONE; | 132 return SecurityStateModel::NONE; |
| 132 const SecurityStateModel* model = | 133 const ChromeSecurityStateModelClient* model_delegate = |
| 133 SecurityStateModel::FromWebContents(web_contents); | 134 ChromeSecurityStateModelClient::FromWebContents(web_contents); |
| 134 | 135 |
| 135 // When editing, assume no security style. | 136 // When editing, assume no security style. |
| 136 return (input_in_progress() && !ignore_editing) | 137 return (input_in_progress() && !ignore_editing) |
| 137 ? SecurityStateModel::NONE | 138 ? SecurityStateModel::NONE |
| 138 : model->GetSecurityInfo().security_level; | 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 Loading... |
| 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 } |
| OLD | NEW |