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 "components/toolbar/toolbar_model_impl.h" | 5 #include "components/toolbar/toolbar_model_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.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 "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return delegate_->GetURL(&url) ? url : GURL(url::kAboutBlankURL); | 91 return delegate_->GetURL(&url) ? url : GURL(url::kAboutBlankURL); |
92 } | 92 } |
93 | 93 |
94 bool ToolbarModelImpl::WouldPerformSearchTermReplacement( | 94 bool ToolbarModelImpl::WouldPerformSearchTermReplacement( |
95 bool ignore_editing) const { | 95 bool ignore_editing) const { |
96 return !GetSearchTerms(ignore_editing).empty(); | 96 return !GetSearchTerms(ignore_editing).empty(); |
97 } | 97 } |
98 | 98 |
99 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( | 99 SecurityStateModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( |
100 bool ignore_editing) const { | 100 bool ignore_editing) const { |
101 // When editing, assume no security style. | 101 // When editing or empty, assume no security style. |
102 return (input_in_progress() && !ignore_editing) | 102 return ((input_in_progress() && !ignore_editing) || !ShouldDisplayURL()) |
103 ? SecurityStateModel::NONE | 103 ? SecurityStateModel::NONE |
104 : delegate_->GetSecurityLevel(); | 104 : delegate_->GetSecurityLevel(); |
105 } | 105 } |
106 | 106 |
107 int ToolbarModelImpl::GetIcon() const { | 107 int ToolbarModelImpl::GetIcon() const { |
108 switch (GetSecurityLevel(false)) { | 108 switch (GetSecurityLevel(false)) { |
109 case SecurityStateModel::NONE: | 109 case SecurityStateModel::NONE: |
110 return IDR_LOCATION_BAR_HTTP; | 110 return IDR_LOCATION_BAR_HTTP; |
111 case SecurityStateModel::EV_SECURE: | 111 case SecurityStateModel::EV_SECURE: |
112 case SecurityStateModel::SECURE: | 112 case SecurityStateModel::SECURE: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 bool ToolbarModelImpl::ShouldDisplayURL() const { | 166 bool ToolbarModelImpl::ShouldDisplayURL() const { |
167 return delegate_->ShouldDisplayURL(); | 167 return delegate_->ShouldDisplayURL(); |
168 } | 168 } |
169 | 169 |
170 base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const { | 170 base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const { |
171 if (!url_replacement_enabled() || (input_in_progress() && !ignore_editing)) | 171 if (!url_replacement_enabled() || (input_in_progress() && !ignore_editing)) |
172 return base::string16(); | 172 return base::string16(); |
173 | 173 |
174 return delegate_->GetSearchTerms(GetSecurityLevel(ignore_editing)); | 174 return delegate_->GetSearchTerms(GetSecurityLevel(ignore_editing)); |
175 } | 175 } |
OLD | NEW |