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/autocomplete_classifier.h" | 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
11 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 11 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
12 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 12 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/search/search.h" | 14 #include "chrome/browser/search/search.h" |
15 #include "chrome/browser/ssl/connection_security_helper.h" | 15 #include "chrome/browser/ssl/connection_security_helper.h" |
16 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" | 16 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
20 #include "components/google/core/browser/google_util.h" | 20 #include "components/google/core/browser/google_util.h" |
21 #include "components/omnibox/autocomplete_input.h" | 21 #include "components/omnibox/autocomplete_input.h" |
22 #include "components/omnibox/autocomplete_match.h" | 22 #include "components/omnibox/autocomplete_match.h" |
| 23 #include "components/url_formatter/url_formatter.h" |
23 #include "content/public/browser/cert_store.h" | 24 #include "content/public/browser/cert_store.h" |
24 #include "content/public/browser/navigation_controller.h" | 25 #include "content/public/browser/navigation_controller.h" |
25 #include "content/public/browser/navigation_entry.h" | 26 #include "content/public/browser/navigation_entry.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
28 #include "content/public/common/content_constants.h" | 29 #include "content/public/common/content_constants.h" |
29 #include "content/public/common/ssl_status.h" | 30 #include "content/public/common/ssl_status.h" |
30 #include "grit/components_scaled_resources.h" | 31 #include "grit/components_scaled_resources.h" |
31 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
32 #include "net/base/net_util.h" | |
33 #include "net/cert/cert_status_flags.h" | 33 #include "net/cert/cert_status_flags.h" |
34 #include "net/cert/x509_certificate.h" | 34 #include "net/cert/x509_certificate.h" |
35 #include "net/ssl/ssl_connection_status_flags.h" | 35 #include "net/ssl/ssl_connection_status_flags.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
37 | 37 |
38 using content::NavigationController; | 38 using content::NavigationController; |
39 using content::NavigationEntry; | 39 using content::NavigationEntry; |
40 using content::WebContents; | 40 using content::WebContents; |
41 | 41 |
42 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) | 42 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) |
(...skipping 18 matching lines...) Expand all Loading... |
61 if (profile) | 61 if (profile) |
62 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 62 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
63 | 63 |
64 GURL url(GetURL()); | 64 GURL url(GetURL()); |
65 if (url.spec().length() > content::kMaxURLDisplayChars) | 65 if (url.spec().length() > content::kMaxURLDisplayChars) |
66 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); | 66 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); |
67 // Note that we can't unescape spaces here, because if the user copies this | 67 // Note that we can't unescape spaces here, because if the user copies this |
68 // and pastes it into another program, that program may think the URL ends at | 68 // and pastes it into another program, that program may think the URL ends at |
69 // the space. | 69 // the space. |
70 return AutocompleteInput::FormattedStringWithEquivalentMeaning( | 70 return AutocompleteInput::FormattedStringWithEquivalentMeaning( |
71 url, net::FormatUrl(url, languages, net::kFormatUrlOmitAll, | 71 url, url_formatter::FormatUrl( |
72 net::UnescapeRule::NORMAL, NULL, prefix_end, NULL), | 72 url, languages, url_formatter::kFormatUrlOmitAll, |
| 73 net::UnescapeRule::NORMAL, nullptr, prefix_end, nullptr), |
73 ChromeAutocompleteSchemeClassifier(profile)); | 74 ChromeAutocompleteSchemeClassifier(profile)); |
74 } | 75 } |
75 | 76 |
76 base::string16 ToolbarModelImpl::GetCorpusNameForMobile() const { | 77 base::string16 ToolbarModelImpl::GetCorpusNameForMobile() const { |
77 if (!WouldPerformSearchTermReplacement(false)) | 78 if (!WouldPerformSearchTermReplacement(false)) |
78 return base::string16(); | 79 return base::string16(); |
79 GURL url(GetURL()); | 80 GURL url(GetURL()); |
80 // If there is a query in the url fragment look for the corpus name there, | 81 // If there is a query in the url fragment look for the corpus name there, |
81 // otherwise look for the corpus name in the query parameters. | 82 // otherwise look for the corpus name in the query parameters. |
82 const std::string& query_str(google_util::HasGoogleSearchQueryParam( | 83 const std::string& query_str(google_util::HasGoogleSearchQueryParam( |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 240 |
240 // Otherwise, extract search terms for HTTPS pages that do not have a security | 241 // Otherwise, extract search terms for HTTPS pages that do not have a security |
241 // error. | 242 // error. |
242 ConnectionSecurityHelper::SecurityLevel security_level = | 243 ConnectionSecurityHelper::SecurityLevel security_level = |
243 GetSecurityLevel(ignore_editing); | 244 GetSecurityLevel(ignore_editing); |
244 return ((security_level == ConnectionSecurityHelper::NONE) || | 245 return ((security_level == ConnectionSecurityHelper::NONE) || |
245 (security_level == ConnectionSecurityHelper::SECURITY_ERROR)) | 246 (security_level == ConnectionSecurityHelper::SECURITY_ERROR)) |
246 ? base::string16() | 247 ? base::string16() |
247 : search_terms; | 248 : search_terms; |
248 } | 249 } |
OLD | NEW |