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 "components/toolbar/toolbar_model_impl.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" | |
11 #include "components/google/core/browser/google_util.h" | 10 #include "components/google/core/browser/google_util.h" |
| 11 #include "components/grit/components_scaled_resources.h" |
12 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
13 #include "components/security_state/security_state_model.h" | 13 #include "components/security_state/security_state_model.h" |
| 14 #include "components/strings/grit/components_strings.h" |
| 15 #include "components/toolbar/toolbar_model_delegate.h" |
14 #include "components/url_formatter/elide_url.h" | 16 #include "components/url_formatter/elide_url.h" |
15 #include "components/url_formatter/url_formatter.h" | 17 #include "components/url_formatter/url_formatter.h" |
16 #include "grit/components_scaled_resources.h" | |
17 #include "grit/components_strings.h" | |
18 #include "net/cert/cert_status_flags.h" | 18 #include "net/cert/cert_status_flags.h" |
19 #include "net/cert/x509_certificate.h" | 19 #include "net/cert/x509_certificate.h" |
20 #include "net/ssl/ssl_connection_status_flags.h" | 20 #include "net/ssl/ssl_connection_status_flags.h" |
21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/gfx/text_elider.h" | 22 #include "ui/gfx/text_elider.h" |
23 #include "ui/gfx/vector_icons_public.h" | 23 #include "ui/gfx/vector_icons_public.h" |
24 | 24 |
25 using security_state::SecurityStateModel; | 25 using security_state::SecurityStateModel; |
26 | 26 |
27 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate, | 27 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 base::string16 ToolbarModelImpl::GetCorpusNameForMobile() const { | 69 base::string16 ToolbarModelImpl::GetCorpusNameForMobile() const { |
70 if (!WouldPerformSearchTermReplacement(false)) | 70 if (!WouldPerformSearchTermReplacement(false)) |
71 return base::string16(); | 71 return base::string16(); |
72 GURL url(GetURL()); | 72 GURL url(GetURL()); |
73 // If there is a query in the url fragment look for the corpus name there, | 73 // If there is a query in the url fragment look for the corpus name there, |
74 // otherwise look for the corpus name in the query parameters. | 74 // otherwise look for the corpus name in the query parameters. |
75 const std::string& query_str(google_util::HasGoogleSearchQueryParam( | 75 const std::string& query_str(google_util::HasGoogleSearchQueryParam( |
76 url.ref_piece()) ? url.ref() : url.query()); | 76 url.ref_piece()) ? url.ref() : url.query()); |
77 url::Component query(0, query_str.length()), key, value; | 77 url::Component query(0, static_cast<int>(query_str.length())), key, value; |
78 const char kChipKey[] = "sboxchip"; | 78 const char kChipKey[] = "sboxchip"; |
79 while (url::ExtractQueryKeyValue(query_str.c_str(), &query, &key, &value)) { | 79 while (url::ExtractQueryKeyValue(query_str.c_str(), &query, &key, &value)) { |
80 if (key.is_nonempty() && query_str.substr(key.begin, key.len) == kChipKey) { | 80 if (key.is_nonempty() && query_str.substr(key.begin, key.len) == kChipKey) { |
81 return net::UnescapeAndDecodeUTF8URLComponent( | 81 return net::UnescapeAndDecodeUTF8URLComponent( |
82 query_str.substr(value.begin, value.len), | 82 query_str.substr(value.begin, value.len), |
83 net::UnescapeRule::NORMAL); | 83 net::UnescapeRule::NORMAL); |
84 } | 84 } |
85 } | 85 } |
86 return base::string16(); | 86 return base::string16(); |
87 } | 87 } |
(...skipping 78 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 |